| 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/toolbar_button.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_button.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/themes/theme_service.h" | 13 #include "chrome/browser/themes/theme_service.h" |
| 14 #include "chrome/browser/themes/theme_service_factory.h" | 14 #include "chrome/browser/themes/theme_service_factory.h" |
| 15 #include "chrome/browser/ui/layout_constants.h" | 15 #include "chrome/browser/ui/layout_constants.h" |
| 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 17 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_view_state.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/material_design/material_design_controller.h" | 19 #include "ui/base/material_design/material_design_controller.h" |
| 20 #include "ui/base/models/menu_model.h" | 20 #include "ui/base/models/menu_model.h" |
| 21 #include "ui/base/theme_provider.h" | 21 #include "ui/base/theme_provider.h" |
| 22 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
| 23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 24 #include "ui/strings/grit/ui_strings.h" | 24 #include "ui/strings/grit/ui_strings.h" |
| 25 #include "ui/views/animation/button_ink_drop_delegate.h" | 25 #include "ui/views/animation/button_ink_drop_delegate.h" |
| 26 #include "ui/views/controls/button/label_button_border.h" | 26 #include "ui/views/controls/button/label_button_border.h" |
| 27 #include "ui/views/controls/menu/menu_item_view.h" | 27 #include "ui/views/controls/menu/menu_item_view.h" |
| 28 #include "ui/views/controls/menu/menu_model_adapter.h" | 28 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 29 #include "ui/views/controls/menu/menu_runner.h" | 29 #include "ui/views/controls/menu/menu_runner.h" |
| 30 #include "ui/views/style/platform_style.h" |
| 30 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
| 31 | 32 |
| 32 ToolbarButton::ToolbarButton(Profile* profile, | 33 ToolbarButton::ToolbarButton(Profile* profile, |
| 33 views::ButtonListener* listener, | 34 views::ButtonListener* listener, |
| 34 ui::MenuModel* model) | 35 ui::MenuModel* model) |
| 35 : views::LabelButton(listener, base::string16()), | 36 : views::LabelButton(listener, base::string16()), |
| 36 profile_(profile), | 37 profile_(profile), |
| 37 model_(model), | 38 model_(model), |
| 38 menu_showing_(false), | 39 menu_showing_(false), |
| 39 y_position_on_lbuttondown_(0), | 40 y_position_on_lbuttondown_(0), |
| 40 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)), | 41 ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)), |
| 41 show_menu_factory_(this) { | 42 show_menu_factory_(this) { |
| 42 set_ink_drop_delegate(ink_drop_delegate_.get()); | 43 set_ink_drop_delegate(ink_drop_delegate_.get()); |
| 43 set_has_ink_drop_action_on_click(true); | 44 set_has_ink_drop_action_on_click(true); |
| 44 set_context_menu_controller(this); | 45 set_context_menu_controller(this); |
| 45 } | 46 } |
| 46 | 47 |
| 47 ToolbarButton::~ToolbarButton() {} | 48 ToolbarButton::~ToolbarButton() {} |
| 48 | 49 |
| 49 void ToolbarButton::Init() { | 50 void ToolbarButton::Init() { |
| 50 SetFocusable(false); | 51 views::PlatformStyle::ConfigureFocus( |
| 51 SetAccessibilityFocusable(true); | 52 views::PlatformStyle::CONTROL::TOOLBAR_BUTTON, this); |
| 52 image()->EnableCanvasFlippingForRTLUI(true); | 53 image()->EnableCanvasFlippingForRTLUI(true); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void ToolbarButton::ClearPendingMenu() { | 56 void ToolbarButton::ClearPendingMenu() { |
| 56 show_menu_factory_.InvalidateWeakPtrs(); | 57 show_menu_factory_.InvalidateWeakPtrs(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 bool ToolbarButton::IsMenuShowing() const { | 60 bool ToolbarButton::IsMenuShowing() const { |
| 60 return menu_showing_; | 61 return menu_showing_; |
| 61 } | 62 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // Set the state back to normal after the drop down menu is closed. | 254 // Set the state back to normal after the drop down menu is closed. |
| 254 if (state() != STATE_DISABLED) | 255 if (state() != STATE_DISABLED) |
| 255 SetState(STATE_NORMAL); | 256 SetState(STATE_NORMAL); |
| 256 | 257 |
| 257 menu_model_adapter_.reset(); | 258 menu_model_adapter_.reset(); |
| 258 } | 259 } |
| 259 | 260 |
| 260 const char* ToolbarButton::GetClassName() const { | 261 const char* ToolbarButton::GetClassName() const { |
| 261 return "ToolbarButton"; | 262 return "ToolbarButton"; |
| 262 } | 263 } |
| OLD | NEW |