OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/ui/ash/system_tray_delegate_win.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_linux.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
11 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
12 #include "ash/system/tray/system_tray_delegate.h" | 12 #include "ash/system/tray/system_tray_delegate.h" |
13 #include "ash/system/tray/system_tray_notifier.h" | 13 #include "ash/system/tray/system_tray_notifier.h" |
14 #include "ash/volume_control_delegate.h" | 14 #include "ash/volume_control_delegate.h" |
15 #include "base/logging.h" | |
16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/lifetime/application_lifetime.h" | 17 #include "chrome/browser/lifetime/application_lifetime.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/chrome_pages.h" | 19 #include "chrome/browser/ui/chrome_pages.h" |
21 #include "chrome/browser/ui/host_desktop.h" | 20 #include "chrome/browser/ui/host_desktop.h" |
| 21 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
22 #include "chrome/browser/upgrade_detector.h" | 22 #include "chrome/browser/upgrade_detector.h" |
23 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 | |
26 #include "grit/locale_settings.h" | 25 #include "grit/locale_settings.h" |
27 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
28 | 27 |
29 namespace { | 28 namespace { |
30 | 29 |
31 class SystemTrayDelegateWin : public ash::SystemTrayDelegate, | 30 class SystemTrayDelegateLinux : public ash::SystemTrayDelegate, |
32 public content::NotificationObserver { | 31 public content::NotificationObserver { |
33 public: | 32 public: |
34 SystemTrayDelegateWin() | 33 SystemTrayDelegateLinux() |
35 : clock_type_(base::GetHourClockType()) { | 34 : clock_type_(base::GetHourClockType()) { |
36 // Register notifications on construction so that events such as | 35 // Register notifications on construction so that events such as |
37 // PROFILE_CREATED do not get missed if they happen before Initialize(). | 36 // PROFILE_CREATED do not get missed if they happen before Initialize(). |
38 registrar_.reset(new content::NotificationRegistrar); | 37 registrar_.reset(new content::NotificationRegistrar); |
39 registrar_->Add(this, | 38 registrar_->Add(this, |
40 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 39 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
41 content::NotificationService::AllSources()); | 40 content::NotificationService::AllSources()); |
42 } | 41 } |
43 | 42 |
44 virtual ~SystemTrayDelegateWin() { | 43 virtual ~SystemTrayDelegateLinux() { |
45 registrar_.reset(); | 44 registrar_.reset(); |
46 } | 45 } |
47 | 46 |
48 // Overridden from ash::SystemTrayDelegate: | 47 // Overridden from ash::SystemTrayDelegate: |
49 virtual void Initialize() OVERRIDE { | 48 virtual void Initialize() OVERRIDE { |
50 UpdateClockType(); | 49 UpdateClockType(); |
51 } | 50 } |
52 | 51 |
53 virtual void Shutdown() OVERRIDE { | 52 virtual void Shutdown() OVERRIDE { |
54 } | 53 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE { | 108 virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE { |
110 } | 109 } |
111 | 110 |
112 virtual void ShowBluetoothSettings() OVERRIDE { | 111 virtual void ShowBluetoothSettings() OVERRIDE { |
113 } | 112 } |
114 | 113 |
115 virtual void ShowDisplaySettings() OVERRIDE { | 114 virtual void ShowDisplaySettings() OVERRIDE { |
116 } | 115 } |
117 | 116 |
118 virtual void ShowChromeSlow() OVERRIDE { | 117 virtual void ShowChromeSlow() OVERRIDE { |
| 118 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 119 ProfileManager::GetPrimaryUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH); |
| 120 chrome::ShowSlow(displayer.browser()); |
119 } | 121 } |
120 | 122 |
121 virtual bool ShouldShowDisplayNotification() OVERRIDE { | 123 virtual bool ShouldShowDisplayNotification() OVERRIDE { |
122 return false; | 124 return false; |
123 } | 125 } |
124 | 126 |
125 virtual void ShowDriveSettings() OVERRIDE { | 127 virtual void ShowDriveSettings() OVERRIDE { |
126 } | 128 } |
127 | 129 |
128 virtual void ShowIMESettings() OVERRIDE { | 130 virtual void ShowIMESettings() OVERRIDE { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // content::NotificationObserver implementation. | 314 // content::NotificationObserver implementation. |
313 virtual void Observe(int type, | 315 virtual void Observe(int type, |
314 const content::NotificationSource& source, | 316 const content::NotificationSource& source, |
315 const content::NotificationDetails& details) OVERRIDE { | 317 const content::NotificationDetails& details) OVERRIDE { |
316 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) { | 318 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) { |
317 UpgradeDetector* detector = | 319 UpgradeDetector* detector = |
318 content::Source<UpgradeDetector>(source).ptr(); | 320 content::Source<UpgradeDetector>(source).ptr(); |
319 ash::UpdateObserver::UpdateSeverity severity = | 321 ash::UpdateObserver::UpdateSeverity severity = |
320 ash::UpdateObserver::UPDATE_NORMAL; | 322 ash::UpdateObserver::UPDATE_NORMAL; |
321 switch (detector->upgrade_notification_stage()) { | 323 switch (detector->upgrade_notification_stage()) { |
| 324 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL: |
322 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: | 325 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE: |
323 severity = ash::UpdateObserver::UPDATE_SEVERE_RED; | 326 severity = ash::UpdateObserver::UPDATE_SEVERE_RED; |
324 break; | 327 break; |
325 case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH: | 328 case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH: |
326 severity = ash::UpdateObserver::UPDATE_HIGH_ORANGE; | 329 severity = ash::UpdateObserver::UPDATE_HIGH_ORANGE; |
327 break; | 330 break; |
328 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED: | 331 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED: |
329 severity = ash::UpdateObserver::UPDATE_LOW_GREEN; | 332 severity = ash::UpdateObserver::UPDATE_LOW_GREEN; |
330 break; | 333 break; |
331 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW: | 334 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW: |
| 335 case UpgradeDetector::UPGRADE_ANNOYANCE_NONE: |
332 severity = ash::UpdateObserver::UPDATE_NORMAL; | 336 severity = ash::UpdateObserver::UPDATE_NORMAL; |
333 break; | 337 break; |
334 } | 338 } |
335 GetSystemTrayNotifier()->NotifyUpdateRecommended(severity); | 339 GetSystemTrayNotifier()->NotifyUpdateRecommended(severity); |
336 } else { | 340 } else { |
337 NOTREACHED(); | 341 NOTREACHED(); |
338 } | 342 } |
339 } | 343 } |
340 | 344 |
341 scoped_ptr<content::NotificationRegistrar> registrar_; | 345 scoped_ptr<content::NotificationRegistrar> registrar_; |
342 base::HourClockType clock_type_; | 346 base::HourClockType clock_type_; |
343 | 347 |
344 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateWin); | 348 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateLinux); |
345 }; | 349 }; |
346 | 350 |
347 } // namespace | 351 } // namespace |
348 | 352 |
349 | 353 |
350 ash::SystemTrayDelegate* CreateWindowsSystemTrayDelegate() { | 354 ash::SystemTrayDelegate* CreateLinuxSystemTrayDelegate() { |
351 return new SystemTrayDelegateWin(); | 355 return new SystemTrayDelegateLinux(); |
352 } | 356 } |
OLD | NEW |