| Index: chrome/browser/ui/views/toolbar/app_menu_button.cc
|
| diff --git a/chrome/browser/ui/views/toolbar/app_menu_button.cc b/chrome/browser/ui/views/toolbar/app_menu_button.cc
|
| index 3236307747c1d62a6023d65d91c2e7e6b4785caf..eb174eb510ba01e7f2212ed37bcb30e546d1f73a 100644
|
| --- a/chrome/browser/ui/views/toolbar/app_menu_button.cc
|
| +++ b/chrome/browser/ui/views/toolbar/app_menu_button.cc
|
| @@ -19,7 +19,6 @@
|
| #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
|
| #include "chrome/grit/theme_resources.h"
|
| #include "extensions/common/feature_switch.h"
|
| -#include "ui/base/material_design/material_design_controller.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/base/theme_provider.h"
|
| #include "ui/gfx/color_palette.h"
|
| @@ -29,42 +28,31 @@
|
| #include "ui/views/controls/button/label_button_border.h"
|
| #include "ui/views/controls/menu/menu_listener.h"
|
| #include "ui/views/metrics.h"
|
| -#include "ui/views/painter.h"
|
|
|
| // static
|
| bool AppMenuButton::g_open_app_immediately_for_testing = false;
|
|
|
| AppMenuButton::AppMenuButton(ToolbarView* toolbar_view)
|
| : views::MenuButton(base::string16(), toolbar_view, false),
|
| - severity_(AppMenuIconPainter::SEVERITY_NONE),
|
| + severity_(AppMenuIconController::Severity::NONE),
|
| type_(AppMenuIconController::IconType::NONE),
|
| toolbar_view_(toolbar_view),
|
| allow_extension_dragging_(
|
| extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()),
|
| margin_trailing_(0),
|
| weak_factory_(this) {
|
| - if (ui::MaterialDesignController::IsModeMaterial()) {
|
| - SetInkDropMode(InkDropMode::ON);
|
| - SetFocusPainter(nullptr);
|
| - } else {
|
| - icon_painter_.reset(new AppMenuIconPainter(this));
|
| - }
|
| + SetInkDropMode(InkDropMode::ON);
|
| + SetFocusPainter(nullptr);
|
| }
|
|
|
| AppMenuButton::~AppMenuButton() {}
|
|
|
| void AppMenuButton::SetSeverity(AppMenuIconController::IconType type,
|
| - AppMenuIconPainter::Severity severity,
|
| + AppMenuIconController::Severity severity,
|
| bool animate) {
|
| - if (ui::MaterialDesignController::IsModeMaterial()) {
|
| - severity_ = severity;
|
| - type_ = type;
|
| - UpdateIcon();
|
| - return;
|
| - }
|
| -
|
| - icon_painter_->SetSeverity(severity, animate);
|
| - SchedulePaint();
|
| + severity_ = severity;
|
| + type_ = type;
|
| + UpdateIcon();
|
| }
|
|
|
| void AppMenuButton::ShowMenu(bool for_drop) {
|
| @@ -119,42 +107,29 @@ void AppMenuButton::RemoveMenuListener(views::MenuListener* listener) {
|
| }
|
|
|
| gfx::Size AppMenuButton::GetPreferredSize() const {
|
| - if (ui::MaterialDesignController::IsModeMaterial()) {
|
| - gfx::Size size(image()->GetPreferredSize());
|
| - const ui::ThemeProvider* provider = GetThemeProvider();
|
| - if (provider) {
|
| - gfx::Insets insets(GetLayoutInsets(TOOLBAR_BUTTON));
|
| - size.Enlarge(insets.width(), insets.height());
|
| - }
|
| - return size;
|
| - }
|
| -
|
| - return ResourceBundle::GetSharedInstance().
|
| - GetImageSkiaNamed(IDR_TOOLBAR_BEZEL_HOVER)->size();
|
| -}
|
| -
|
| -void AppMenuButton::ScheduleAppMenuIconPaint() {
|
| - SchedulePaint();
|
| + gfx::Size size(image()->GetPreferredSize());
|
| + gfx::Insets insets(GetLayoutInsets(TOOLBAR_BUTTON));
|
| + size.Enlarge(insets.width(), insets.height());
|
| + return size;
|
| }
|
|
|
| void AppMenuButton::UpdateIcon() {
|
| - DCHECK(ui::MaterialDesignController::IsModeMaterial());
|
| SkColor color = gfx::kPlaceholderColor;
|
| const ui::NativeTheme* native_theme = GetNativeTheme();
|
| switch (severity_) {
|
| - case AppMenuIconPainter::SEVERITY_NONE:
|
| + case AppMenuIconController::Severity::NONE:
|
| color = GetThemeProvider()->GetColor(
|
| ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
|
| break;
|
| - case AppMenuIconPainter::SEVERITY_LOW:
|
| + case AppMenuIconController::Severity::LOW:
|
| color = native_theme->GetSystemColor(
|
| ui::NativeTheme::kColorId_AlertSeverityLow);
|
| break;
|
| - case AppMenuIconPainter::SEVERITY_MEDIUM:
|
| + case AppMenuIconController::Severity::MEDIUM:
|
| color = native_theme->GetSystemColor(
|
| ui::NativeTheme::kColorId_AlertSeverityMedium);
|
| break;
|
| - case AppMenuIconPainter::SEVERITY_HIGH:
|
| + case AppMenuIconController::Severity::HIGH:
|
| color = native_theme->GetSystemColor(
|
| ui::NativeTheme::kColorId_AlertSeverityHigh);
|
| break;
|
| @@ -164,7 +139,7 @@ void AppMenuButton::UpdateIcon() {
|
| switch (type_) {
|
| case AppMenuIconController::IconType::NONE:
|
| icon_id = gfx::VectorIconId::BROWSER_TOOLS;
|
| - DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE);
|
| + DCHECK_EQ(severity_, AppMenuIconController::Severity::NONE);
|
| break;
|
| case AppMenuIconController::IconType::UPGRADE_NOTIFICATION:
|
| icon_id = gfx::VectorIconId::BROWSER_TOOLS_UPDATE;
|
| @@ -180,15 +155,7 @@ void AppMenuButton::UpdateIcon() {
|
|
|
| void AppMenuButton::SetTrailingMargin(int margin) {
|
| margin_trailing_ = margin;
|
| -
|
| UpdateThemedBorder();
|
| -
|
| - if (!ui::MaterialDesignController::IsModeMaterial()) {
|
| - const int inset = LabelButton::kFocusRectInset;
|
| - SetFocusPainter(views::Painter::CreateDashedFocusPainterWithInsets(
|
| - gfx::Insets(inset, inset, inset, inset + margin)));
|
| - }
|
| -
|
| InvalidateLayout();
|
| }
|
|
|
| @@ -265,15 +232,3 @@ int AppMenuButton::OnPerformDrop(const ui::DropTargetEvent& event) {
|
| DCHECK(allow_extension_dragging_);
|
| return ui::DragDropTypes::DRAG_MOVE;
|
| }
|
| -
|
| -void AppMenuButton::OnPaint(gfx::Canvas* canvas) {
|
| - views::MenuButton::OnPaint(canvas);
|
| - if (ui::MaterialDesignController::IsModeMaterial())
|
| - return;
|
| - // Use GetPreferredSize() to center the icon inside the visible bounds rather
|
| - // than the whole size() (which may refer to hit test region extended to the
|
| - // end of the toolbar in maximized mode).
|
| - icon_painter_->Paint(canvas, GetThemeProvider(),
|
| - gfx::Rect(GetPreferredSize()),
|
| - AppMenuIconPainter::BEZEL_NONE);
|
| -}
|
|
|