| 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/threading/thread_task_runner_handle.h" | 10 #include "base/threading/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_node_data.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/models/menu_model.h" | 19 #include "ui/base/models/menu_model.h" |
| 20 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
| 21 #include "ui/display/screen.h" | 21 #include "ui/display/screen.h" |
| 22 #include "ui/strings/grit/ui_strings.h" | 22 #include "ui/strings/grit/ui_strings.h" |
| 23 #include "ui/views/controls/button/label_button_border.h" | 23 #include "ui/views/controls/button/label_button_border.h" |
| 24 #include "ui/views/controls/menu/menu_item_view.h" | 24 #include "ui/views/controls/menu/menu_item_view.h" |
| 25 #include "ui/views/controls/menu/menu_model_adapter.h" | 25 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 26 #include "ui/views/controls/menu/menu_runner.h" | 26 #include "ui/views/controls/menu/menu_runner.h" |
| 27 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { | 129 void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { |
| 130 if (menu_showing_) { | 130 if (menu_showing_) { |
| 131 // While dropdown menu is showing the button should not handle gestures. | 131 // While dropdown menu is showing the button should not handle gestures. |
| 132 event->StopPropagation(); | 132 event->StopPropagation(); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 LabelButton::OnGestureEvent(event); | 136 LabelButton::OnGestureEvent(event); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ToolbarButton::GetAccessibleState(ui::AXViewState* state) { | 139 void ToolbarButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 140 CustomButton::GetAccessibleState(state); | 140 CustomButton::GetAccessibleNodeData(node_data); |
| 141 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; | 141 node_data->role = ui::AX_ROLE_BUTTON_DROP_DOWN; |
| 142 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); | 142 node_data->AddStringAttribute( |
| 143 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 143 ui::AX_ATTR_ACTION, l10n_util::GetStringUTF8(IDS_APP_ACCACTION_PRESS)); |
| 144 node_data->AddStateFlag(ui::AX_STATE_HASPOPUP); |
| 144 } | 145 } |
| 145 | 146 |
| 146 std::unique_ptr<views::LabelButtonBorder> ToolbarButton::CreateDefaultBorder() | 147 std::unique_ptr<views::LabelButtonBorder> ToolbarButton::CreateDefaultBorder() |
| 147 const { | 148 const { |
| 148 std::unique_ptr<views::LabelButtonBorder> border = | 149 std::unique_ptr<views::LabelButtonBorder> border = |
| 149 views::LabelButton::CreateDefaultBorder(); | 150 views::LabelButton::CreateDefaultBorder(); |
| 150 | 151 |
| 151 if (ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme()) | 152 if (ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme()) |
| 152 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); | 153 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); |
| 153 | 154 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (state() != STATE_DISABLED) | 243 if (state() != STATE_DISABLED) |
| 243 SetState(STATE_NORMAL); | 244 SetState(STATE_NORMAL); |
| 244 | 245 |
| 245 menu_runner_.reset(); | 246 menu_runner_.reset(); |
| 246 menu_model_adapter_.reset(); | 247 menu_model_adapter_.reset(); |
| 247 } | 248 } |
| 248 | 249 |
| 249 const char* ToolbarButton::GetClassName() const { | 250 const char* ToolbarButton::GetClassName() const { |
| 250 return "ToolbarButton"; | 251 return "ToolbarButton"; |
| 251 } | 252 } |
| OLD | NEW |