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

Side by Side Diff: ash/system/tray_update.cc

Issue 10915214: ash: Update system update notification behaviour. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 | Annotate | Revision Log
« 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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "ash/system/tray/tray_constants.h" 10 #include "ash/system/tray/tray_constants.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/views/widget/widget.h" 26 #include "ui/views/widget/widget.h"
27 27
28 namespace { 28 namespace {
29 29
30 // How many seconds should we wait before showing the nag reminder? 30 // How many seconds should we wait before showing the nag reminder?
31 const int kUpdateNaggingTimeSeconds = 24 * 60 * 60; 31 const int kUpdateNaggingTimeSeconds = 24 * 60 * 60;
32 32
33 // How long should the nag reminder be displayed? 33 // How long should the nag reminder be displayed?
34 const int kShowUpdateNaggerForSeconds = 15; 34 const int kShowUpdateNaggerForSeconds = 15;
35 35
36 int DecideResource(ash::UpdateObserver::UpdateSeverity severity, bool dark) {
37 switch (severity) {
38 case ash::UpdateObserver::UPDATE_NORMAL:
39 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK:
40 IDR_AURA_UBER_TRAY_UPDATE;
41
42 case ash::UpdateObserver::UPDATE_LOW_GREEN:
43 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_GREEN :
44 IDR_AURA_UBER_TRAY_UPDATE_GREEN;
45
46 case ash::UpdateObserver::UPDATE_HIGH_ORANGE:
47 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_ORANGE :
48 IDR_AURA_UBER_TRAY_UPDATE_ORANGE;
49
50 case ash::UpdateObserver::UPDATE_SEVERE_RED:
51 return dark ? IDR_AURA_UBER_TRAY_UPDATE_DARK_RED :
52 IDR_AURA_UBER_TRAY_UPDATE_RED;
53 }
54
55 NOTREACHED() << "Unknown update severity level.";
56 return 0;
57 }
58
36 class UpdateView : public ash::internal::ActionableView { 59 class UpdateView : public ash::internal::ActionableView {
37 public: 60 public:
38 UpdateView() { 61 explicit UpdateView(ash::UpdateObserver::UpdateSeverity severity) {
39 SetLayoutManager(new 62 SetLayoutManager(new
40 views::BoxLayout(views::BoxLayout::kHorizontal, 63 views::BoxLayout(views::BoxLayout::kHorizontal,
41 ash::kTrayPopupPaddingHorizontal, 0, 64 ash::kTrayPopupPaddingHorizontal, 0,
42 ash::kTrayPopupPaddingBetweenItems)); 65 ash::kTrayPopupPaddingBetweenItems));
43 66
44 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 67 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
45 views::ImageView* image = 68 views::ImageView* image =
46 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); 69 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight);
47 image->SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_UPDATE_DARK). 70 image->SetImage(bundle.GetImageNamed(DecideResource(severity, true)).
48 ToImageSkia()); 71 ToImageSkia());
49 72
50 AddChildView(image); 73 AddChildView(image);
51 AddChildView(new views::Label( 74 AddChildView(new views::Label(
52 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE))); 75 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE)));
53 SetAccessibleName(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE)); 76 SetAccessibleName(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE));
54 } 77 }
55 78
56 virtual ~UpdateView() {} 79 virtual ~UpdateView() {}
57 80
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 139
117 SystemTrayItem* owner_; 140 SystemTrayItem* owner_;
118 base::OneShotTimer<UpdateNagger> timer_; 141 base::OneShotTimer<UpdateNagger> timer_;
119 142
120 DISALLOW_COPY_AND_ASSIGN(UpdateNagger); 143 DISALLOW_COPY_AND_ASSIGN(UpdateNagger);
121 }; 144 };
122 145
123 } // namespace tray 146 } // namespace tray
124 147
125 TrayUpdate::TrayUpdate() 148 TrayUpdate::TrayUpdate()
126 : TrayImageItem(IDR_AURA_UBER_TRAY_UPDATE) { 149 : TrayImageItem(IDR_AURA_UBER_TRAY_UPDATE),
150 severity_(UpdateObserver::UPDATE_NORMAL) {
127 } 151 }
128 152
129 TrayUpdate::~TrayUpdate() {} 153 TrayUpdate::~TrayUpdate() {}
130 154
131 bool TrayUpdate::GetInitialVisibility() { 155 bool TrayUpdate::GetInitialVisibility() {
132 return Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade(); 156 return Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade();
133 } 157 }
134 158
135 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) { 159 views::View* TrayUpdate::CreateDefaultView(user::LoginStatus status) {
136 if (!Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade()) 160 if (!Shell::GetInstance()->tray_delegate()->SystemShouldUpgrade())
137 return NULL; 161 return NULL;
138 return new UpdateView; 162 return new UpdateView(severity_);
139 } 163 }
140 164
141 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) { 165 views::View* TrayUpdate::CreateDetailedView(user::LoginStatus status) {
142 return CreateDefaultView(status); 166 return CreateDefaultView(status);
143 } 167 }
144 168
145 void TrayUpdate::DestroyDetailedView() { 169 void TrayUpdate::DestroyDetailedView() {
146 if (nagger_.get()) { 170 if (nagger_.get()) {
147 // The nagger was being displayed. Now that the detailed view is being 171 // The nagger was being displayed. Now that the detailed view is being
148 // closed, that means either the user clicks on it to restart, or the user 172 // closed, that means either the user clicks on it to restart, or the user
149 // didn't click on it to restart. In either case, start the timer to show 173 // didn't click on it to restart. In either case, start the timer to show
150 // the nag reminder again after the specified time. 174 // the nag reminder again after the specified time.
151 nagger_->RestartTimer(); 175 nagger_->RestartTimer();
152 } 176 }
153 } 177 }
154 178
155 void TrayUpdate::OnUpdateRecommended() { 179 void TrayUpdate::OnUpdateRecommended(UpdateObserver::UpdateSeverity severity) {
180 severity_ = severity;
181 SetImageFromResourceId(DecideResource(severity_, false));
156 tray_view()->SetVisible(true); 182 tray_view()->SetVisible(true);
157 if (!Shell::GetInstance()->shelf()->IsVisible() && !nagger_.get()) { 183 if (!Shell::GetInstance()->shelf()->IsVisible() && !nagger_.get()) {
158 // The shelf is not visible, and there is no nagger scheduled. 184 // The shelf is not visible, and there is no nagger scheduled.
159 nagger_.reset(new tray::UpdateNagger(this)); 185 nagger_.reset(new tray::UpdateNagger(this));
160 } 186 }
161 } 187 }
162 188
163 } // namespace internal 189 } // namespace internal
164 } // namespace ash 190 } // 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