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

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: Refactoring of SystemTrayDelegate(Windows|Linux) is delayed. 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 | « ash/system/tray_update.h ('k') | ash/system/user/update_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.factory_reset_required
81 ? bundle.GetLocalizedString(
82 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE)
83 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 153
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) {
160 Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this); 164 Shell::GetInstance()->system_tray_notifier()->AddUpdateObserver(this);
161 } 165 }
162 166
163 TrayUpdate::~TrayUpdate() { 167 TrayUpdate::~TrayUpdate() {
164 Shell::GetInstance()->system_tray_notifier()->RemoveUpdateObserver(this); 168 Shell::GetInstance()->system_tray_notifier()->RemoveUpdateObserver(this);
165 } 169 }
166 170
167 bool TrayUpdate::GetInitialVisibility() { 171 bool TrayUpdate::GetInitialVisibility() {
168 return Shell::GetInstance()->system_tray_delegate()->SystemShouldUpgrade(); 172 UpdateInfo info;
173 Shell::GetInstance()->system_tray_delegate()->GetSystemUpdateInfo(&info);
174 return info.update_required;
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;
173 return NULL; 179 Shell::GetInstance()->system_tray_delegate()->GetSystemUpdateInfo(&info);
174 return new UpdateView(severity_); 180 return info.update_required ? new UpdateView(info) : nullptr;
175 } 181 }
176 182
177 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) { 183 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) {
178 return CreateDefaultView(status); 184 return CreateDefaultView(status);
179 } 185 }
180 186
181 void TrayUpdate::DestroyDetailedView() { 187 void TrayUpdate::DestroyDetailedView() {
182 if (nagger_) { 188 if (nagger_) {
183 // The nagger was being displayed. Now that the detailed view is being 189 // 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 190 // 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 191 // didn't click on it to restart. In either case, start the timer to show
186 // the nag reminder again after the specified time. 192 // the nag reminder again after the specified time.
187 nagger_->RestartTimer(); 193 nagger_->RestartTimer();
188 } 194 }
189 } 195 }
190 196
191 void TrayUpdate::OnUpdateRecommended(UpdateObserver::UpdateSeverity severity) { 197 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) {
192 severity_ = severity; 198 SetImageFromResourceId(DecideResource(info.severity, false));
193 SetImageFromResourceId(DecideResource(severity_, false));
194 tray_view()->SetVisible(true); 199 tray_view()->SetVisible(true);
195 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() && 200 if (!Shell::GetPrimaryRootWindowController()->shelf()->IsVisible() &&
196 !nagger_.get()) { 201 !nagger_.get()) {
197 // The shelf is not visible, and there is no nagger scheduled. 202 // The shelf is not visible, and there is no nagger scheduled.
198 nagger_.reset(new tray::UpdateNagger(this)); 203 nagger_.reset(new tray::UpdateNagger(this));
199 } 204 }
200 } 205 }
201 206
202 } // namespace ash 207 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray_update.h ('k') | ash/system/user/update_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698