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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_win.cc

Issue 636853002: Common code from linux and windows implementations of SystemTrayDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 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 | « chrome/browser/ui/ash/system_tray_delegate_win.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "chrome/browser/ui/ash/system_tray_delegate_win.h"
6
7 #include <string>
8
9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h"
11 #include "ash/system/tray/system_tray.h"
12 #include "ash/system/tray/system_tray_delegate.h"
13 #include "ash/system/tray/system_tray_notifier.h"
14 #include "ash/volume_control_delegate.h"
15 #include "base/logging.h"
16 #include "base/time/time.h"
17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/lifetime/application_lifetime.h"
19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/ash/system_tray_delegate_utils.h"
21 #include "chrome/browser/ui/chrome_pages.h"
22 #include "chrome/browser/ui/host_desktop.h"
23 #include "chrome/browser/upgrade_detector.h"
24 #include "chrome/grit/locale_settings.h"
25 #include "content/public/browser/notification_observer.h"
26 #include "content/public/browser/notification_service.h"
27 #include "ui/base/l10n/l10n_util.h"
28
29 namespace {
30
31 class SystemTrayDelegateWin : public ash::SystemTrayDelegate,
32 public content::NotificationObserver {
33 public:
34 SystemTrayDelegateWin()
35 : clock_type_(base::GetHourClockType()) {
36 // Register notifications on construction so that events such as
37 // PROFILE_CREATED do not get missed if they happen before Initialize().
38 registrar_.reset(new content::NotificationRegistrar);
39 registrar_->Add(this,
40 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
41 content::NotificationService::AllSources());
42 }
43
44 virtual ~SystemTrayDelegateWin() {
45 registrar_.reset();
46 }
47
48 // Overridden from ash::SystemTrayDelegate:
49 virtual void Initialize() override {
50 UpdateClockType();
51 }
52
53 virtual void Shutdown() override {
54 }
55
56 virtual bool GetTrayVisibilityOnStartup() override {
57 return true;
58 }
59
60 virtual ash::user::LoginStatus GetUserLoginStatus() const override {
61 return ash::user::LOGGED_IN_OWNER;
62 }
63
64 virtual void ChangeProfilePicture() override {
65 }
66
67 virtual const std::string GetEnterpriseDomain() const override {
68 return std::string();
69 }
70
71 virtual const base::string16 GetEnterpriseMessage() const override {
72 return base::string16();
73 }
74
75 virtual const std::string GetSupervisedUserManager() const override {
76 return std::string();
77 }
78
79 virtual const base::string16 GetSupervisedUserManagerName() const override {
80 return base::string16();
81 }
82
83 virtual const base::string16 GetSupervisedUserMessage() const override {
84 return base::string16();
85 }
86
87 virtual bool IsUserSupervised() const override {
88 return false;
89 }
90
91 virtual void GetSystemUpdateInfo(ash::UpdateInfo* info) const override {
92 GetUpdateInfo(UpgradeDetector::GetInstance(), info);
93 }
94
95 virtual base::HourClockType GetHourClockType() const override {
96 return clock_type_;
97 }
98
99 virtual void ShowSettings() override {
100 }
101
102 virtual bool ShouldShowSettings() override {
103 return true;
104 }
105
106 virtual void ShowDateSettings() override {
107 }
108
109 virtual void ShowSetTimeDialog() override {
110 }
111
112 virtual void ShowNetworkSettings(const std::string& service_path) override {
113 }
114
115 virtual void ShowBluetoothSettings() override {
116 }
117
118 virtual void ShowDisplaySettings() override {
119 }
120
121 virtual void ShowChromeSlow() override {
122 }
123
124 virtual bool ShouldShowDisplayNotification() override {
125 return false;
126 }
127
128 virtual void ShowIMESettings() override {
129 }
130
131 virtual void ShowHelp() override {
132 chrome::ShowHelpForProfile(
133 ProfileManager::GetLastUsedProfile(),
134 chrome::HOST_DESKTOP_TYPE_ASH,
135 chrome::HELP_SOURCE_MENU);
136 }
137
138 virtual void ShowAccessibilityHelp() override {
139 }
140
141 virtual void ShowAccessibilitySettings() override {
142 }
143
144 virtual void ShowPublicAccountInfo() override {
145 }
146
147 virtual void ShowSupervisedUserInfo() override {
148 }
149
150 virtual void ShowEnterpriseInfo() override {
151 }
152
153 virtual void ShowUserLogin() override {
154 }
155
156 virtual bool ShowSpringChargerReplacementDialog() override {
157 return false;
158 }
159
160 virtual bool IsSpringChargerReplacementDialogVisible() override {
161 return false;
162 }
163
164 virtual bool HasUserConfirmedSafeSpringCharger() override {
165 return false;
166 }
167
168 virtual void ShutDown() override {
169 }
170
171 virtual void SignOut() override {
172 }
173
174 virtual void RequestLockScreen() override {
175 }
176
177 virtual void RequestRestartForUpdate() override {
178 chrome::AttemptRestart();
179 }
180
181 virtual void GetAvailableBluetoothDevices(
182 ash::BluetoothDeviceList* list) override {
183 }
184
185 virtual void BluetoothStartDiscovering() override {
186 }
187
188 virtual void BluetoothStopDiscovering() override {
189 }
190
191 virtual void ConnectToBluetoothDevice(const std::string& address) override {
192 }
193
194 virtual bool IsBluetoothDiscovering() override {
195 return false;
196 }
197
198 virtual void GetCurrentIME(ash::IMEInfo* info) override {
199 }
200
201 virtual void GetAvailableIMEList(ash::IMEInfoList* list) override {
202 }
203
204 virtual void GetCurrentIMEProperties(
205 ash::IMEPropertyInfoList* list) override {
206 }
207
208 virtual void SwitchIME(const std::string& ime_id) override {
209 }
210
211 virtual void ActivateIMEProperty(const std::string& key) override {
212 }
213
214 virtual void ShowNetworkConfigure(const std::string& network_id) override {
215 }
216
217 virtual bool EnrollNetwork(const std::string& network_id) override {
218 return true;
219 }
220
221 virtual void ManageBluetoothDevices() override {
222 }
223
224 virtual void ToggleBluetooth() override {
225 }
226
227 virtual void ShowMobileSimDialog() override {
228 }
229
230 virtual void ShowMobileSetupDialog(const std::string& service_path) override {
231 }
232
233 virtual void ShowOtherNetworkDialog(const std::string& type) override {
234 }
235
236 virtual bool GetBluetoothAvailable() override {
237 return false;
238 }
239
240 virtual bool GetBluetoothEnabled() override {
241 return false;
242 }
243
244 virtual bool GetBluetoothDiscovering() override {
245 return false;
246 }
247
248 virtual void ChangeProxySettings() override {
249 }
250
251 virtual ash::VolumeControlDelegate*
252 GetVolumeControlDelegate() const override {
253 return NULL;
254 }
255
256 virtual void SetVolumeControlDelegate(
257 scoped_ptr<ash::VolumeControlDelegate> delegate) override {
258 }
259
260 virtual bool GetSessionStartTime(
261 base::TimeTicks* session_start_time) override {
262 return false;
263 }
264
265 virtual bool GetSessionLengthLimit(
266 base::TimeDelta* session_length_limit) override {
267 return false;
268 }
269
270 virtual int GetSystemTrayMenuWidth() override {
271 return l10n_util::GetLocalizedContentsWidthInPixels(
272 IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS);
273 }
274
275 virtual void ActiveUserWasChanged() override {
276 }
277
278 virtual bool IsSearchKeyMappedToCapsLock() override {
279 return false;
280 }
281
282 virtual ash::tray::UserAccountsDelegate* GetUserAccountsDelegate(
283 const std::string& user_id) override {
284 return NULL;
285 }
286
287 virtual void AddCustodianInfoTrayObserver(
288 ash::CustodianInfoTrayObserver* observer) override {
289 }
290
291 virtual void RemoveCustodianInfoTrayObserver(
292 ash::CustodianInfoTrayObserver* observer) override {
293 }
294
295 private:
296 ash::SystemTrayNotifier* GetSystemTrayNotifier() {
297 return ash::Shell::GetInstance()->system_tray_notifier();
298 }
299
300 void UpdateClockType() {
301 clock_type_ = (base::GetHourClockType() == base::k24HourClock) ?
302 base::k24HourClock : base::k12HourClock;
303 GetSystemTrayNotifier()->NotifyDateFormatChanged();
304 }
305
306 // content::NotificationObserver implementation.
307 virtual void Observe(int type,
308 const content::NotificationSource& source,
309 const content::NotificationDetails& details) override {
310 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) {
311 ash::UpdateInfo info;
312 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info);
313 GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
314 } else {
315 NOTREACHED();
316 }
317 }
318
319 scoped_ptr<content::NotificationRegistrar> registrar_;
320 base::HourClockType clock_type_;
321
322 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateWin);
323 };
324
325 } // namespace
326
327
328 ash::SystemTrayDelegate* CreateWindowsSystemTrayDelegate() {
329 return new SystemTrayDelegateWin();
330 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_win.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698