Index: ash/common/system/tray/system_tray_controller.h |
diff --git a/ash/common/system/tray/system_tray_controller.h b/ash/common/system/tray/system_tray_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a229b7e5711f3b0e4350bff3ffb0734486195b70 |
--- /dev/null |
+++ b/ash/common/system/tray/system_tray_controller.h |
@@ -0,0 +1,69 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |
+#define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |
+ |
+#include "ash/public/interfaces/system_tray.mojom.h" |
+#include "base/i18n/time_formatting.h" |
+#include "base/macros.h" |
+#include "base/observer_list.h" |
+ |
+namespace shell { |
+class Connector; |
+} |
+ |
+namespace ash { |
+ |
+class ClockObserver; |
+ |
+// Allows control of the system tray the mojom::SystemTray interface. Provides |
+// caching of state pushed down from chrome browser. Provides a wrapper around |
+// the mojom::SystemTrayClient interface that handles retries. |
+// |
+// TODO: What about tests? How would you mock one of these? |
+// |
+// TODO: Delete SystemTrayDelegateMus |
+// This would be called "SystemTray" but we already have one of those. |
+class SystemTrayController : public mojom::SystemTray { |
+ public: |
+ explicit SystemTrayController(shell::Connector* connector); |
+ ~SystemTrayController() override; |
+ |
+ // REVIEWERS: Methods migrated from SystemTrayDelegate. |
+ base::HourClockType GetHourClockType() const; |
+ void ShowDateSettings(); |
+ |
+ // TODO: Migrate other observers from SystemTrayNotifier. |
+ void AddClockObserver(ClockObserver* observer); |
+ void RemoveClockObserver(ClockObserver* observer); |
+ |
+ private: |
+ // Connects or reconnects to the mojom::SystemTrayClient interface and returns |
+ // the interface pointer. |
+ mojom::SystemTrayClient* ConnectToSystemTrayClient(); |
+ |
+ // Handles errors on the |system_tray_client_| interface connection. |
+ void OnClientConnectionError(); |
+ |
+ // mojom::SystemTray: |
+ void SetUse24HourClock(bool use_24_hour) override; |
+ |
+ // May be null in unit tests. |
+ shell::Connector* connector_; |
+ |
+ // Client interface in chrome browser. |
+ mojom::SystemTrayClientPtr system_tray_client_; |
+ |
+ // 12 or 24 hour display. |
+ base::HourClockType hour_clock_type_; |
+ |
+ base::ObserverList<ClockObserver> clock_observers_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayController); |
+}; |
+ |
+} // namspace ash |
+ |
+#endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ |