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

Unified Diff: ash/system/update/tray_update.cc

Issue 2816253002: Display "Restart to update Adobe Flash Player" for Flash updates. (Closed)
Patch Set: Fix nits from last review Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/update/tray_update.h ('k') | ash/system/update/tray_update_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/update/tray_update.cc
diff --git a/ash/system/update/tray_update.cc b/ash/system/update/tray_update.cc
index 55a82c5649a29a7510b5637802f1ce406392c228..a88ae9c671d86f174fbb3b2a2568b7e6361fe6a6 100644
--- a/ash/system/update/tray_update.cc
+++ b/ash/system/update/tray_update.cc
@@ -60,12 +60,14 @@ bool TrayUpdate::update_required_ = false;
mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE;
// static
bool TrayUpdate::factory_reset_required_ = false;
+mojom::UpdateType TrayUpdate::update_type_ = mojom::UpdateType::SYSTEM;
// The "restart to update" item in the system tray menu.
class TrayUpdate::UpdateView : public ActionableView {
public:
explicit UpdateView(TrayUpdate* owner)
- : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) {
+ : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS),
+ update_label_(nullptr) {
SetLayoutManager(new views::FillLayout);
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
@@ -77,23 +79,31 @@ class TrayUpdate::UpdateView : public ActionableView {
IconColorForUpdateSeverity(owner->severity_, true)));
tri_view->AddView(TriView::Container::START, image);
- base::string16 label_text =
- owner->factory_reset_required_
- ? bundle.GetLocalizedString(
- IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE)
- : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
+ base::string16 label_text;
+ if (owner->factory_reset_required_) {
+ label_text = bundle.GetLocalizedString(
+ IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE);
+ } else if (owner->update_type_ == mojom::UpdateType::FLASH) {
+ label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH);
+ } else {
+ label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
+ }
+
SetAccessibleName(label_text);
- auto* label = TrayPopupUtils::CreateDefaultLabel();
- label->SetText(label_text);
+ update_label_ = TrayPopupUtils::CreateDefaultLabel();
+ update_label_->SetText(label_text);
+
TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
- style.SetupLabel(label);
- tri_view->AddView(TriView::Container::CENTER, label);
+ style.SetupLabel(update_label_);
+ tri_view->AddView(TriView::Container::CENTER, update_label_);
SetInkDropMode(InkDropHostView::InkDropMode::ON);
}
~UpdateView() override {}
+ views::Label* update_label_;
+
private:
// Overridden from ActionableView.
bool PerformAction(const ui::Event& event) override {
@@ -119,19 +129,33 @@ bool TrayUpdate::GetInitialVisibility() {
}
views::View* TrayUpdate::CreateDefaultView(LoginStatus status) {
- return update_required_ ? new UpdateView(this) : nullptr;
+ if (update_required_) {
+ update_view_ = new UpdateView(this);
+ return update_view_;
+ }
+ return nullptr;
+}
+
+void TrayUpdate::DestroyDefaultView() {
+ update_view_ = nullptr;
}
void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity,
- bool factory_reset_required) {
+ bool factory_reset_required,
+ mojom::UpdateType update_type) {
// Cache update info so we can create the default view when the menu opens.
update_required_ = true;
severity_ = severity;
factory_reset_required_ = factory_reset_required;
+ update_type_ = update_type;
// Show the icon in the tray.
SetIconColor(IconColorForUpdateSeverity(severity_, false));
tray_view()->SetVisible(true);
}
+views::Label* TrayUpdate::GetLabelForTesting() {
+ return update_view_ ? update_view_->update_label_ : nullptr;
+}
+
} // namespace ash
« no previous file with comments | « ash/system/update/tray_update.h ('k') | ash/system/update/tray_update_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698