| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/public/interfaces/system_tray.mojom.h" | 9 #include "ash/public/interfaces/system_tray.mojom.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/i18n/time_formatting.h" | 11 #include "base/i18n/time_formatting.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
| 14 | 14 |
| 15 namespace service_manager { | |
| 16 class Connector; | |
| 17 } | |
| 18 | |
| 19 namespace ash { | 15 namespace ash { |
| 20 | 16 |
| 21 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient | 17 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient |
| 22 // interface. The wrapper makes the initial connection and handles reconnecting | 18 // interface. Implements both because it caches state pushed down from the |
| 23 // on error. Implements both because it caches state pushed down from the | |
| 24 // browser process via SystemTray so it can be synchronously queried inside ash. | 19 // browser process via SystemTray so it can be synchronously queried inside ash. |
| 25 // | 20 // |
| 26 // Conceptually similar to historical ash-to-chrome interfaces like | 21 // Conceptually similar to historical ash-to-chrome interfaces like |
| 27 // SystemTrayDelegate. Lives on the main thread. | 22 // SystemTrayDelegate. Lives on the main thread. |
| 28 // | 23 // |
| 29 // Only connects to the actual mojom::SystemTrayClient interface when running on | |
| 30 // Chrome OS. In tests and on Windows all operations are no-ops. | |
| 31 // | |
| 32 // TODO: Consider renaming this to SystemTrayClient or renaming the current | 24 // TODO: Consider renaming this to SystemTrayClient or renaming the current |
| 33 // SystemTray to SystemTrayView and making this class SystemTray. | 25 // SystemTray to SystemTrayView and making this class SystemTray. |
| 34 class ASH_EXPORT SystemTrayController | 26 class ASH_EXPORT SystemTrayController |
| 35 : NON_EXPORTED_BASE(public mojom::SystemTray) { | 27 : NON_EXPORTED_BASE(public mojom::SystemTray) { |
| 36 public: | 28 public: |
| 37 explicit SystemTrayController(service_manager::Connector* connector); | 29 SystemTrayController(); |
| 38 ~SystemTrayController() override; | 30 ~SystemTrayController() override; |
| 39 | 31 |
| 40 base::HourClockType hour_clock_type() const { return hour_clock_type_; } | 32 base::HourClockType hour_clock_type() const { return hour_clock_type_; } |
| 41 | 33 |
| 42 // Wrappers around the mojom::SystemTrayClient interface. | 34 // Wrappers around the mojom::SystemTrayClient interface. |
| 43 void ShowSettings(); | 35 void ShowSettings(); |
| 44 void ShowDateSettings(); | 36 void ShowDateSettings(); |
| 45 void ShowSetTimeDialog(); | 37 void ShowSetTimeDialog(); |
| 46 void ShowDisplaySettings(); | 38 void ShowDisplaySettings(); |
| 47 void ShowPowerSettings(); | 39 void ShowPowerSettings(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 void ShowThirdPartyVpnCreate(const std::string& extension_id); | 50 void ShowThirdPartyVpnCreate(const std::string& extension_id); |
| 59 void ShowNetworkSettings(const std::string& network_id); | 51 void ShowNetworkSettings(const std::string& network_id); |
| 60 void ShowProxySettings(); | 52 void ShowProxySettings(); |
| 61 void SignOut(); | 53 void SignOut(); |
| 62 void RequestRestartForUpdate(); | 54 void RequestRestartForUpdate(); |
| 63 | 55 |
| 64 // Binds the mojom::SystemTray interface to this object. | 56 // Binds the mojom::SystemTray interface to this object. |
| 65 void BindRequest(mojom::SystemTrayRequest request); | 57 void BindRequest(mojom::SystemTrayRequest request); |
| 66 | 58 |
| 67 private: | 59 private: |
| 68 // Connects or reconnects to the mojom::SystemTrayClient interface when | |
| 69 // running on Chrome OS. Otherwise does nothing. Returns true if connected. | |
| 70 bool ConnectToSystemTrayClient(); | |
| 71 | |
| 72 // Handles errors on the |system_tray_client_| interface connection. | |
| 73 void OnClientConnectionError(); | |
| 74 | |
| 75 // mojom::SystemTray: | 60 // mojom::SystemTray: |
| 61 void SetClient(mojom::SystemTrayClientPtr client) override; |
| 76 void SetUse24HourClock(bool use_24_hour) override; | 62 void SetUse24HourClock(bool use_24_hour) override; |
| 77 | 63 |
| 78 // May be null in unit tests. | |
| 79 service_manager::Connector* connector_; | |
| 80 | |
| 81 // Client interface in chrome browser. Only bound on Chrome OS. | 64 // Client interface in chrome browser. Only bound on Chrome OS. |
| 82 mojom::SystemTrayClientPtr system_tray_client_; | 65 mojom::SystemTrayClientPtr system_tray_client_; |
| 83 | 66 |
| 84 // Bindings for the SystemTray interface. | 67 // Bindings for the SystemTray interface. |
| 85 mojo::BindingSet<mojom::SystemTray> bindings_; | 68 mojo::BindingSet<mojom::SystemTray> bindings_; |
| 86 | 69 |
| 87 // The type of clock hour display: 12 or 24 hour. | 70 // The type of clock hour display: 12 or 24 hour. |
| 88 base::HourClockType hour_clock_type_; | 71 base::HourClockType hour_clock_type_; |
| 89 | 72 |
| 90 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); | 73 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); |
| 91 }; | 74 }; |
| 92 | 75 |
| 93 } // namspace ash | 76 } // namspace ash |
| 94 | 77 |
| 95 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | 78 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |
| OLD | NEW |