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

Unified Diff: chrome/browser/ui/ash/system_tray_client.cc

Issue 2360143004: mash: Add SystemTrayClient interface, use to show date settings (Closed)
Patch Set: reparent 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
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | chrome/browser/ui/ash/system_tray_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/system_tray_client.cc
diff --git a/chrome/browser/ui/ash/system_tray_controller_mus.cc b/chrome/browser/ui/ash/system_tray_client.cc
similarity index 36%
rename from chrome/browser/ui/ash/system_tray_controller_mus.cc
rename to chrome/browser/ui/ash/system_tray_client.cc
index 4fae245db722aa0caed2d463695a518605b72f55..81acd94ea8232c84e55346ecb9389bd9b665c1fc 100644
--- a/chrome/browser/ui/ash/system_tray_controller_mus.cc
+++ b/chrome/browser/ui/ash/system_tray_client.cc
@@ -2,27 +2,67 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/ui/ash/system_tray_controller_mus.h"
+#include "chrome/browser/ui/ash/system_tray_client.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/chromeos/system/system_clock.h"
+#include "chrome/browser/ui/ash/system_tray_common.h"
#include "content/public/common/mojo_shell_connection.h"
#include "services/shell/public/cpp/connector.h"
-SystemTrayControllerMus::SystemTrayControllerMus() {
- shell::Connector* connector =
- content::MojoShellConnection::GetForProcess()->GetConnector();
- connector->ConnectToInterface("mojo:ash", &system_tray_);
+namespace {
+SystemTrayClient* g_instance = nullptr;
+
+} // namespace
+
+SystemTrayClient::SystemTrayClient() {
+ // If this observes clock setting changes before ash comes up the IPCs will
+ // be queued on |system_tray_|.
g_browser_process->platform_part()->GetSystemClock()->AddObserver(this);
+
+ DCHECK(!g_instance);
+ g_instance = this;
}
-SystemTrayControllerMus::~SystemTrayControllerMus() {
+SystemTrayClient::~SystemTrayClient() {
+ DCHECK_EQ(this, g_instance);
+ g_instance = nullptr;
+
g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this);
}
-void SystemTrayControllerMus::OnSystemClockChanged(
+// static
+SystemTrayClient* SystemTrayClient::Get() {
+ return g_instance;
+}
+
+void SystemTrayClient::ConnectToSystemTray() {
+ if (system_tray_.is_bound())
+ return;
+
+ content::MojoShellConnection::GetForProcess()
+ ->GetConnector()
+ ->ConnectToInterface("mojo:ash", &system_tray_);
+
+ // Tolerate ash crashing and coming back up.
+ system_tray_.set_connection_error_handler(base::Bind(
+ &SystemTrayClient::OnClientConnectionError, base::Unretained(this)));
+}
+
+void SystemTrayClient::OnClientConnectionError() {
+ system_tray_.reset();
+}
+
+void SystemTrayClient::ShowDateSettings() {
+ SystemTrayCommon::ShowDateSettings();
+}
+
+void SystemTrayClient::OnSystemClockChanged(
chromeos::system::SystemClock* clock) {
+ ConnectToSystemTray();
system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock());
}
« no previous file with comments | « chrome/browser/ui/ash/system_tray_client.h ('k') | chrome/browser/ui/ash/system_tray_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698