network_feature_pod_controller.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2021 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_FEATURE_POD_CONTROLLER_H_
  5. #define ASH_SYSTEM_NETWORK_NETWORK_FEATURE_POD_CONTROLLER_H_
  6. #include <string>
  7. #include "ash/system/network/network_feature_pod_button.h"
  8. #include "ash/system/network/network_icon_animation_observer.h"
  9. #include "ash/system/network/tray_network_state_observer.h"
  10. #include "ash/system/tray/system_tray_item_uma_type.h"
  11. #include "ash/system/unified/feature_pod_controller_base.h"
  12. #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom.h"
  13. namespace ash {
  14. class FeaturePodButton;
  15. class UnifiedSystemTrayController;
  16. // Controller of the feature pod button that allows users to toggle whether
  17. // certain network technologies are enabled or disabled, and that allows users
  18. // to navigate to a more detailed page with a network list.
  19. class ASH_EXPORT NetworkFeaturePodController
  20. : public network_icon::AnimationObserver,
  21. public FeaturePodControllerBase,
  22. public NetworkFeaturePodButton::Delegate,
  23. public TrayNetworkStateObserver {
  24. public:
  25. explicit NetworkFeaturePodController(
  26. UnifiedSystemTrayController* tray_controller);
  27. NetworkFeaturePodController(const NetworkFeaturePodController&) = delete;
  28. NetworkFeaturePodController& operator=(const NetworkFeaturePodController&) =
  29. delete;
  30. ~NetworkFeaturePodController() override;
  31. // FeaturePodControllerBase:
  32. FeaturePodButton* CreateButton() override;
  33. void OnIconPressed() override;
  34. void OnLabelPressed() override;
  35. SystemTrayItemUmaType GetUmaType() const override;
  36. private:
  37. // network_icon::AnimationObserver:
  38. void NetworkIconChanged() override;
  39. // NetworkFeaturePodButton::Delegate:
  40. void OnFeaturePodButtonThemeChanged() override;
  41. // TrayNetworkStateObserver:
  42. void ActiveNetworkStateChanged() override;
  43. std::u16string ComputeButtonLabel(
  44. const chromeos::network_config::mojom::NetworkStateProperties* network)
  45. const;
  46. std::u16string ComputeButtonSubLabel(
  47. const chromeos::network_config::mojom::NetworkStateProperties* network)
  48. const;
  49. // Updates |button_| state to reflect the current state of networks.
  50. void UpdateButtonStateIfExists();
  51. FeaturePodButton* button_ = nullptr;
  52. UnifiedSystemTrayController* tray_controller_;
  53. };
  54. } // namespace ash
  55. #endif // ASH_SYSTEM_NETWORK_NETWORK_FEATURE_POD_CONTROLLER_H_