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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu_button.cc

Issue 1966643002: Integrate new MD update menu icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates based on feedback. Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/app_menu_button.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu_button.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/themes/theme_properties.h" 12 #include "chrome/browser/themes/theme_properties.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_otr_state.h"
14 #include "chrome/browser/ui/layout_constants.h" 15 #include "chrome/browser/ui/layout_constants.h"
15 #include "chrome/browser/ui/toolbar/app_menu_model.h" 16 #include "chrome/browser/ui/toolbar/app_menu_model.h"
16 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 17 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
17 #include "chrome/browser/ui/views/toolbar/app_menu.h" 18 #include "chrome/browser/ui/views/toolbar/app_menu.h"
18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
19 #include "extensions/common/feature_switch.h" 20 #include "extensions/common/feature_switch.h"
20 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
21 #include "ui/base/material_design/material_design_controller.h" 22 #include "ui/base/material_design/material_design_controller.h"
22 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/theme_provider.h" 24 #include "ui/base/theme_provider.h"
(...skipping 19 matching lines...) Expand all
43 margin_trailing_(0), 44 margin_trailing_(0),
44 weak_factory_(this) { 45 weak_factory_(this) {
45 set_ink_drop_delegate( 46 set_ink_drop_delegate(
46 base::WrapUnique(new views::ButtonInkDropDelegate(this, this))); 47 base::WrapUnique(new views::ButtonInkDropDelegate(this, this)));
47 if (!ui::MaterialDesignController::IsModeMaterial()) 48 if (!ui::MaterialDesignController::IsModeMaterial())
48 icon_painter_.reset(new AppMenuIconPainter(this)); 49 icon_painter_.reset(new AppMenuIconPainter(this));
49 } 50 }
50 51
51 AppMenuButton::~AppMenuButton() {} 52 AppMenuButton::~AppMenuButton() {}
52 53
53 void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity, 54 void AppMenuButton::SetSeverity(AppMenuBadgeController::BadgeType type,
55 AppMenuIconPainter::Severity severity,
54 bool animate) { 56 bool animate) {
55 if (ui::MaterialDesignController::IsModeMaterial()) { 57 if (ui::MaterialDesignController::IsModeMaterial()) {
56 severity_ = severity; 58 severity_ = severity;
59 type_ = type;
57 UpdateIcon(); 60 UpdateIcon();
58 return; 61 return;
59 } 62 }
60 63
61 icon_painter_->SetSeverity(severity, animate); 64 icon_painter_->SetSeverity(severity, animate);
62 SchedulePaint(); 65 SchedulePaint();
63 } 66 }
64 67
65 void AppMenuButton::ShowMenu(bool for_drop) { 68 void AppMenuButton::ShowMenu(bool for_drop) {
66 if (menu_ && menu_->IsShowing()) 69 if (menu_ && menu_->IsShowing())
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 129
127 return ResourceBundle::GetSharedInstance(). 130 return ResourceBundle::GetSharedInstance().
128 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); 131 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
129 } 132 }
130 133
131 void AppMenuButton::ScheduleAppMenuIconPaint() { 134 void AppMenuButton::ScheduleAppMenuIconPaint() {
132 SchedulePaint(); 135 SchedulePaint();
133 } 136 }
134 137
135 void AppMenuButton::UpdateIcon() { 138 void AppMenuButton::UpdateIcon() {
139 using BadgeType = AppMenuBadgeController::BadgeType;
136 DCHECK(ui::MaterialDesignController::IsModeMaterial()); 140 DCHECK(ui::MaterialDesignController::IsModeMaterial());
141 gfx::VectorIconId icon_id = gfx::VectorIconId::BROWSER_TOOLS;
137 SkColor color = gfx::kPlaceholderColor; 142 SkColor color = gfx::kPlaceholderColor;
138 switch (severity_) { 143 switch (severity_) {
139 case AppMenuIconPainter::SEVERITY_NONE: 144 case AppMenuIconPainter::SEVERITY_NONE:
140 color = GetThemeProvider()->GetColor( 145 color = GetThemeProvider()->GetColor(
141 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); 146 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
142 break; 147 break;
143 case AppMenuIconPainter::SEVERITY_LOW: 148 case AppMenuIconPainter::SEVERITY_LOW:
144 color = gfx::kGoogleGreen700; 149 color = gfx::kGoogleGreen700;
145 break; 150 break;
146 case AppMenuIconPainter::SEVERITY_MEDIUM: 151 case AppMenuIconPainter::SEVERITY_MEDIUM:
147 color = gfx::kGoogleYellow700; 152 color = gfx::kGoogleYellow700;
148 break; 153 break;
149 case AppMenuIconPainter::SEVERITY_HIGH: 154 case AppMenuIconPainter::SEVERITY_HIGH:
150 color = gfx::kGoogleRed700; 155 color = gfx::kGoogleRed700;
151 break; 156 break;
152 } 157 }
153 158
159 if (severity_ != AppMenuIconPainter::SEVERITY_NONE) {
Evan Stade 2016/06/03 19:31:26 why this check? Wouldn't type_ be NONE in this cas
kylix_rd 2016/06/03 19:50:43 The code was assuming that if the severity_ is NON
160 if (type_ == BadgeType::GLOBAL_ERROR)
161 icon_id = gfx::VectorIconId::UPDATE_MENU_FAILED;
162 else if (type_ == BadgeType::INCOMPATIBILITY_WARNING)
163 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_WARNING;
164 else
165 icon_id = gfx::VectorIconId::UPDATE_MENU_SEVERITY_LOW_MEDIUM_HIGH;
166 }
167
154 SetImage(views::Button::STATE_NORMAL, 168 SetImage(views::Button::STATE_NORMAL,
155 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color)); 169 gfx::CreateVectorIcon(icon_id, 16, color));
156 } 170 }
157 171
158 void AppMenuButton::SetTrailingMargin(int margin) { 172 void AppMenuButton::SetTrailingMargin(int margin) {
159 margin_trailing_ = margin; 173 margin_trailing_ = margin;
160 174
161 UpdateThemedBorder(); 175 UpdateThemedBorder();
162 176
163 if (!ui::MaterialDesignController::IsModeMaterial()) { 177 if (!ui::MaterialDesignController::IsModeMaterial()) {
164 const int inset = LabelButton::kFocusRectInset; 178 const int inset = LabelButton::kFocusRectInset;
165 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( 179 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 views::MenuButton::OnPaint(canvas); 261 views::MenuButton::OnPaint(canvas);
248 if (ui::MaterialDesignController::IsModeMaterial()) 262 if (ui::MaterialDesignController::IsModeMaterial())
249 return; 263 return;
250 // Use GetPreferredSize() to center the icon inside the visible bounds rather 264 // Use GetPreferredSize() to center the icon inside the visible bounds rather
251 // than the whole size() (which may refer to hit test region extended to the 265 // than the whole size() (which may refer to hit test region extended to the
252 // end of the toolbar in maximized mode). 266 // end of the toolbar in maximized mode).
253 icon_painter_->Paint(canvas, GetThemeProvider(), 267 icon_painter_->Paint(canvas, GetThemeProvider(),
254 gfx::Rect(GetPreferredSize()), 268 gfx::Rect(GetPreferredSize()),
255 AppMenuIconPainter::BEZEL_NONE); 269 AppMenuIconPainter::BEZEL_NONE);
256 } 270 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu_button.h ('k') | chrome/browser/ui/views/toolbar/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698