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

Side by Side 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/mus/system_tray_delegate_mus.h" 5 #include "ash/mus/system_tray_delegate_mus.h"
6 6
7 #include "ash/common/system/tray/system_tray_notifier.h" 7 #include "ash/common/system/tray/system_tray_notifier.h"
8 #include "ash/common/wm_shell.h" 8 #include "ash/common/wm_shell.h"
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
9 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "services/shell/public/cpp/connector.h"
11 14
12 namespace ash { 15 namespace ash {
13 namespace { 16 namespace {
14 17
15 SystemTrayDelegateMus* g_instance = nullptr; 18 SystemTrayDelegateMus* g_instance = nullptr;
16 19
17 } // namespace 20 } // namespace
18 21
19 SystemTrayDelegateMus::SystemTrayDelegateMus() 22 SystemTrayDelegateMus::SystemTrayDelegateMus(shell::Connector* connector)
20 : hour_clock_type_(base::GetHourClockType()) { 23 : connector_(connector), hour_clock_type_(base::GetHourClockType()) {
24 // Don't make an initial connection to exe:chrome. Do it on demand.
21 DCHECK(!g_instance); 25 DCHECK(!g_instance);
22 g_instance = this; 26 g_instance = this;
23 } 27 }
24 28
25 SystemTrayDelegateMus::~SystemTrayDelegateMus() { 29 SystemTrayDelegateMus::~SystemTrayDelegateMus() {
26 DCHECK_EQ(this, g_instance); 30 DCHECK_EQ(this, g_instance);
27 g_instance = nullptr; 31 g_instance = nullptr;
28 } 32 }
29 33
30 // static 34 // static
31 SystemTrayDelegateMus* SystemTrayDelegateMus::Get() { 35 SystemTrayDelegateMus* SystemTrayDelegateMus::Get() {
32 return g_instance; 36 return g_instance;
33 } 37 }
34 38
39 void SystemTrayDelegateMus::ConnectToSystemTrayClient() {
40 if (system_tray_client_.is_bound())
41 return;
42
43 connector_->ConnectToInterface("exe:chrome", &system_tray_client_);
44
45 // Tolerate chrome crashing and coming back up.
46 system_tray_client_.set_connection_error_handler(base::Bind(
47 &SystemTrayDelegateMus::OnClientConnectionError, base::Unretained(this)));
48 }
49
50 void SystemTrayDelegateMus::OnClientConnectionError() {
51 system_tray_client_.reset();
52 }
53
35 base::HourClockType SystemTrayDelegateMus::GetHourClockType() const { 54 base::HourClockType SystemTrayDelegateMus::GetHourClockType() const {
36 return hour_clock_type_; 55 return hour_clock_type_;
37 } 56 }
38 57
58 void SystemTrayDelegateMus::ShowDateSettings() {
59 ConnectToSystemTrayClient();
60 system_tray_client_->ShowDateSettings();
61 }
62
39 void SystemTrayDelegateMus::SetUse24HourClock(bool use_24_hour) { 63 void SystemTrayDelegateMus::SetUse24HourClock(bool use_24_hour) {
40 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; 64 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock;
41 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); 65 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged();
42 } 66 }
43 67
44 } // namespace ash 68 } // namespace ash
OLDNEW
« 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