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

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

Issue 2365523002: Materialized the font/icon color for some default rows in the system menu. (Closed)
Patch Set: Addressed tdanderson@ comments from previous patch set. Created 4 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
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"
11 #include "ash/common/system/tray/system_tray_delegate.h" 11 #include "ash/common/system/tray/system_tray_delegate.h"
12 #include "ash/common/system/tray/system_tray_notifier.h" 12 #include "ash/common/system/tray/system_tray_notifier.h"
13 #include "ash/common/system/tray/tray_constants.h" 13 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_popup_item_style.h"
14 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
15 #include "ash/resources/vector_icons/vector_icons.h" 16 #include "ash/resources/vector_icons/vector_icons.h"
16 #include "grit/ash_resources.h" 17 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 18 #include "grit/ash_strings.h"
18 #include "ui/base/resource/resource_bundle.h" 19 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/color_palette.h" 20 #include "ui/gfx/color_palette.h"
20 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
21 #include "ui/gfx/paint_vector_icon.h" 22 #include "ui/gfx/paint_vector_icon.h"
22 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
23 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return for_menu ? gfx::kGoogleRed700 : gfx::kGoogleRed300; 74 return for_menu ? gfx::kGoogleRed700 : gfx::kGoogleRed300;
74 default: 75 default:
75 NOTREACHED(); 76 NOTREACHED();
76 break; 77 break;
77 } 78 }
78 return default_color; 79 return default_color;
79 } 80 }
80 81
81 class UpdateView : public ActionableView { 82 class UpdateView : public ActionableView {
82 public: 83 public:
83 explicit UpdateView(const UpdateInfo& info) { 84 explicit UpdateView(const UpdateInfo& info) : label_(nullptr) {
84 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, 85 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
85 kTrayPopupPaddingHorizontal, 0, 86 kTrayPopupPaddingHorizontal, 0,
86 kTrayPopupPaddingBetweenItems)); 87 kTrayPopupPaddingBetweenItems));
87 88
88 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 89 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
89 views::ImageView* image = 90 views::ImageView* image =
90 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)); 91 new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT));
91 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { 92 if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
92 image->SetImage(gfx::CreateVectorIcon( 93 image->SetImage(gfx::CreateVectorIcon(
93 kSystemMenuUpdateIcon, 94 kSystemMenuUpdateIcon,
94 IconColorForUpdateSeverity(info.severity, true))); 95 IconColorForUpdateSeverity(info.severity, true)));
95 } else { 96 } else {
96 image->SetImage(bundle.GetImageNamed(DecideResource(info.severity, true)) 97 image->SetImage(bundle.GetImageNamed(DecideResource(info.severity, true))
97 .ToImageSkia()); 98 .ToImageSkia());
98 } 99 }
99 AddChildView(image); 100 AddChildView(image);
100 101
101 base::string16 label = 102 base::string16 label_text =
102 info.factory_reset_required 103 info.factory_reset_required
103 ? bundle.GetLocalizedString( 104 ? bundle.GetLocalizedString(
104 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE) 105 IDS_ASH_STATUS_TRAY_RESTART_AND_POWERWASH_TO_UPDATE)
105 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE); 106 : bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_UPDATE);
106 AddChildView(new views::Label(label)); 107 label_ = new views::Label(label_text);
107 SetAccessibleName(label); 108 AddChildView(label_);
109 SetAccessibleName(label_text);
108 } 110 }
109 111
110 ~UpdateView() override {} 112 ~UpdateView() override {}
111 113
112 private: 114 private:
113 // Overridden from ActionableView. 115 // Overridden from ActionableView.
114 bool PerformAction(const ui::Event& event) override { 116 bool PerformAction(const ui::Event& event) override {
115 WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate(); 117 WmShell::Get()->system_tray_delegate()->RequestRestartForUpdate();
116 WmShell::Get()->RecordUserMetricsAction( 118 WmShell::Get()->RecordUserMetricsAction(
117 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED); 119 UMA_STATUS_AREA_OS_UPDATE_DEFAULT_SELECTED);
118 return true; 120 return true;
119 } 121 }
120 122
123 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
124 ActionableView::OnNativeThemeChanged(theme);
125
126 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
127 return;
128
129 TrayPopupItemStyle style(GetNativeTheme(),
130 TrayPopupItemStyle::FontStyle::DEFAULT_VIEW_LABEL);
131 style.SetupLabel(label_);
132 }
133
134 views::Label* label_;
135
121 DISALLOW_COPY_AND_ASSIGN(UpdateView); 136 DISALLOW_COPY_AND_ASSIGN(UpdateView);
122 }; 137 };
123 138
124 } // namespace 139 } // namespace
125 140
126 TrayUpdate::TrayUpdate(SystemTray* system_tray) 141 TrayUpdate::TrayUpdate(SystemTray* system_tray)
127 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) { 142 : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_UPDATE, UMA_UPDATE) {
128 WmShell::Get()->system_tray_notifier()->AddUpdateObserver(this); 143 WmShell::Get()->system_tray_notifier()->AddUpdateObserver(this);
129 } 144 }
130 145
(...skipping 15 matching lines...) Expand all
146 161
147 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) { 162 void TrayUpdate::OnUpdateRecommended(const UpdateInfo& info) {
148 if (MaterialDesignController::UseMaterialDesignSystemIcons()) 163 if (MaterialDesignController::UseMaterialDesignSystemIcons())
149 SetIconColor(IconColorForUpdateSeverity(info.severity, false)); 164 SetIconColor(IconColorForUpdateSeverity(info.severity, false));
150 else 165 else
151 SetImageFromResourceId(DecideResource(info.severity, false)); 166 SetImageFromResourceId(DecideResource(info.severity, false));
152 tray_view()->SetVisible(true); 167 tray_view()->SetVisible(true);
153 } 168 }
154 169
155 } // namespace ash 170 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray_accessibility.cc ('k') | ash/system/chromeos/rotation/tray_rotation_lock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698