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

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

Issue 614363002: Added Aura notification that relaunch and powerwash is required in case of downgrade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes to StstemTrayDelegateWin. 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_win.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" 15 #include "base/logging.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/chrome_notification_types.h" 17 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/lifetime/application_lifetime.h" 18 #include "chrome/browser/lifetime/application_lifetime.h"
19 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/ui/chrome_pages.h" 20 #include "chrome/browser/ui/chrome_pages.h"
21 #include "chrome/browser/ui/host_desktop.h" 21 #include "chrome/browser/ui/host_desktop.h"
22 #include "chrome/browser/upgrade_detector.h" 22 #include "chrome/browser/upgrade_detector.h"
23 #include "chrome/grit/locale_settings.h" 23 #include "chrome/grit/locale_settings.h"
24 #include "content/public/browser/notification_observer.h" 24 #include "content/public/browser/notification_observer.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 27
28 namespace { 28 namespace {
29 29
30 void GetUpdateInfo(const UpgradeDetector* detector, ash::UpdateInfo* info) {
31 if (!detector || !info)
32 return;
33 ash::UpdateInfo::UpdateSeverity severity =
34 ash::UpdateInfo::UPDATE_NORMAL;
35 switch (detector->upgrade_notification_stage()) {
36 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL:
37 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE:
38 severity = ash::UpdateInfo::UPDATE_SEVERE_RED;
39 break;
40 case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH:
41 severity = ash::UpdateInfo::UPDATE_HIGH_ORANGE;
42 break;
43 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED:
44 severity = ash::UpdateInfo::UPDATE_LOW_GREEN;
45 break;
46 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW:
47 case UpgradeDetector::UPGRADE_ANNOYANCE_NONE:
48 severity = ash::UpdateInfo::UPDATE_NORMAL;
49 break;
50 }
51 info->severity = severity;
52 info->is_factory_reset_required = detector->is_factory_reset_required();
53 }
54
30 class SystemTrayDelegateWin : public ash::SystemTrayDelegate, 55 class SystemTrayDelegateWin : public ash::SystemTrayDelegate,
31 public content::NotificationObserver { 56 public content::NotificationObserver {
32 public: 57 public:
33 SystemTrayDelegateWin() 58 SystemTrayDelegateWin()
34 : clock_type_(base::GetHourClockType()) { 59 : clock_type_(base::GetHourClockType()) {
35 // Register notifications on construction so that events such as 60 // Register notifications on construction so that events such as
36 // PROFILE_CREATED do not get missed if they happen before Initialize(). 61 // PROFILE_CREATED do not get missed if they happen before Initialize().
37 registrar_.reset(new content::NotificationRegistrar); 62 registrar_.reset(new content::NotificationRegistrar);
38 registrar_->Add(this, 63 registrar_->Add(this,
39 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 64 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 105 }
81 106
82 virtual const base::string16 GetSupervisedUserMessage() const OVERRIDE { 107 virtual const base::string16 GetSupervisedUserMessage() const OVERRIDE {
83 return base::string16(); 108 return base::string16();
84 } 109 }
85 110
86 virtual bool IsUserSupervised() const OVERRIDE { 111 virtual bool IsUserSupervised() const OVERRIDE {
87 return false; 112 return false;
88 } 113 }
89 114
90 virtual bool SystemShouldUpgrade() const OVERRIDE { 115 virtual bool SystemShouldUpgrade(ash::UpdateInfo* info) const OVERRIDE {
91 return UpgradeDetector::GetInstance()->notify_upgrade(); 116 UpgradeDetector* detector = UpgradeDetector::GetInstance();
117 GetUpdateInfo(detector, info);
118 return detector->notify_upgrade();
92 } 119 }
93 120
94 virtual base::HourClockType GetHourClockType() const OVERRIDE { 121 virtual base::HourClockType GetHourClockType() const OVERRIDE {
95 return clock_type_; 122 return clock_type_;
96 } 123 }
97 124
98 virtual void ShowSettings() OVERRIDE { 125 virtual void ShowSettings() OVERRIDE {
99 } 126 }
100 127
101 virtual bool ShouldShowSettings() OVERRIDE { 128 virtual bool ShouldShowSettings() OVERRIDE {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 clock_type_ = (base::GetHourClockType() == base::k24HourClock) ? 319 clock_type_ = (base::GetHourClockType() == base::k24HourClock) ?
293 base::k24HourClock : base::k12HourClock; 320 base::k24HourClock : base::k12HourClock;
294 GetSystemTrayNotifier()->NotifyDateFormatChanged(); 321 GetSystemTrayNotifier()->NotifyDateFormatChanged();
295 } 322 }
296 323
297 // content::NotificationObserver implementation. 324 // content::NotificationObserver implementation.
298 virtual void Observe(int type, 325 virtual void Observe(int type,
299 const content::NotificationSource& source, 326 const content::NotificationSource& source,
300 const content::NotificationDetails& details) OVERRIDE { 327 const content::NotificationDetails& details) OVERRIDE {
301 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) { 328 if (type == chrome::NOTIFICATION_UPGRADE_RECOMMENDED) {
302 UpgradeDetector* detector = 329 ash::UpdateInfo info;
303 content::Source<UpgradeDetector>(source).ptr(); 330 GetUpdateInfo(content::Source<UpgradeDetector>(source).ptr(), &info);
304 ash::UpdateObserver::UpdateSeverity severity = 331 GetSystemTrayNotifier()->NotifyUpdateRecommended(info);
305 ash::UpdateObserver::UPDATE_NORMAL;
306 switch (detector->upgrade_notification_stage()) {
307 case UpgradeDetector::UPGRADE_ANNOYANCE_CRITICAL:
308 case UpgradeDetector::UPGRADE_ANNOYANCE_SEVERE:
309 severity = ash::UpdateObserver::UPDATE_SEVERE_RED;
310 break;
311 case UpgradeDetector::UPGRADE_ANNOYANCE_HIGH:
312 severity = ash::UpdateObserver::UPDATE_HIGH_ORANGE;
313 break;
314 case UpgradeDetector::UPGRADE_ANNOYANCE_ELEVATED:
315 severity = ash::UpdateObserver::UPDATE_LOW_GREEN;
316 break;
317 case UpgradeDetector::UPGRADE_ANNOYANCE_LOW:
318 case UpgradeDetector::UPGRADE_ANNOYANCE_NONE:
319 severity = ash::UpdateObserver::UPDATE_NORMAL;
320 break;
321 }
322 GetSystemTrayNotifier()->NotifyUpdateRecommended(severity);
323 } else { 332 } else {
324 NOTREACHED(); 333 NOTREACHED();
325 } 334 }
326 } 335 }
327 336
328 scoped_ptr<content::NotificationRegistrar> registrar_; 337 scoped_ptr<content::NotificationRegistrar> registrar_;
329 base::HourClockType clock_type_; 338 base::HourClockType clock_type_;
330 339
331 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateWin); 340 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegateWin);
332 }; 341 };
333 342
334 } // namespace 343 } // namespace
335 344
336 345
337 ash::SystemTrayDelegate* CreateWindowsSystemTrayDelegate() { 346 ash::SystemTrayDelegate* CreateWindowsSystemTrayDelegate() {
338 return new SystemTrayDelegateWin(); 347 return new SystemTrayDelegateWin();
339 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698