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

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

Issue 2915383002: Fix crash of update-over-cellular icon (Closed)
Patch Set: Disable the icon in locked and login screen instead of OOBE Created 3 years, 6 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 | « no previous file | chrome/browser/chromeos/upgrade_detector_chromeos.cc » ('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/update/tray_update.h" 5 #include "ash/system/update/tray_update.h"
6 6
7 #include "ash/metrics/user_metrics_action.h" 7 #include "ash/metrics/user_metrics_action.h"
8 #include "ash/public/interfaces/update.mojom.h" 8 #include "ash/public/interfaces/update.mojom.h"
9 #include "ash/resources/vector_icons/vector_icons.h" 9 #include "ash/resources/vector_icons/vector_icons.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // static 60 // static
61 bool TrayUpdate::factory_reset_required_ = false; 61 bool TrayUpdate::factory_reset_required_ = false;
62 // static 62 // static
63 bool TrayUpdate::update_over_cellular_available_ = false; 63 bool TrayUpdate::update_over_cellular_available_ = false;
64 64
65 mojom::UpdateType TrayUpdate::update_type_ = mojom::UpdateType::SYSTEM; 65 mojom::UpdateType TrayUpdate::update_type_ = mojom::UpdateType::SYSTEM;
66 66
67 // The "restart to update" item in the system tray menu. 67 // The "restart to update" item in the system tray menu.
68 class TrayUpdate::UpdateView : public ActionableView { 68 class TrayUpdate::UpdateView : public ActionableView {
69 public: 69 public:
70 explicit UpdateView(TrayUpdate* owner) 70 explicit UpdateView(TrayUpdate* owner, LoginStatus status)
xiyuan 2017/06/05 16:12:52 nit: "explicit" can be removed since this is no lo
weidongg 2017/06/05 16:56:52 Removed the second parameter.
71 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS), 71 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS),
72 update_label_(nullptr) { 72 update_label_(nullptr) {
73 SetLayoutManager(new views::FillLayout); 73 SetLayoutManager(new views::FillLayout);
74 74
75 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 75 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
76 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 76 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
77 AddChildView(tri_view); 77 AddChildView(tri_view);
78 views::ImageView* image = TrayPopupUtils::CreateMainImageView(); 78 views::ImageView* image = TrayPopupUtils::CreateMainImageView();
79 image->SetImage(gfx::CreateVectorIcon( 79 image->SetImage(gfx::CreateVectorIcon(
80 kSystemMenuUpdateIcon, 80 kSystemMenuUpdateIcon,
81 IconColorForUpdateSeverity(owner->severity_, true))); 81 IconColorForUpdateSeverity(owner->severity_, true)));
82 tri_view->AddView(TriView::Container::START, image); 82 tri_view->AddView(TriView::Container::START, image);
83 83
84 base::string16 label_text; 84 base::string16 label_text;
85 update_label_ = TrayPopupUtils::CreateDefaultLabel();
85 if (owner->factory_reset_required_) { 86 if (owner->factory_reset_required_) {
86 label_text = bundle.GetLocalizedString( 87 label_text = bundle.GetLocalizedString(
87 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE); 88 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE);
88 } else if (owner->update_type_ == mojom::UpdateType::FLASH) { 89 } else if (owner->update_type_ == mojom::UpdateType::FLASH) {
89 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH); 90 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH);
90 } else if (!owner->update_required_ && 91 } else if (!owner->update_required_ &&
91 owner->update_over_cellular_available_) { 92 owner->update_over_cellular_available_) {
92 label_text = bundle.GetLocalizedString( 93 label_text = bundle.GetLocalizedString(
93 IDS_ASH_STATUS_TRAY_UPDATE_OVER_CELLULAR_AVAILABLE); 94 IDS_ASH_STATUS_TRAY_UPDATE_OVER_CELLULAR_AVAILABLE);
95 if (status == LoginStatus::LOCKED ||
96 status == LoginStatus::NOT_LOGGED_IN) {
xiyuan 2017/06/05 16:12:52 Should we call SessionController::ShouldEnableSett
weidongg 2017/06/05 16:56:52 Aha, yes, good to know this api. Thanks.
97 // Disables the view as clicking it opens settings page which is not
98 // available in locked and login screen.
99 tri_view->SetEnabled(false);
100 update_label_->SetEnabled(false);
xiyuan 2017/06/05 16:12:52 Does this only apply to cellular update available
weidongg 2017/06/05 16:56:52 The action of clicking in other update cases is re
101 }
94 } else { 102 } else {
95 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); 103 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
96 } 104 }
97 105
98 SetAccessibleName(label_text); 106 SetAccessibleName(label_text);
99 update_label_ = TrayPopupUtils::CreateDefaultLabel();
100 update_label_->SetText(label_text); 107 update_label_->SetText(label_text);
101 108
102 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 109 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
103 style.SetupLabel(update_label_); 110 style.SetupLabel(update_label_);
104 tri_view->AddView(TriView::Container::CENTER, update_label_); 111 tri_view->AddView(TriView::Container::CENTER, update_label_);
105 112
106 SetInkDropMode(InkDropHostView::InkDropMode::ON); 113 SetInkDropMode(InkDropHostView::InkDropMode::ON);
107 } 114 }
108 115
109 ~UpdateView() override {} 116 ~UpdateView() override {}
(...skipping 26 matching lines...) Expand all
136 TrayUpdate::~TrayUpdate() {} 143 TrayUpdate::~TrayUpdate() {}
137 144
138 bool TrayUpdate::GetInitialVisibility() { 145 bool TrayUpdate::GetInitialVisibility() {
139 // If chrome tells ash there is an update available before this item's system 146 // If chrome tells ash there is an update available before this item's system
140 // tray is constructed then show the icon. 147 // tray is constructed then show the icon.
141 return update_required_ || update_over_cellular_available_; 148 return update_required_ || update_over_cellular_available_;
142 } 149 }
143 150
144 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { 151 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) {
145 if (update_required_ || update_over_cellular_available_) { 152 if (update_required_ || update_over_cellular_available_) {
146 update_view_ = new UpdateView(this); 153 update_view_ = new UpdateView(this, status);
147 return update_view_; 154 return update_view_;
148 } 155 }
149 return nullptr; 156 return nullptr;
150 } 157 }
151 158
152 void TrayUpdate::DestroyDefaultView() { 159 void TrayUpdate::DestroyDefaultView() {
153 update_view_ = nullptr; 160 update_view_ = nullptr;
154 } 161 }
155 162
156 void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity, 163 void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity,
(...skipping 18 matching lines...) Expand all
175 update_over_cellular_available_ = true; 182 update_over_cellular_available_ = true;
176 183
177 // TODO(weidongg/691108): adjust severity according the amount of time passing 184 // TODO(weidongg/691108): adjust severity according the amount of time passing
178 // after update is available over cellular connection. 185 // after update is available over cellular connection.
179 // Use low severity for update available over cellular connection. 186 // Use low severity for update available over cellular connection.
180 SetIconColor(IconColorForUpdateSeverity(mojom::UpdateSeverity::LOW, false)); 187 SetIconColor(IconColorForUpdateSeverity(mojom::UpdateSeverity::LOW, false));
181 tray_view()->SetVisible(true); 188 tray_view()->SetVisible(true);
182 } 189 }
183 190
184 } // namespace ash 191 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/upgrade_detector_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698