Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | |
| 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | |
| 7 | |
| 8 #include "ash/public/interfaces/system_tray.mojom.h" | |
| 9 #include "base/i18n/time_formatting.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "base/observer_list.h" | |
|
msw
2016/09/30 23:26:49
nit: remove
James Cook
2016/10/03 18:07:56
Done.
| |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 13 | |
| 14 namespace shell { | |
| 15 class Connector; | |
| 16 } | |
| 17 | |
| 18 namespace ash { | |
| 19 | |
| 20 class ClockObserver; | |
|
msw
2016/09/30 23:26:49
nit: remove
James Cook
2016/10/03 18:07:56
Done.
| |
| 21 | |
| 22 // Wrapper around the mojom::SystemTrayClient interface that makes the initial | |
|
msw
2016/09/30 23:26:48
nit: mention that it implements mojom::SystemTray?
James Cook
2016/10/03 18:07:55
Rewrote.
| |
| 23 // connection and reconnects on error. Also caches state pushed down from chrome | |
| 24 // browser to allow synchronous access to the state. Conceptually similar to | |
| 25 // historical ash-to-chrome interfaces like SystemTrayDelegate. Lives on the | |
| 26 // main thread. | |
| 27 // | |
| 28 // Only connects to the actual mojom::SystemTrayClient interface when running on | |
| 29 // Chrome OS. In tests and on Windows all operations are no-ops. | |
| 30 // | |
| 31 // TODO: Consider renaming this to SystemTrayClient or renaming the current | |
|
msw
2016/09/30 23:26:49
I definitely favor the latter option :)
| |
| 32 // SystemTray to SystemTrayView and making this class SystemTray. | |
| 33 class SystemTrayController : public mojom::SystemTray { | |
| 34 public: | |
| 35 explicit SystemTrayController(shell::Connector* connector); | |
| 36 ~SystemTrayController() override; | |
| 37 | |
| 38 // Wrappers around the mojom::SystemTrayClient interface. | |
| 39 base::HourClockType GetHourClockType() const; | |
| 40 void ShowDateSettings(); | |
| 41 | |
|
James Cook
2016/09/30 21:18:27
The other ShowFoo() methods will end up here.
msw
2016/09/30 23:26:49
Acknowledged.
| |
| 42 // Binds the mojom::SystemTray interface to this object. | |
| 43 void BindRequest(mojom::SystemTrayRequest request); | |
| 44 | |
| 45 private: | |
| 46 // Connects or reconnects to the mojom::SystemTrayClient interface when | |
| 47 // running on Chrome OS. Otherwise does nothing. | |
| 48 void ConnectToSystemTrayClient(); | |
| 49 | |
| 50 // Handles errors on the |system_tray_client_| interface connection. | |
| 51 void OnClientConnectionError(); | |
| 52 | |
| 53 // mojom::SystemTray: | |
| 54 void SetUse24HourClock(bool use_24_hour) override; | |
| 55 | |
| 56 // May be null in unit tests. | |
| 57 shell::Connector* connector_; | |
| 58 | |
| 59 // Client interface in chrome browser. Only bound on Chrome OS. | |
| 60 mojom::SystemTrayClientPtr system_tray_client_; | |
| 61 | |
| 62 // Bindings for the SystemTray interface. | |
| 63 mojo::BindingSet<mojom::SystemTray> bindings_; | |
| 64 | |
| 65 // 12 or 24 hour display. | |
|
msw
2016/09/30 23:26:49
optional nit: The type of hour display: 12 or 24 h
James Cook
2016/10/03 18:07:56
Done.
| |
| 66 base::HourClockType hour_clock_type_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); | |
| 69 }; | |
| 70 | |
| 71 } // namspace ash | |
| 72 | |
| 73 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | |
| OLD | NEW |