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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_linux.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
OLDNEW
(Empty)
1 // Copyright 2014 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_linux.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/time/time.h"
16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/lifetime/application_lifetime.h"
18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/ash/system_tray_delegate_utils.h"
20 #include "chrome/browser/ui/chrome_pages.h"
21 #include "chrome/browser/ui/host_desktop.h"
22 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.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 SystemTrayDelegateLinux : public ash::SystemTrayDelegate,
32 public content::NotificationObserver {
33 public:
34 SystemTrayDelegateLinux()
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 ~SystemTrayDelegateLinux() {
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 chrome::ScopedTabbedBrowserDisplayer displayer(
123 ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
124 chrome::ShowSlow(displayer.browser());
125 }
126
127 virtual bool ShouldShowDisplayNotification() override {
128 return false;
129 }
130
131 virtual void ShowIMESettings() override {
132 }
133
134 virtual void ShowHelp() override {
135 chrome::ShowHelpForProfile(
136 ProfileManager::GetLastUsedProfile(),
137 chrome::HOST_DESKTOP_TYPE_ASH,
138 chrome::HELP_SOURCE_MENU);
139 }
140
141 virtual void ShowAccessibilityHelp() override {
142 }
143
144 virtual void ShowAccessibilitySettings() override {
145 }
146
147 virtual void ShowPublicAccountInfo() override {
148 }
149
150 virtual void ShowSupervisedUserInfo() override {
151 }
152
153 virtual void ShowEnterpriseInfo() override {
154 }
155
156 virtual void ShowUserLogin() override {
157 }
158
159 virtual bool ShowSpringChargerReplacementDialog() override {
160 return false;
161 }
162
163 virtual bool IsSpringChargerReplacementDialogVisible() override {
164 return false;
165 }
166
167 virtual bool HasUserConfirmedSafeSpringCharger() override {
168 return false;
169 }
170
171 virtual void ShutDown() override {
172 }
173
174 virtual void SignOut() override {
175 }
176
177 virtual void RequestLockScreen() override {
178 }
179
180 virtual void RequestRestartForUpdate() override {
181 chrome::AttemptRestart();
182 }
183
184 virtual void GetAvailableBluetoothDevices(
185 ash::BluetoothDeviceList* list) override {
186 }
187
188 virtual void BluetoothStartDiscovering() override {
189 }
190
191 virtual void BluetoothStopDiscovering() override {
192 }
193
194 virtual void ConnectToBluetoothDevice(const std::string& address) override {
195 }
196
197 virtual bool IsBluetoothDiscovering() override {
198 return false;
199 }
200
201 virtual void GetCurrentIME(ash::IMEInfo* info) override {
202 }
203
204 virtual void GetAvailableIMEList(ash::IMEInfoList* list) override {
205 }
206
207 virtual void GetCurrentIMEProperties(
208 ash::IMEPropertyInfoList* list) override {
209 }
210
211 virtual void SwitchIME(const std::string& ime_id) override {
212 }
213
214 virtual void ActivateIMEProperty(const std::string& key) override {
215 }
216
217 virtual void ShowNetworkConfigure(const std::string& network_id) override {
218 }
219
220 virtual bool EnrollNetwork(const std::string& network_id) override {
221 return true;
222 }
223
224 virtual void ManageBluetoothDevices() override {
225 }
226
227 virtual void ToggleBluetooth() override {
228 }
229
230 virtual void ShowMobileSimDialog() override {
231 }
232
233 virtual void ShowMobileSetupDialog(const std::string& service_path) override {
234 }
235
236 virtual void ShowOtherNetworkDialog(const std::string& type) override {
237 }
238
239 virtual bool GetBluetoothAvailable() override {
240 return false;
241 }
242
243 virtual bool GetBluetoothEnabled() override {
244 return false;
245 }
246
247 virtual bool GetBluetoothDiscovering() override {
248 return false;
249 }
250
251 virtual void ChangeProxySettings() override {
252 }
253
254 virtual ash::VolumeControlDelegate*
255 GetVolumeControlDelegate() const override {
256 return NULL;
257 }
258
259 virtual void SetVolumeControlDelegate(
260 scoped_ptr<ash::VolumeControlDelegate> delegate) override {
261 }
262
263 virtual bool GetSessionStartTime(
264 base::TimeTicks* session_start_time) override {
265 return false;
266 }
267
268 virtual bool GetSessionLengthLimit(
269 base::TimeDelta* session_length_limit) override {
270 return false;
271 }
272
273 virtual int GetSystemTrayMenuWidth() override {
274 return l10n_util::GetLocalizedContentsWidthInPixels(
275 IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS);
276 }
277
278 virtual void ActiveUserWasChanged() override {
279 }
280
281 virtual bool IsSearchKeyMappedToCapsLock() override {
282 return false;
283 }
284
285 virtual ash::tray::UserAccountsDelegate* GetUserAccountsDelegate(
286 const std::string& user_id) override {
287 return NULL;
288 }
289
290 virtual void AddCustodianInfoTrayObserver(
291 ash::CustodianInfoTrayObserver* observer) override {
292 }
293
294 virtual void RemoveCustodianInfoTrayObserver(
295 ash::CustodianInfoTrayObserver* observer) override {
296 }
297
298 private:
299 ash::SystemTrayNotifier* GetSystemTrayNotifier() {
300 return ash::Shell::GetInstance()->system_tray_notifier();
301 }
302
303 void UpdateClockType() {
304 clock_type_ = (base::GetHourClockType() == base::k24HourClock) ?
305 base::k24HourClock : base::k12HourClock;
306 GetSystemTrayNotifier()->NotifyDateFormatChanged();
307 }
308
309 // content::NotificationObserver implementation.
310 virtual void Observe(int type,
311 const content::NotificationSource& source,
312 const content::NotificationDetails& details) override {
313 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) {
314 ash::UpdateInfo info;
315 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info);
316 GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
317 } else {
318 NOTREACHED();
319 }
320 }
321
322 scoped_ptr<content::NotificationRegistrar> registrar_;
323 base::HourClockType clock_type_;
324
325 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateLinux);
326 };
327
328 } // namespace
329
330
331 ash::SystemTrayDelegate* CreateLinuxSystemTrayDelegate() {
332 return new SystemTrayDelegateLinux();
333 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_linux.h ('k') | chrome/browser/ui/ash/system_tray_delegate_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698