network_tray_view.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2018 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_NETWORK_NETWORK_TRAY_VIEW_H_
  5. #define ASH_SYSTEM_NETWORK_NETWORK_TRAY_VIEW_H_
  6. #include <memory>
  7. #include "ash/public/cpp/session/session_observer.h"
  8. #include "ash/system/network/active_network_icon.h"
  9. #include "ash/system/network/network_icon_animation_observer.h"
  10. #include "ash/system/network/tray_network_state_observer.h"
  11. #include "ash/system/tray/tray_item_view.h"
  12. namespace ash {
  13. // View class containing an ImageView for a network icon in the tray.
  14. // The ActiveNetworkIcon::Type parameter determines what type of icon is
  15. // displayed. Generation and update of the icon is handled by ActiveNetworkIcon.
  16. class NetworkTrayView : public TrayItemView,
  17. public network_icon::AnimationObserver,
  18. public SessionObserver,
  19. public TrayNetworkStateObserver {
  20. public:
  21. NetworkTrayView(const NetworkTrayView&) = delete;
  22. NetworkTrayView& operator=(const NetworkTrayView&) = delete;
  23. ~NetworkTrayView() override;
  24. NetworkTrayView(Shelf* shelf, ActiveNetworkIcon::Type type);
  25. std::u16string GetAccessibleNameString() const;
  26. const char* GetClassName() const override;
  27. // views::View:
  28. void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
  29. views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
  30. std::u16string GetTooltipText(const gfx::Point& p) const override;
  31. // TrayItemView:
  32. void HandleLocaleChange() override;
  33. void OnThemeChanged() override;
  34. // network_icon::AnimationObserver:
  35. void NetworkIconChanged() override;
  36. // SessionObserver:
  37. void OnSessionStateChanged(session_manager::SessionState state) override;
  38. // TrayNetworkStateObserver:
  39. void ActiveNetworkStateChanged() override;
  40. void NetworkListChanged() override;
  41. private:
  42. void UpdateIcon(bool tray_icon_visible, const gfx::ImageSkia& image);
  43. void UpdateNetworkStateHandlerIcon();
  44. // Updates the tooltip and calls NotifyAccessibilityEvent when necessary.
  45. void UpdateConnectionStatus(bool notify_a11y);
  46. ActiveNetworkIcon::Type type_;
  47. // The name provided by GetAccessibleNodeData, which includes the network
  48. // name and connection state.
  49. std::u16string accessible_name_;
  50. // The description provided by GetAccessibleNodeData. For wifi networks this
  51. // is the signal strength of the network. Otherwise it is empty.
  52. std::u16string accessible_description_;
  53. // The tooltip for the icon. Includes the network name and signal strength
  54. // (for wireless networks).
  55. std::u16string tooltip_;
  56. };
  57. } // namespace ash
  58. #endif // ASH_SYSTEM_NETWORK_NETWORK_TRAY_VIEW_H_