| 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 "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/themes/theme_service.h" |
| 13 #include "chrome/browser/themes/theme_service_factory.h" |
| 11 #include "chrome/browser/ui/layout_constants.h" | 14 #include "chrome/browser/ui/layout_constants.h" |
| 12 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 13 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_view_state.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/models/menu_model.h" | 18 #include "ui/base/models/menu_model.h" |
| 16 #include "ui/base/resource/material_design/material_design_controller.h" | 19 #include "ui/base/resource/material_design/material_design_controller.h" |
| 17 #include "ui/base/theme_provider.h" | 20 #include "ui/base/theme_provider.h" |
| 18 #include "ui/gfx/display.h" | 21 #include "ui/gfx/display.h" |
| 19 #include "ui/gfx/screen.h" | 22 #include "ui/gfx/screen.h" |
| 20 #include "ui/strings/grit/ui_strings.h" | 23 #include "ui/strings/grit/ui_strings.h" |
| 21 #include "ui/views/animation/ink_drop_animation_controller.h" | 24 #include "ui/views/animation/ink_drop_animation_controller.h" |
| 22 #include "ui/views/animation/ink_drop_animation_controller_factory.h" | 25 #include "ui/views/animation/ink_drop_animation_controller_factory.h" |
| 23 #include "ui/views/controls/button/label_button_border.h" | 26 #include "ui/views/controls/button/label_button_border.h" |
| 24 #include "ui/views/controls/menu/menu_item_view.h" | 27 #include "ui/views/controls/menu/menu_item_view.h" |
| 25 #include "ui/views/controls/menu/menu_model_adapter.h" | 28 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 26 #include "ui/views/controls/menu/menu_runner.h" | 29 #include "ui/views/controls/menu/menu_runner.h" |
| 27 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 28 | 31 |
| 29 ToolbarButton::ToolbarButton(views::ButtonListener* listener, | 32 ToolbarButton::ToolbarButton(Profile* profile, |
| 33 views::ButtonListener* listener, |
| 30 ui::MenuModel* model) | 34 ui::MenuModel* model) |
| 31 : views::LabelButton(listener, base::string16()), | 35 : views::LabelButton(listener, base::string16()), |
| 36 profile_(profile), |
| 32 model_(model), | 37 model_(model), |
| 33 menu_showing_(false), | 38 menu_showing_(false), |
| 34 y_position_on_lbuttondown_(0), | 39 y_position_on_lbuttondown_(0), |
| 35 ink_drop_animation_controller_( | 40 ink_drop_animation_controller_( |
| 36 views::InkDropAnimationControllerFactory:: | 41 views::InkDropAnimationControllerFactory:: |
| 37 CreateInkDropAnimationController(this)), | 42 CreateInkDropAnimationController(this)), |
| 38 show_menu_factory_(this) { | 43 show_menu_factory_(this) { |
| 39 set_context_menu_controller(this); | 44 set_context_menu_controller(this); |
| 40 | 45 |
| 41 const int kInkDropLargeSize = 32; | 46 const int kInkDropLargeSize = 32; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; | 199 state->role = ui::AX_ROLE_BUTTON_DROP_DOWN; |
| 195 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); | 200 state->default_action = l10n_util::GetStringUTF16(IDS_APP_ACCACTION_PRESS); |
| 196 state->AddStateFlag(ui::AX_STATE_HASPOPUP); | 201 state->AddStateFlag(ui::AX_STATE_HASPOPUP); |
| 197 } | 202 } |
| 198 | 203 |
| 199 scoped_ptr<views::LabelButtonBorder> | 204 scoped_ptr<views::LabelButtonBorder> |
| 200 ToolbarButton::CreateDefaultBorder() const { | 205 ToolbarButton::CreateDefaultBorder() const { |
| 201 scoped_ptr<views::LabelButtonBorder> border = | 206 scoped_ptr<views::LabelButtonBorder> border = |
| 202 views::LabelButton::CreateDefaultBorder(); | 207 views::LabelButton::CreateDefaultBorder(); |
| 203 | 208 |
| 204 const ui::ThemeProvider* provider = GetThemeProvider(); | 209 if (ThemeServiceFactory::GetForProfile(profile_)->UsingSystemTheme()) |
| 205 if (provider && provider->UsingSystemTheme()) | |
| 206 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); | 210 border->set_insets(GetLayoutInsets(TOOLBAR_BUTTON)); |
| 207 | 211 |
| 208 return border.Pass(); | 212 return border.Pass(); |
| 209 } | 213 } |
| 210 | 214 |
| 211 void ToolbarButton::ShowContextMenuForView(View* source, | 215 void ToolbarButton::ShowContextMenuForView(View* source, |
| 212 const gfx::Point& point, | 216 const gfx::Point& point, |
| 213 ui::MenuSourceType source_type) { | 217 ui::MenuSourceType source_type) { |
| 214 if (!enabled()) | 218 if (!enabled()) |
| 215 return; | 219 return; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 SetState(STATE_NORMAL); | 350 SetState(STATE_NORMAL); |
| 347 } | 351 } |
| 348 | 352 |
| 349 const char* ToolbarButton::GetClassName() const { | 353 const char* ToolbarButton::GetClassName() const { |
| 350 return "ToolbarButton"; | 354 return "ToolbarButton"; |
| 351 } | 355 } |
| 352 | 356 |
| 353 gfx::Point ToolbarButton::CalculateInkDropCenter() const { | 357 gfx::Point ToolbarButton::CalculateInkDropCenter() const { |
| 354 return GetLocalBounds().CenterPoint(); | 358 return GetLocalBounds().CenterPoint(); |
| 355 } | 359 } |
| OLD | NEW |