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

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

Issue 2661023006: Remove unused references to NativeTheme in TrayPopupItemStyle. (Closed)
Patch Set: slight improvement Created 3 years, 10 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/common/system/tray/tray_popup_item_style.cc ('k') | no next file » | 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/common/system/update/tray_update.h" 5 #include "ash/common/system/update/tray_update.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/metrics/user_metrics_action.h" 8 #include "ash/common/metrics/user_metrics_action.h"
9 #include "ash/common/system/tray/fixed_sized_image_view.h" 9 #include "ash/common/system/tray/fixed_sized_image_view.h"
10 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 bool TrayUpdate::update_required_ = false; 87 bool TrayUpdate::update_required_ = false;
88 // static 88 // static
89 mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE; 89 mojom::UpdateSeverity TrayUpdate::severity_ = mojom::UpdateSeverity::NONE;
90 // static 90 // static
91 bool TrayUpdate::factory_reset_required_ = false; 91 bool TrayUpdate::factory_reset_required_ = false;
92 92
93 // The "restart to update" item in the system tray menu. 93 // The "restart to update" item in the system tray menu.
94 class TrayUpdate::UpdateView : public ActionableView { 94 class TrayUpdate::UpdateView : public ActionableView {
95 public: 95 public:
96 explicit UpdateView(TrayUpdate* owner) 96 explicit UpdateView(TrayUpdate* owner)
97 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS), 97 : ActionableView(owner, TrayPopupInkDropStyle::FILL_BOUNDS) {
98 label_(nullptr) {
99 SetLayoutManager(new views::FillLayout); 98 SetLayoutManager(new views::FillLayout);
100 99
101 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 100 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
102 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView(); 101 TriView* tri_view = TrayPopupUtils::CreateDefaultRowView();
103 AddChildView(tri_view); 102 AddChildView(tri_view);
104 views::ImageView* image = TrayPopupUtils::CreateMainImageView(); 103 views::ImageView* image = TrayPopupUtils::CreateMainImageView();
105 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 104 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
106 image->SetImage(gfx::CreateVectorIcon( 105 image->SetImage(gfx::CreateVectorIcon(
107 kSystemMenuUpdateIcon, 106 kSystemMenuUpdateIcon,
108 IconColorForUpdateSeverity(owner->severity_, true))); 107 IconColorForUpdateSeverity(owner->severity_, true)));
109 } else { 108 } else {
110 image->SetImage( 109 image->SetImage(
111 bundle.GetImageNamed(DecideResource(owner->severity_, true)) 110 bundle.GetImageNamed(DecideResource(owner->severity_, true))
112 .ToImageSkia()); 111 .ToImageSkia());
113 } 112 }
114 tri_view->AddView(TriView::Container::START, image); 113 tri_view->AddView(TriView::Container::START, image);
115 114
116 base::string16 label_text = 115 base::string16 label_text =
117 owner->factory_reset_required_ 116 owner->factory_reset_required_
118 ? bundle.GetLocalizedString( 117 ? bundle.GetLocalizedString(
119 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE) 118 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE)
120 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); 119 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
121 label_ = TrayPopupUtils::CreateDefaultLabel();
122 label_->SetText(label_text);
123 SetAccessibleName(label_text); 120 SetAccessibleName(label_text);
124 tri_view->AddView(TriView::Container::CENTER, label_); 121 auto label = TrayPopupUtils::CreateDefaultLabel();
122 label->SetText(label_text);
123 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
124 style.SetupLabel(label);
125 tri_view->AddView(TriView::Container::CENTER, label);
125 126
126 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 127 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
127 UpdateStyle();
128 SetInkDropMode(InkDropHostView::InkDropMode::ON); 128 SetInkDropMode(InkDropHostView::InkDropMode::ON);
129 } 129 }
130 } 130 }
131 131
132 ~UpdateView() override {} 132 ~UpdateView() override {}
133 133
134 private: 134 private:
135 void UpdateStyle() {
136 TrayPopupItemStyle style(GetNativeTheme(),
137 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
138 style.SetupLabel(label_);
139 }
140
141 // Overridden from ActionableView. 135 // Overridden from ActionableView.
142 bool PerformAction(const ui::Event& event) override { 136 bool PerformAction(const ui::Event& event) override {
143 WmShell::Get()->system_tray_controller()->RequestRestartForUpdate(); 137 WmShell::Get()->system_tray_controller()->RequestRestartForUpdate();
144 WmShell::Get()->RecordUserMetricsAction( 138 WmShell::Get()->RecordUserMetricsAction(
145 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); 139 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED);
146 CloseSystemBubble(); 140 CloseSystemBubble();
147 return true; 141 return true;
148 } 142 }
149 143
150 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
151 ActionableView::OnNativeThemeChanged(theme);
152
153 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
154 return;
155 UpdateStyle();
156 }
157
158 views::Label* label_;
159
160 DISALLOW_COPY_AND_ASSIGN(UpdateView); 144 DISALLOW_COPY_AND_ASSIGN(UpdateView);
161 }; 145 };
162 146
163 TrayUpdate::TrayUpdate(SystemTray* system_tray) 147 TrayUpdate::TrayUpdate(SystemTray* system_tray)
164 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) {} 148 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) {}
165 149
166 TrayUpdate::~TrayUpdate() {} 150 TrayUpdate::~TrayUpdate() {}
167 151
168 bool TrayUpdate::GetInitialVisibility() { 152 bool TrayUpdate::GetInitialVisibility() {
169 // If chrome tells ash there is an update available before this item's system 153 // If chrome tells ash there is an update available before this item's system
(...skipping 14 matching lines...) Expand all
184 168
185 // Show the icon in the tray. 169 // Show the icon in the tray.
186 if (MaterialDesignController::UseMaterialDesignSystemIcons()) 170 if (MaterialDesignController::UseMaterialDesignSystemIcons())
187 SetIconColor(IconColorForUpdateSeverity(severity_, false)); 171 SetIconColor(IconColorForUpdateSeverity(severity_, false));
188 else 172 else
189 SetImageFromResourceId(DecideResource(severity_, false)); 173 SetImageFromResourceId(DecideResource(severity_, false));
190 tray_view()->SetVisible(true); 174 tray_view()->SetVisible(true);
191 } 175 }
192 176
193 } // namespace ash 177 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_popup_item_style.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698