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 "mojo/public/cpp/bindings/binding_set.h" | |
| 12 | |
| 13 namespace shell { | |
| 14 class Connector; | |
| 15 } | |
| 16 | |
| 17 namespace ash { | |
| 18 | |
| 19 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient | |
| 20 // interface. The wrapper makes the initial connection and handles reconnecting | |
| 21 // on error. Implements both because it caches state pushed down from the | |
| 22 // browser process via SystemTray so it can be synchronously queried inside ash. | |
| 23 // | |
| 24 // Conceptually similar to historical ash-to-chrome interfaces like | |
| 25 // SystemTrayDelegate. Lives on the main thread. | |
| 26 // | |
| 27 // Only connects to the actual mojom::SystemTrayClient interface when running on | |
| 28 // Chrome OS. In tests and on Windows all operations are no-ops. | |
| 29 // | |
| 30 // TODO: Consider renaming this to SystemTrayClient or renaming the current | |
| 31 // SystemTray to SystemTrayView and making this class SystemTray. | |
| 32 class SystemTrayController : public mojom::SystemTray { | |
| 33 public: | |
| 34 explicit SystemTrayController(shell::Connector* connector); | |
| 35 ~SystemTrayController() override; | |
| 36 | |
| 37 // Wrappers around the mojom::SystemTrayClient interface. | |
| 38 base::HourClockType hour_clock_type() const { return hour_clock_type_; } | |
| 39 void ShowDateSettings(); | |
| 40 | |
| 41 // Binds the mojom::SystemTray interface to this object. | |
| 42 void BindRequest(mojom::SystemTrayRequest request); | |
|
Ken Rockot(use gerrit already)
2016/10/03 18:19:03
Then again... if you keep MojoInterfaceFactory as
| |
| 43 | |
| 44 private: | |
| 45 // Connects or reconnects to the mojom::SystemTrayClient interface when | |
| 46 // running on Chrome OS. Otherwise does nothing. Returns true if connected. | |
| 47 bool ConnectToSystemTrayClient(); | |
| 48 | |
| 49 // Handles errors on the |system_tray_client_| interface connection. | |
| 50 void OnClientConnectionError(); | |
| 51 | |
| 52 // mojom::SystemTray: | |
| 53 void SetUse24HourClock(bool use_24_hour) override; | |
| 54 | |
| 55 // May be null in unit tests. | |
| 56 shell::Connector* connector_; | |
| 57 | |
| 58 // Client interface in chrome browser. Only bound on Chrome OS. | |
| 59 mojom::SystemTrayClientPtr system_tray_client_; | |
| 60 | |
| 61 // Bindings for the SystemTray interface. | |
| 62 mojo::BindingSet<mojom::SystemTray> bindings_; | |
| 63 | |
| 64 // The type of clock hour display: 12 or 24 hour. | |
| 65 base::HourClockType hour_clock_type_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); | |
| 68 }; | |
| 69 | |
| 70 } // namspace ash | |
| 71 | |
| 72 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ | |
| OLD | NEW |