Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: ash/common/system/tray/system_tray_controller.h

Issue 2381753002: Use mojo SystemTray interfaces for both mash and classic ash (Closed)
Patch Set: Restructure based on feedback Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3bb09d3d90a5cd080cd43c84d2db255c79661e47
--- /dev/null
+++ b/ash/common/system/tray/system_tray_controller.h
@@ -0,0 +1,73 @@
+// 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"
msw 2016/09/30 23:26:49 nit: remove
James Cook 2016/10/03 18:07:56 Done.
+#include "mojo/public/cpp/bindings/binding_set.h"
+
+namespace shell {
+class Connector;
+}
+
+namespace ash {
+
+class ClockObserver;
msw 2016/09/30 23:26:49 nit: remove
James Cook 2016/10/03 18:07:56 Done.
+
+// 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.
+// connection and reconnects on error. Also caches state pushed down from chrome
+// browser to allow synchronous access to the state. Conceptually similar to
+// historical ash-to-chrome interfaces like SystemTrayDelegate. Lives on the
+// main thread.
+//
+// Only connects to the actual mojom::SystemTrayClient interface when running on
+// Chrome OS. In tests and on Windows all operations are no-ops.
+//
+// TODO: Consider renaming this to SystemTrayClient or renaming the current
msw 2016/09/30 23:26:49 I definitely favor the latter option :)
+// SystemTray to SystemTrayView and making this class SystemTray.
+class SystemTrayController : public mojom::SystemTray {
+ public:
+ explicit SystemTrayController(shell::Connector* connector);
+ ~SystemTrayController() override;
+
+ // Wrappers around the mojom::SystemTrayClient interface.
+ base::HourClockType GetHourClockType() const;
+ void ShowDateSettings();
+
James Cook 2016/09/30 21:18:27 The other ShowFoo() methods will end up here.
msw 2016/09/30 23:26:49 Acknowledged.
+ // Binds the mojom::SystemTray interface to this object.
+ void BindRequest(mojom::SystemTrayRequest request);
+
+ private:
+ // Connects or reconnects to the mojom::SystemTrayClient interface when
+ // running on Chrome OS. Otherwise does nothing.
+ void 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. Only bound on Chrome OS.
+ mojom::SystemTrayClientPtr system_tray_client_;
+
+ // Bindings for the SystemTray interface.
+ mojo::BindingSet<mojom::SystemTray> bindings_;
+
+ // 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.
+ base::HourClockType hour_clock_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemTrayController);
+};
+
+} // namspace ash
+
+#endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698