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

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

Issue 2039403002: Renamed AppMenuBadgeController to AppMenuIconController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed identifiers in Cocoa file 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"
(...skipping 19 matching lines...) Expand all
30 #include "ui/views/controls/menu/menu_listener.h" 30 #include "ui/views/controls/menu/menu_listener.h"
31 #include "ui/views/metrics.h" 31 #include "ui/views/metrics.h"
32 #include "ui/views/painter.h" 32 #include "ui/views/painter.h"
33 33
34 // static 34 // static
35 bool AppMenuButton::g_open_app_immediately_for_testing = false; 35 bool AppMenuButton::g_open_app_immediately_for_testing = false;
36 36
37 AppMenuButton::AppMenuButton(ToolbarView* toolbar_view) 37 AppMenuButton::AppMenuButton(ToolbarView* toolbar_view)
38 : views::MenuButton(base::string16(), toolbar_view, false), 38 : views::MenuButton(base::string16(), toolbar_view, false),
39 severity_(AppMenuIconPainter::SEVERITY_NONE), 39 severity_(AppMenuIconPainter::SEVERITY_NONE),
40 type_(AppMenuBadgeController::BadgeType::NONE), 40 type_(AppMenuIconController::IconType::NONE),
41 toolbar_view_(toolbar_view), 41 toolbar_view_(toolbar_view),
42 allow_extension_dragging_( 42 allow_extension_dragging_(
43 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()), 43 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()),
44 margin_trailing_(0), 44 margin_trailing_(0),
45 weak_factory_(this) { 45 weak_factory_(this) {
46 SetHasInkDrop(true); 46 SetHasInkDrop(true);
47 if (!ui::MaterialDesignController::IsModeMaterial()) 47 if (!ui::MaterialDesignController::IsModeMaterial())
48 icon_painter_.reset(new AppMenuIconPainter(this)); 48 icon_painter_.reset(new AppMenuIconPainter(this));
49 } 49 }
50 50
51 AppMenuButton::~AppMenuButton() {} 51 AppMenuButton::~AppMenuButton() {}
52 52
53 void AppMenuButton::SetSeverity(AppMenuBadgeController::BadgeType type, 53 void AppMenuButton::SetSeverity(AppMenuIconController::IconType type,
54 AppMenuIconPainter::Severity severity, 54 AppMenuIconPainter::Severity severity,
55 bool animate) { 55 bool animate) {
56 if (ui::MaterialDesignController::IsModeMaterial()) { 56 if (ui::MaterialDesignController::IsModeMaterial()) {
57 severity_ = severity; 57 severity_ = severity;
58 type_ = type; 58 type_ = type;
59 UpdateIcon(); 59 UpdateIcon();
60 return; 60 return;
61 } 61 }
62 62
63 icon_painter_->SetSeverity(severity, animate); 63 icon_painter_->SetSeverity(severity, animate);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 case AppMenuIconPainter::SEVERITY_MEDIUM: 148 case AppMenuIconPainter::SEVERITY_MEDIUM:
149 color = gfx::kGoogleYellow700; 149 color = gfx::kGoogleYellow700;
150 break; 150 break;
151 case AppMenuIconPainter::SEVERITY_HIGH: 151 case AppMenuIconPainter::SEVERITY_HIGH:
152 color = gfx::kGoogleRed700; 152 color = gfx::kGoogleRed700;
153 break; 153 break;
154 } 154 }
155 155
156 gfx::VectorIconId icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; 156 gfx::VectorIconId icon_id = gfx::VectorIconId::VECTOR_ICON_NONE;
157 switch (type_) { 157 switch (type_) {
158 case AppMenuBadgeController::BadgeType::NONE: 158 case AppMenuIconController::IconType::NONE:
159 icon_id = gfx::VectorIconId::BROWSER_TOOLS; 159 icon_id = gfx::VectorIconId::BROWSER_TOOLS;
160 DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE); 160 DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE);
161 break; 161 break;
162 case AppMenuBadgeController::BadgeType::UPGRADE_NOTIFICATION: 162 case AppMenuIconController::IconType::UPGRADE_NOTIFICATION:
163 icon_id = gfx::VectorIconId::BROWSER_TOOLS_UPDATE; 163 icon_id = gfx::VectorIconId::BROWSER_TOOLS_UPDATE;
164 break; 164 break;
165 case AppMenuBadgeController::BadgeType::GLOBAL_ERROR: 165 case AppMenuIconController::IconType::GLOBAL_ERROR:
166 icon_id = gfx::VectorIconId::BROWSER_TOOLS_ERROR; 166 icon_id = gfx::VectorIconId::BROWSER_TOOLS_ERROR;
167 break; 167 break;
168 case AppMenuBadgeController::BadgeType::INCOMPATIBILITY_WARNING: 168 case AppMenuIconController::IconType::INCOMPATIBILITY_WARNING:
169 icon_id = gfx::VectorIconId::BROWSER_TOOLS_WARNING; 169 icon_id = gfx::VectorIconId::BROWSER_TOOLS_WARNING;
170 break; 170 break;
171 } 171 }
172 172
173 SetImage(views::Button::STATE_NORMAL, gfx::CreateVectorIcon(icon_id, color)); 173 SetImage(views::Button::STATE_NORMAL, gfx::CreateVectorIcon(icon_id, color));
174 } 174 }
175 175
176 void AppMenuButton::SetTrailingMargin(int margin) { 176 void AppMenuButton::SetTrailingMargin(int margin) {
177 margin_trailing_ = margin; 177 margin_trailing_ = margin;
178 178
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 views::MenuButton::OnPaint(canvas); 265 views::MenuButton::OnPaint(canvas);
266 if (ui::MaterialDesignController::IsModeMaterial()) 266 if (ui::MaterialDesignController::IsModeMaterial())
267 return; 267 return;
268 // Use GetPreferredSize() to center the icon inside the visible bounds rather 268 // Use GetPreferredSize() to center the icon inside the visible bounds rather
269 // than the whole size() (which may refer to hit test region extended to the 269 // than the whole size() (which may refer to hit test region extended to the
270 // end of the toolbar in maximized mode). 270 // end of the toolbar in maximized mode).
271 icon_painter_->Paint(canvas, GetThemeProvider(), 271 icon_painter_->Paint(canvas, GetThemeProvider(),
272 gfx::Rect(GetPreferredSize()), 272 gfx::Rect(GetPreferredSize()),
273 AppMenuIconPainter::BEZEL_NONE); 273 AppMenuIconPainter::BEZEL_NONE);
274 } 274 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/app_menu_button.h ('k') | chrome/browser/ui/views/toolbar/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698