| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 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 toolbar_view_(toolbar_view), | 40 toolbar_view_(toolbar_view), |
| 41 allow_extension_dragging_( | 41 allow_extension_dragging_( |
| 42 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()), | 42 extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()), |
| 43 margin_trailing_(0), | 43 margin_trailing_(0), |
| 44 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)), | |
| 45 weak_factory_(this) { | 44 weak_factory_(this) { |
| 46 set_ink_drop_delegate(ink_drop_delegate_.get()); | 45 set_ink_drop_delegate( |
| 46 base::WrapUnique(new views::ButtonInkDropDelegate(this, this))); |
| 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(AppMenuIconPainter::Severity severity, | 53 void AppMenuButton::SetSeverity(AppMenuIconPainter::Severity severity, |
| 54 bool animate) { | 54 bool animate) { |
| 55 if (ui::MaterialDesignController::IsModeMaterial()) { | 55 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 56 severity_ = severity; | 56 severity_ = severity; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 SetImage(views::Button::STATE_NORMAL, | 154 SetImage(views::Button::STATE_NORMAL, |
| 155 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color)); | 155 gfx::CreateVectorIcon(gfx::VectorIconId::BROWSER_TOOLS, color)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void AppMenuButton::SetTrailingMargin(int margin) { | 158 void AppMenuButton::SetTrailingMargin(int margin) { |
| 159 margin_trailing_ = margin; | 159 margin_trailing_ = margin; |
| 160 | 160 |
| 161 UpdateThemedBorder(); | 161 UpdateThemedBorder(); |
| 162 | 162 |
| 163 const int inset = LabelButton::kFocusRectInset; | 163 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 164 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( | 164 const int inset = LabelButton::kFocusRectInset; |
| 165 gfx::Insets(inset, inset, inset, inset + margin))); | 165 SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets( |
| 166 gfx::Insets(inset, inset, inset, inset + margin))); |
| 167 } |
| 168 |
| 166 InvalidateLayout(); | 169 InvalidateLayout(); |
| 167 } | 170 } |
| 168 | 171 |
| 169 const char* AppMenuButton::GetClassName() const { | 172 const char* AppMenuButton::GetClassName() const { |
| 170 return "AppMenuButton"; | 173 return "AppMenuButton"; |
| 171 } | 174 } |
| 172 | 175 |
| 173 std::unique_ptr<views::LabelButtonBorder> AppMenuButton::CreateDefaultBorder() | 176 std::unique_ptr<views::LabelButtonBorder> AppMenuButton::CreateDefaultBorder() |
| 174 const { | 177 const { |
| 175 std::unique_ptr<views::LabelButtonBorder> border = | 178 std::unique_ptr<views::LabelButtonBorder> border = |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 views::MenuButton::OnPaint(canvas); | 247 views::MenuButton::OnPaint(canvas); |
| 245 if (ui::MaterialDesignController::IsModeMaterial()) | 248 if (ui::MaterialDesignController::IsModeMaterial()) |
| 246 return; | 249 return; |
| 247 // Use GetPreferredSize() to center the icon inside the visible bounds rather | 250 // Use GetPreferredSize() to center the icon inside the visible bounds rather |
| 248 // than the whole size() (which may refer to hit test region extended to the | 251 // than the whole size() (which may refer to hit test region extended to the |
| 249 // end of the toolbar in maximized mode). | 252 // end of the toolbar in maximized mode). |
| 250 icon_painter_->Paint(canvas, GetThemeProvider(), | 253 icon_painter_->Paint(canvas, GetThemeProvider(), |
| 251 gfx::Rect(GetPreferredSize()), | 254 gfx::Rect(GetPreferredSize()), |
| 252 AppMenuIconPainter::BEZEL_NONE); | 255 AppMenuIconPainter::BEZEL_NONE); |
| 253 } | 256 } |
| OLD | NEW |