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

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

Issue 1393163002: Update app menu button MD colors for the notification case. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: replace amber with yellow700 Created 5 years, 2 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 | « chrome/browser/ui/views/toolbar/wrench_toolbar_button.h ('k') | ui/gfx/color_palette.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wrench_toolbar_button.h" 5 #include "chrome/browser/ui/views/toolbar/wrench_toolbar_button.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "chrome/browser/themes/theme_properties.h"
11 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 13 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
13 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 14 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
14 #include "chrome/browser/ui/views/layout_constants.h" 15 #include "chrome/browser/ui/views/layout_constants.h"
15 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 16 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
16 #include "chrome/browser/ui/views/toolbar/wrench_menu.h" 17 #include "chrome/browser/ui/views/toolbar/wrench_menu.h"
17 #include "extensions/common/feature_switch.h" 18 #include "extensions/common/feature_switch.h"
18 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
19 #include "ui/base/resource/material_design/material_design_controller.h" 20 #include "ui/base/resource/material_design/material_design_controller.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/base/theme_provider.h" 22 #include "ui/base/theme_provider.h"
23 #include "ui/gfx/color_palette.h"
24 #include "ui/gfx/paint_vector_icon.h"
25 #include "ui/gfx/vector_icons_public.h"
22 #include "ui/keyboard/keyboard_controller.h" 26 #include "ui/keyboard/keyboard_controller.h"
23 #include "ui/views/controls/button/label_button_border.h" 27 #include "ui/views/controls/button/label_button_border.h"
24 #include "ui/views/controls/menu/menu_listener.h" 28 #include "ui/views/controls/menu/menu_listener.h"
25 #include "ui/views/metrics.h" 29 #include "ui/views/metrics.h"
26 #include "ui/views/painter.h" 30 #include "ui/views/painter.h"
27 31
28 // static 32 // static
29 bool WrenchToolbarButton::g_open_app_immediately_for_testing = false; 33 bool WrenchToolbarButton::g_open_app_immediately_for_testing = false;
30 34
31 WrenchToolbarButton::WrenchToolbarButton(ToolbarView* toolbar_view) 35 WrenchToolbarButton::WrenchToolbarButton(ToolbarView* toolbar_view)
32 : views::MenuButton(NULL, base::string16(), toolbar_view, false), 36 : views::MenuButton(NULL, base::string16(), toolbar_view, false),
33 wrench_icon_painter_(nullptr), 37 severity_(WrenchIconPainter::SEVERITY_NONE),
34 toolbar_view_(toolbar_view), 38 toolbar_view_(toolbar_view),
35 allow_extension_dragging_( 39 allow_extension_dragging_(
36 extensions::FeatureSwitch::extension_action_redesign() 40 extensions::FeatureSwitch::extension_action_redesign()
37 ->IsEnabled()), 41 ->IsEnabled()),
38 weak_factory_(this) { 42 weak_factory_(this) {
39 if (!ui::MaterialDesignController::IsModeMaterial()) 43 if (!ui::MaterialDesignController::IsModeMaterial())
40 wrench_icon_painter_.reset(new WrenchIconPainter(this)); 44 wrench_icon_painter_.reset(new WrenchIconPainter(this));
41 } 45 }
42 46
43 WrenchToolbarButton::~WrenchToolbarButton() { 47 WrenchToolbarButton::~WrenchToolbarButton() {
44 } 48 }
45 49
46 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity, 50 void WrenchToolbarButton::SetSeverity(WrenchIconPainter::Severity severity,
47 bool animate) { 51 bool animate) {
48 if (ui::MaterialDesignController::IsModeMaterial()) 52 if (ui::MaterialDesignController::IsModeMaterial()) {
53 severity_ = severity;
54 UpdateIcon();
49 return; 55 return;
56 }
50 57
51 wrench_icon_painter_->SetSeverity(severity, animate); 58 wrench_icon_painter_->SetSeverity(severity, animate);
52 SchedulePaint(); 59 SchedulePaint();
53 } 60 }
54 61
55 void WrenchToolbarButton::ShowMenu(bool for_drop) { 62 void WrenchToolbarButton::ShowMenu(bool for_drop) {
56 if (menu_ && menu_->IsShowing()) 63 if (menu_ && menu_->IsShowing())
57 return; 64 return;
58 65
59 #if defined(USE_AURA) 66 #if defined(USE_AURA)
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 113 }
107 114
108 return ResourceBundle::GetSharedInstance(). 115 return ResourceBundle::GetSharedInstance().
109 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size(); 116 GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
110 } 117 }
111 118
112 void WrenchToolbarButton::ScheduleWrenchIconPaint() { 119 void WrenchToolbarButton::ScheduleWrenchIconPaint() {
113 SchedulePaint(); 120 SchedulePaint();
114 } 121 }
115 122
123 void WrenchToolbarButton::UpdateIcon() {
124 DCHECK(ui::MaterialDesignController::IsModeMaterial());
125 SkColor color = SK_ColorRED;
126 switch (severity_) {
127 case WrenchIconPainter::SEVERITY_NONE:
128 color = GetThemeProvider()->GetColor(
129 ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
130 break;
131 case WrenchIconPainter::SEVERITY_LOW:
132 color = gfx::kGoogleGreen700;
133 break;
134 case WrenchIconPainter::SEVERITY_MEDIUM:
135 color = gfx::kGoogleYellow700;
136 break;
137 case WrenchIconPainter::SEVERITY_HIGH:
138 color = gfx::kGoogleRed700;
139 break;
140 }
141
142 // TODO(estade): find a home for this constant.
143 const int kButtonSize = 16;
144 SetImage(views::Button::STATE_NORMAL,
145 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, kButtonSize,
146 color));
147 }
148
116 const char* WrenchToolbarButton::GetClassName() const { 149 const char* WrenchToolbarButton::GetClassName() const {
117 return "WrenchToolbarButton"; 150 return "WrenchToolbarButton";
118 } 151 }
119 152
120 bool WrenchToolbarButton::GetDropFormats( 153 bool WrenchToolbarButton::GetDropFormats(
121 int* formats, 154 int* formats,
122 std::set<ui::Clipboard::FormatType>* format_types) { 155 std::set<ui::Clipboard::FormatType>* format_types) {
123 return allow_extension_dragging_ ? 156 return allow_extension_dragging_ ?
124 BrowserActionDragData::GetDropFormats(format_types) : 157 BrowserActionDragData::GetDropFormats(format_types) :
125 views::View::GetDropFormats(formats, format_types); 158 views::View::GetDropFormats(formats, format_types);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 199
167 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) { 200 void WrenchToolbarButton::OnPaint(gfx::Canvas* canvas) {
168 views::MenuButton::OnPaint(canvas); 201 views::MenuButton::OnPaint(canvas);
169 if (ui::MaterialDesignController::IsModeMaterial()) 202 if (ui::MaterialDesignController::IsModeMaterial())
170 return; 203 return;
171 wrench_icon_painter_->Paint(canvas, 204 wrench_icon_painter_->Paint(canvas,
172 GetThemeProvider(), 205 GetThemeProvider(),
173 gfx::Rect(size()), 206 gfx::Rect(size()),
174 WrenchIconPainter::BEZEL_NONE); 207 WrenchIconPainter::BEZEL_NONE);
175 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/wrench_toolbar_button.h ('k') | ui/gfx/color_palette.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698