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

Unified Diff: ash/mus/system_tray_delegate_mus.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 | « ash/mus/system_tray_delegate_mus.h ('k') | ash/public/interfaces/system_tray.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/system_tray_delegate_mus.cc
diff --git a/ash/mus/system_tray_delegate_mus.cc b/ash/mus/system_tray_delegate_mus.cc
index 8add535aa2bf63f0e61f51d57121d91a21396604..f2afff5527e22ea33723c2f96543ae0273b0415b 100644
--- a/ash/mus/system_tray_delegate_mus.cc
+++ b/ash/mus/system_tray_delegate_mus.cc
@@ -6,8 +6,11 @@
#include "ash/common/system/tray/system_tray_notifier.h"
#include "ash/common/wm_shell.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/i18n/time_formatting.h"
#include "base/logging.h"
+#include "services/shell/public/cpp/connector.h"
namespace ash {
namespace {
@@ -16,8 +19,9 @@ SystemTrayDelegateMus* g_instance = nullptr;
} // namespace
-SystemTrayDelegateMus::SystemTrayDelegateMus()
- : hour_clock_type_(base::GetHourClockType()) {
+SystemTrayDelegateMus::SystemTrayDelegateMus(shell::Connector* connector)
+ : connector_(connector), hour_clock_type_(base::GetHourClockType()) {
+ // Don't make an initial connection to exe:chrome. Do it on demand.
DCHECK(!g_instance);
g_instance = this;
}
@@ -32,10 +36,30 @@ SystemTrayDelegateMus* SystemTrayDelegateMus::Get() {
return g_instance;
}
+void SystemTrayDelegateMus::ConnectToSystemTrayClient() {
+ if (system_tray_client_.is_bound())
+ return;
+
+ connector_->ConnectToInterface("exe:chrome", &system_tray_client_);
+
+ // Tolerate chrome crashing and coming back up.
+ system_tray_client_.set_connection_error_handler(base::Bind(
+ &SystemTrayDelegateMus::OnClientConnectionError, base::Unretained(this)));
+}
+
+void SystemTrayDelegateMus::OnClientConnectionError() {
+ system_tray_client_.reset();
+}
+
base::HourClockType SystemTrayDelegateMus::GetHourClockType() const {
return hour_clock_type_;
}
+void SystemTrayDelegateMus::ShowDateSettings() {
+ ConnectToSystemTrayClient();
+ system_tray_client_->ShowDateSettings();
+}
+
void SystemTrayDelegateMus::SetUse24HourClock(bool use_24_hour) {
hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock;
WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged();
« no previous file with comments | « ash/mus/system_tray_delegate_mus.h ('k') | ash/public/interfaces/system_tray.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698