phone_status_view.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_PHONEHUB_PHONE_STATUS_VIEW_H_
  5. #define ASH_SYSTEM_PHONEHUB_PHONE_STATUS_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/components/phonehub/phone_model.h"
  8. #include "ash/system/power/power_status.h"
  9. #include "ash/system/tray/tri_view.h"
  10. #include "base/gtest_prod_util.h"
  11. namespace views {
  12. class ImageView;
  13. class Label;
  14. class Separator;
  15. } // namespace views
  16. namespace ash {
  17. class IconButton;
  18. // The header row at the top of the Phone Hub panel, showing phone title and
  19. // status (wifi, volime, etc.).
  20. class ASH_EXPORT PhoneStatusView : public TriView,
  21. public phonehub::PhoneModel::Observer {
  22. public:
  23. class Delegate {
  24. public:
  25. virtual bool CanOpenConnectedDeviceSettings() = 0;
  26. virtual void OpenConnectedDevicesSettings() = 0;
  27. };
  28. PhoneStatusView(phonehub::PhoneModel* phone_model, Delegate* delegate);
  29. ~PhoneStatusView() override;
  30. PhoneStatusView(PhoneStatusView&) = delete;
  31. PhoneStatusView operator=(PhoneStatusView&) = delete;
  32. // TriView:
  33. void OnThemeChanged() override;
  34. // phonehub::PhoneHubModel::Observer:
  35. void OnModelChanged() override;
  36. private:
  37. FRIEND_TEST_ALL_PREFIXES(PhoneStatusViewTest, MobileProviderVisibility);
  38. FRIEND_TEST_ALL_PREFIXES(PhoneStatusViewTest, PhoneStatusLabelsContent);
  39. FRIEND_TEST_ALL_PREFIXES(PhoneStatusViewTest, ClickOnSettings);
  40. // Update the labels and icons in the view to display current phone status.
  41. void Update();
  42. void UpdateMobileStatus();
  43. void UpdateBatteryStatus();
  44. PowerStatus::BatteryImageInfo CalculateBatteryInfo();
  45. void SetBatteryTooltipText();
  46. // Clear the existing labels and icons for the phone status.
  47. void ClearExistingStatus();
  48. void ConfigureTriViewContainer(TriView::Container container);
  49. phonehub::PhoneModel* phone_model_ = nullptr;
  50. Delegate* delegate_ = nullptr;
  51. // Owned by views hierarchy.
  52. views::Label* phone_name_label_ = nullptr;
  53. views::ImageView* signal_icon_ = nullptr;
  54. views::ImageView* battery_icon_ = nullptr;
  55. views::Label* battery_label_ = nullptr;
  56. views::Separator* separator_ = nullptr;
  57. IconButton* settings_button_ = nullptr;
  58. };
  59. } // namespace ash
  60. #endif // ASH_SYSTEM_PHONEHUB_PHONE_STATUS_VIEW_H_