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 shell { | 15 namespace service_manager { |
16 class Connector; | 16 class Connector; |
17 } | 17 } |
18 | 18 |
19 namespace ash { | 19 namespace ash { |
20 | 20 |
21 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient | 21 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient |
22 // interface. The wrapper makes the initial connection and handles reconnecting | 22 // interface. The wrapper makes the initial connection and handles reconnecting |
23 // on error. 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. | 24 // browser process via SystemTray so it can be synchronously queried inside ash. |
25 // | 25 // |
26 // Conceptually similar to historical ash-to-chrome interfaces like | 26 // Conceptually similar to historical ash-to-chrome interfaces like |
27 // SystemTrayDelegate. Lives on the main thread. | 27 // SystemTrayDelegate. Lives on the main thread. |
28 // | 28 // |
29 // Only connects to the actual mojom::SystemTrayClient interface when running on | 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. | 30 // Chrome OS. In tests and on Windows all operations are no-ops. |
31 // | 31 // |
32 // TODO: Consider renaming this to SystemTrayClient or renaming the current | 32 // TODO: Consider renaming this to SystemTrayClient or renaming the current |
33 // SystemTray to SystemTrayView and making this class SystemTray. | 33 // SystemTray to SystemTrayView and making this class SystemTray. |
34 class ASH_EXPORT SystemTrayController | 34 class ASH_EXPORT SystemTrayController |
35 : NON_EXPORTED_BASE(public mojom::SystemTray) { | 35 : NON_EXPORTED_BASE(public mojom::SystemTray) { |
36 public: | 36 public: |
37 explicit SystemTrayController(shell::Connector* connector); | 37 explicit SystemTrayController(service_manager::Connector* connector); |
38 ~SystemTrayController() override; | 38 ~SystemTrayController() override; |
39 | 39 |
40 base::HourClockType hour_clock_type() const { return hour_clock_type_; } | 40 base::HourClockType hour_clock_type() const { return hour_clock_type_; } |
41 | 41 |
42 // Wrappers around the mojom::SystemTrayClient interface. | 42 // Wrappers around the mojom::SystemTrayClient interface. |
43 void ShowSettings(); | 43 void ShowSettings(); |
44 void ShowDateSettings(); | 44 void ShowDateSettings(); |
45 void ShowDisplaySettings(); | 45 void ShowDisplaySettings(); |
46 void ShowPowerSettings(); | 46 void ShowPowerSettings(); |
47 void ShowChromeSlow(); | 47 void ShowChromeSlow(); |
(...skipping 16 matching lines...) Expand all Loading... |
64 // running on Chrome OS. Otherwise does nothing. Returns true if connected. | 64 // running on Chrome OS. Otherwise does nothing. Returns true if connected. |
65 bool ConnectToSystemTrayClient(); | 65 bool ConnectToSystemTrayClient(); |
66 | 66 |
67 // Handles errors on the |system_tray_client_| interface connection. | 67 // Handles errors on the |system_tray_client_| interface connection. |
68 void OnClientConnectionError(); | 68 void OnClientConnectionError(); |
69 | 69 |
70 // mojom::SystemTray: | 70 // mojom::SystemTray: |
71 void SetUse24HourClock(bool use_24_hour) override; | 71 void SetUse24HourClock(bool use_24_hour) override; |
72 | 72 |
73 // May be null in unit tests. | 73 // May be null in unit tests. |
74 shell::Connector* connector_; | 74 service_manager::Connector* connector_; |
75 | 75 |
76 // Client interface in chrome browser. Only bound on Chrome OS. | 76 // Client interface in chrome browser. Only bound on Chrome OS. |
77 mojom::SystemTrayClientPtr system_tray_client_; | 77 mojom::SystemTrayClientPtr system_tray_client_; |
78 | 78 |
79 // Bindings for the SystemTray interface. | 79 // Bindings for the SystemTray interface. |
80 mojo::BindingSet<mojom::SystemTray> bindings_; | 80 mojo::BindingSet<mojom::SystemTray> bindings_; |
81 | 81 |
82 // The type of clock hour display: 12 or 24 hour. | 82 // The type of clock hour display: 12 or 24 hour. |
83 base::HourClockType hour_clock_type_; | 83 base::HourClockType hour_clock_type_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); | 85 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); |
86 }; | 86 }; |
87 | 87 |
88 } // namspace ash | 88 } // namspace ash |
89 | 89 |
90 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | 90 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |
OLD | NEW |