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

Side by Side Diff: ash/system/tray_update.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 "ash/system/tray_update.h" 5 #include "ash/system/tray_update.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shelf/shelf_widget.h" 9 #include "ash/shelf/shelf_widget.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 19 matching lines...) Expand all
30 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
31 31
32 namespace { 32 namespace {
33 33
34 // How many seconds should we wait before showing the nag reminder? 34 // How many seconds should we wait before showing the nag reminder?
35 const int kUpdateNaggingTimeSeconds = 24 * 60 * 60; 35 const int kUpdateNaggingTimeSeconds = 24 * 60 * 60;
36 36
37 // How long should the nag reminder be displayed? 37 // How long should the nag reminder be displayed?
38 const int kShowUpdateNaggerForSeconds = 15; 38 const int kShowUpdateNaggerForSeconds = 15;
39 39
40 int DecideResource(ash::UpdateObserver::UpdateSeverity severity, bool dark) { 40 int DecideResource(ash::UpdateInfo::UpdateSeverity severity, bool dark) {
41 switch (severity) { 41 switch (severity) {
42 case ash::UpdateObserver::UPDATE_NORMAL: 42 case ash::UpdateInfo::UPDATE_NORMAL:
43 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK: 43 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK:
44 IDR_AURA_UBER_TRAY_UPDATE; 44 IDR_AURA_UBER_TRAY_UPDATE;
45 45
46 case ash::UpdateObserver::UPDATE_LOW_GREEN: 46 case ash::UpdateInfo::UPDATE_LOW_GREEN:
47 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_GREEN : 47 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_GREEN :
48 IDR_AURA_UBER_TRAY_UPDATE_GREEN; 48 IDR_AURA_UBER_TRAY_UPDATE_GREEN;
49 49
50 case ash::UpdateObserver::UPDATE_HIGH_ORANGE: 50 case ash::UpdateInfo::UPDATE_HIGH_ORANGE:
51 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_ORANGE : 51 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_ORANGE :
52 IDR_AURA_UBER_TRAY_UPDATE_ORANGE; 52 IDR_AURA_UBER_TRAY_UPDATE_ORANGE;
53 53
54 case ash::UpdateObserver::UPDATE_SEVERE_RED: 54 case ash::UpdateInfo::UPDATE_SEVERE_RED:
55 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_RED : 55 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_RED :
56 IDR_AURA_UBER_TRAY_UPDATE_RED; 56 IDR_AURA_UBER_TRAY_UPDATE_RED;
57 } 57 }
58 58
59 NOTREACHED() << "Unknown update severity level."; 59 NOTREACHED() << "Unknown update severity level.";
60 return 0; 60 return 0;
61 } 61 }
62 62
63 class UpdateView : public ash::ActionableView { 63 class UpdateView : public ash::ActionableView {
64 public: 64 public:
65 explicit UpdateView(ash::UpdateObserver::UpdateSeverity severity) { 65 explicit UpdateView(const ash::UpdateInfo& info) {
66 SetLayoutManager(new 66 SetLayoutManager(new
67 views::BoxLayout(views::BoxLayout::kHorizontal, 67 views::BoxLayout(views::BoxLayout::kHorizontal,
68 ash::kTrayPopupPaddingHorizontal, 0, 68 ash::kTrayPopupPaddingHorizontal, 0,
69 ash::kTrayPopupPaddingBetweenItems)); 69 ash::kTrayPopupPaddingBetweenItems));
70 70
71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
72 views::ImageView* image = 72 views::ImageView* image =
73 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight); 73 new ash::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
74 image->SetImage(bundle.GetImageNamed(DecideResource(severity, true)). 74 image->SetImage(bundle.GetImageNamed(DecideResource(info.severity, true)).
75 ToImageSkia()); 75 ToImageSkia());
76 76
77 AddChildView(image); 77 AddChildView(image);
78 AddChildView(new views::Label( 78
79 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE))); 79 base::string16 label =
80 SetAccessibleName(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE)); 80 info.is_factory_reset_required
81 ? bundle.GetLocalizedString(
82 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE)
83 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_RESTART_TO_UPDATE);
84 AddChildView(new views::Label(label));
85 SetAccessibleName(label);
81 } 86 }
82 87
83 virtual ~UpdateView() {} 88 virtual ~UpdateView() {}
84 89
85 private: 90 private:
86 // Overridden from ActionableView. 91 // Overridden from ActionableView.
87 virtual bool PerformAction(const ui::Event& event) OVERRIDE { 92 virtual bool PerformAction(const ui::Event& event) OVERRIDE {
88 ash::Shell::GetInstance()-> 93 ash::Shell::GetInstance()->
89 system_tray_delegate()->RequestRestartForUpdate(); 94 system_tray_delegate()->RequestRestartForUpdate();
90 return true; 95 return true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 SystemTrayItem* owner_; 154 SystemTrayItem* owner_;
150 base::OneShotTimer<UpdateNagger> timer_; 155 base::OneShotTimer<UpdateNagger> timer_;
151 156
152 DISALLOW_COPY_AND_ASSIGN(UpdateNagger); 157 DISALLOW_COPY_AND_ASSIGN(UpdateNagger);
153 }; 158 };
154 159
155 } // namespace tray 160 } // namespace tray
156 161
157 TrayUpdate::TrayUpdate(SystemTray* system_tray) 162 TrayUpdate::TrayUpdate(SystemTray* system_tray)
158 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE), 163 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE),
159 severity_(UpdateObserver::UPDATE_NORMAL) { 164 severity_(UpdateInfo::UPDATE_NORMAL) {
160 Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this); 165 Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this);
161 } 166 }
162 167
163 TrayUpdate::~TrayUpdate() { 168 TrayUpdate::~TrayUpdate() {
164 Shell::GetInstance()->system_tray_notifier()->RemoveUpdateObserver(this); 169 Shell::GetInstance()->system_tray_notifier()->RemoveUpdateObserver(this);
165 } 170 }
166 171
167 bool TrayUpdate::GetInitialVisibility() { 172 bool TrayUpdate::GetInitialVisibility() {
168 return Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade(); 173 return Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade(
174 NULL);
169 } 175 }
170 176
171 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) { 177 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) {
172 if (!Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade()) 178 UpdateInfo info;
179 if (!Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade(
180 &info)) {
173 return NULL; 181 return NULL;
174 return new UpdateView(severity_); 182 }
183 return new UpdateView(info);
175 } 184 }
176 185
177 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) { 186 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) {
178 return CreateDefaultView(status); 187 return CreateDefaultView(status);
179 } 188 }
180 189
181 void TrayUpdate::DestroyDetailedView() { 190 void TrayUpdate::DestroyDetailedView() {
182 if (nagger_) { 191 if (nagger_) {
183 // The nagger was being displayed. Now that the detailed view is being 192 // The nagger was being displayed. Now that the detailed view is being
184 // closed, that means either the user clicks on it to restart, or the user 193 // closed, that means either the user clicks on it to restart, or the user
185 // didn't click on it to restart. In either case, start the timer to show 194 // didn't click on it to restart. In either case, start the timer to show
186 // the nag reminder again after the specified time. 195 // the nag reminder again after the specified time.
187 nagger_->RestartTimer(); 196 nagger_->RestartTimer();
188 } 197 }
189 } 198 }
190 199
191 void TrayUpdate::OnUpdateRecommended(UpdateObserver::UpdateSeverity severity) { 200 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) {
192 severity_ = severity; 201 severity_ = info.severity;
193 SetImageFromResourceId(DecideResource(severity_, false)); 202 SetImageFromResourceId(DecideResource(severity_, false));
194 tray_view()->SetVisible(true); 203 tray_view()->SetVisible(true);
195 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() && 204 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() &&
196 !nagger_.get()) { 205 !nagger_.get()) {
197 // The shelf is not visible, and there is no nagger scheduled. 206 // The shelf is not visible, and there is no nagger scheduled.
198 nagger_.reset(new tray::UpdateNagger(this)); 207 nagger_.reset(new tray::UpdateNagger(this));
199 } 208 }
200 } 209 }
201 210
202 } // namespace ash 211 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698