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

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

Issue 2816253002: Display "Restart to update Adobe Flash Player" for Flash updates. (Closed)
Patch Set: Add test for Flash player update 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 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/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 } // namespace 55 } // namespace
56 56
57 // static 57 // static
58 bool TrayUpdate::update_required_ = false; 58 bool TrayUpdate::update_required_ = false;
59 // static 59 // static
60 mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE; 60 mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE;
61 // static 61 // static
62 bool TrayUpdate::factory_reset_required_ = false; 62 bool TrayUpdate::factory_reset_required_ = false;
63 mojom::UpdateType TrayUpdate::update_type_ = mojom::UpdateType::SYSTEM;
64 views::Label* TrayUpdate::update_label_ = nullptr;
63 65
64 // The "restart to update" item in the system tray menu. 66 // The "restart to update" item in the system tray menu.
65 class TrayUpdate::UpdateView : public ActionableView { 67 class TrayUpdate::UpdateView : public ActionableView {
66 public: 68 public:
67 explicit UpdateView(TrayUpdate* owner) 69 explicit UpdateView(TrayUpdate* owner)
68 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) { 70 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) {
69 SetLayoutManager(new views::FillLayout); 71 SetLayoutManager(new views::FillLayout);
70 72
71 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 73 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
72 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 74 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
73 AddChildView(tri_view); 75 AddChildView(tri_view);
74 views::ImageView* image = TrayPopupUtils::CreateMainImageView(); 76 views::ImageView* image = TrayPopupUtils::CreateMainImageView();
75 image->SetImage(gfx::CreateVectorIcon( 77 image->SetImage(gfx::CreateVectorIcon(
76 kSystemMenuUpdateIcon, 78 kSystemMenuUpdateIcon,
77 IconColorForUpdateSeverity(owner->severity_, true))); 79 IconColorForUpdateSeverity(owner->severity_, true)));
78 tri_view->AddView(TriView::Container::START, image); 80 tri_view->AddView(TriView::Container::START, image);
79 81
80 base::string16 label_text = 82 base::string16 label_text;
81 owner->factory_reset_required_ 83 if (owner->factory_reset_required_) {
82 ? bundle.GetLocalizedString( 84 label_text = bundle.GetLocalizedString(
83 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE) 85 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE);
84 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); 86 } else if (owner->update_type_ == mojom::UpdateType::FLASH) {
87 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE_FLASH);
88 } else {
89 label_text = bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
90 }
91
85 SetAccessibleName(label_text); 92 SetAccessibleName(label_text);
86 auto* label = TrayPopupUtils::CreateDefaultLabel(); 93 views::Label* label = TrayPopupUtils::CreateDefaultLabel();
87 label->SetText(label_text); 94 label->SetText(label_text);
95 update_label_ = label;
James Cook 2017/04/18 23:20:57 update_label_ can point to deleted memory after th
Greg K 2017/04/18 23:45:23 Done.
96
88 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL); 97 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
89 style.SetupLabel(label); 98 style.SetupLabel(label);
90 tri_view->AddView(TriView::Container::CENTER, label); 99 tri_view->AddView(TriView::Container::CENTER, label);
91 100
92 SetInkDropMode(InkDropHostView::InkDropMode::ON); 101 SetInkDropMode(InkDropHostView::InkDropMode::ON);
93 } 102 }
94 103
95 ~UpdateView() override {} 104 ~UpdateView() override {}
96 105
97 private: 106 private:
(...skipping 18 matching lines...) Expand all
116 // If chrome tells ash there is an update available before this item's system 125 // If chrome tells ash there is an update available before this item's system
117 // tray is constructed then show the icon. 126 // tray is constructed then show the icon.
118 return update_required_; 127 return update_required_;
119 } 128 }
120 129
121 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) { 130 views::View* TrayUpdate::CreateDefaultView(LoginStatus status) {
122 return update_required_ ? new UpdateView(this) : nullptr; 131 return update_required_ ? new UpdateView(this) : nullptr;
123 } 132 }
124 133
125 void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity, 134 void TrayUpdate::ShowUpdateIcon(mojom::UpdateSeverity severity,
126 bool factory_reset_required) { 135 bool factory_reset_required,
136 mojom::UpdateType update_type) {
127 // Cache update info so we can create the default view when the menu opens. 137 // Cache update info so we can create the default view when the menu opens.
128 update_required_ = true; 138 update_required_ = true;
129 severity_ = severity; 139 severity_ = severity;
130 factory_reset_required_ = factory_reset_required; 140 factory_reset_required_ = factory_reset_required;
141 update_type_ = update_type;
131 142
132 // Show the icon in the tray. 143 // Show the icon in the tray.
133 SetIconColor(IconColorForUpdateSeverity(severity_, false)); 144 SetIconColor(IconColorForUpdateSeverity(severity_, false));
134 tray_view()->SetVisible(true); 145 tray_view()->SetVisible(true);
135 } 146 }
136 147
148 base::string16 TrayUpdate::GetLabelForTesting() {
149 return update_label_ ? update_label_->text() : base::string16();
James Cook 2017/04/18 23:20:57 Then this could become "return default_view_ ? def
Greg K 2017/04/18 23:45:23 Done.
150 }
151
137 } // namespace ash 152 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698