tray_power.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (c) 2012 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_POWER_TRAY_POWER_H_
  5. #define ASH_SYSTEM_POWER_TRAY_POWER_H_
  6. #include <memory>
  7. #include "ash/public/cpp/session/session_observer.h"
  8. #include "ash/system/power/power_status.h"
  9. #include "ash/system/tray/tray_item_view.h"
  10. namespace ash {
  11. class PowerTrayView : public TrayItemView,
  12. public PowerStatus::Observer,
  13. public SessionObserver {
  14. public:
  15. explicit PowerTrayView(Shelf* shelf);
  16. PowerTrayView(const PowerTrayView&) = delete;
  17. PowerTrayView& operator=(const PowerTrayView&) = delete;
  18. ~PowerTrayView() override;
  19. // views::View:
  20. gfx::Size CalculatePreferredSize() const override;
  21. void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
  22. views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
  23. std::u16string GetTooltipText(const gfx::Point& p) const override;
  24. const char* GetClassName() const override;
  25. void OnThemeChanged() override;
  26. // TrayItemView:
  27. void HandleLocaleChange() override;
  28. // PowerStatus::Observer:
  29. void OnPowerStatusChanged() override;
  30. // SessionObserver:
  31. void OnSessionStateChanged(session_manager::SessionState state) override;
  32. private:
  33. void UpdateStatus();
  34. void UpdateImage(bool icon_color_changed);
  35. std::u16string accessible_name_;
  36. std::u16string tooltip_;
  37. absl::optional<PowerStatus::BatteryImageInfo> info_;
  38. session_manager::SessionState session_state_ =
  39. session_manager::SessionState::UNKNOWN;
  40. ScopedSessionObserver session_observer_{this};
  41. };
  42. } // namespace ash
  43. #endif // ASH_SYSTEM_POWER_TRAY_POWER_H_