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

Side by Side Diff: ash/mus/system_tray_delegate_mus.cc

Issue 2381753002: Use mojo SystemTray interfaces for both mash and classic ash (Closed)
Patch Set: cleanup 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/mus/system_tray_delegate_mus.h"
6
7 #include "ash/common/system/tray/system_tray_notifier.h"
8 #include "ash/common/wm_shell.h"
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/i18n/time_formatting.h"
12 #include "base/logging.h"
13 #include "services/shell/public/cpp/connector.h"
14
15 namespace ash {
16 namespace {
17
18 SystemTrayDelegateMus* g_instance = nullptr;
19
20 } // namespace
21
22 SystemTrayDelegateMus::SystemTrayDelegateMus(shell::Connector* connector)
23 : connector_(connector), hour_clock_type_(base::GetHourClockType()) {
24 // Don't make an initial connection to exe:chrome. Do it on demand.
25 DCHECK(!g_instance);
26 g_instance = this;
27 }
28
29 SystemTrayDelegateMus::~SystemTrayDelegateMus() {
30 DCHECK_EQ(this, g_instance);
31 g_instance = nullptr;
32 }
33
34 // static
35 SystemTrayDelegateMus* SystemTrayDelegateMus::Get() {
36 return g_instance;
37 }
38
39 mojom::SystemTrayClient* SystemTrayDelegateMus::ConnectToSystemTrayClient() {
40 if (!system_tray_client_.is_bound()) {
41 // Connect (or reconnect) to the interface.
42 connector_->ConnectToInterface("exe:chrome", &system_tray_client_);
43
44 // Tolerate chrome crashing and coming back up.
45 system_tray_client_.set_connection_error_handler(
46 base::Bind(&SystemTrayDelegateMus::OnClientConnectionError,
47 base::Unretained(this)));
48 }
49 return system_tray_client_.get();
50 }
51
52 void SystemTrayDelegateMus::OnClientConnectionError() {
53 system_tray_client_.reset();
54 }
55
56 ////////////////////////////////////////////////////////////////////////////////
57 // SystemTrayDelegate:
58
59 base::HourClockType SystemTrayDelegateMus::GetHourClockType() const {
60 return hour_clock_type_;
61 }
62
63 void SystemTrayDelegateMus::ShowSettings() {
64 ConnectToSystemTrayClient()->ShowSettings();
65 }
66
67 void SystemTrayDelegateMus::ShowDateSettings() {
68 ConnectToSystemTrayClient()->ShowDateSettings();
69 }
70
71 void SystemTrayDelegateMus::ShowNetworkSettingsForGuid(
72 const std::string& guid) {
73 // http://crbug.com/647412
74 NOTIMPLEMENTED();
75 }
76
77 void SystemTrayDelegateMus::ShowDisplaySettings() {
78 ConnectToSystemTrayClient()->ShowDisplaySettings();
79 }
80
81 void SystemTrayDelegateMus::ShowPowerSettings() {
82 // http://crbug.com/647412
83 NOTIMPLEMENTED();
84 }
85
86 void SystemTrayDelegateMus::ShowChromeSlow() {
87 ConnectToSystemTrayClient()->ShowChromeSlow();
88 }
89
90 void SystemTrayDelegateMus::ShowIMESettings() {
91 ConnectToSystemTrayClient()->ShowIMESettings();
92 }
93
94 void SystemTrayDelegateMus::ShowHelp() {
95 ConnectToSystemTrayClient()->ShowHelp();
96 }
97
98 void SystemTrayDelegateMus::ShowAccessibilityHelp() {
99 ConnectToSystemTrayClient()->ShowAccessibilityHelp();
100 }
101
102 void SystemTrayDelegateMus::ShowAccessibilitySettings() {
103 ConnectToSystemTrayClient()->ShowAccessibilitySettings();
104 }
105
106 void SystemTrayDelegateMus::ShowPaletteHelp() {
107 ConnectToSystemTrayClient()->ShowPaletteHelp();
108 }
109
110 void SystemTrayDelegateMus::ShowPaletteSettings() {
111 ConnectToSystemTrayClient()->ShowPaletteSettings();
112 }
113
114 void SystemTrayDelegateMus::ShowPublicAccountInfo() {
115 ConnectToSystemTrayClient()->ShowPublicAccountInfo();
116 }
117
118 void SystemTrayDelegateMus::ShowEnterpriseInfo() {
119 // http://crbug.com/647412
120 NOTIMPLEMENTED();
121 }
122
123 void SystemTrayDelegateMus::ShowProxySettings() {
124 ConnectToSystemTrayClient()->ShowProxySettings();
125 }
126
127 ////////////////////////////////////////////////////////////////////////////////
128 // mojom::SystemTray:
129
130 void SystemTrayDelegateMus::SetUse24HourClock(bool use_24_hour) {
131 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock;
132 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged();
133 }
134
135 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698