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_action_view.h" | 5 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "ui/gfx/image/image_skia_operations.h" | 26 #include "ui/gfx/image/image_skia_operations.h" |
27 #include "ui/gfx/image/image_skia_source.h" | 27 #include "ui/gfx/image/image_skia_source.h" |
28 #include "ui/resources/grit/ui_resources.h" | 28 #include "ui/resources/grit/ui_resources.h" |
29 #include "ui/views/animation/button_ink_drop_delegate.h" | 29 #include "ui/views/animation/button_ink_drop_delegate.h" |
30 #include "ui/views/controls/button/label_button_border.h" | 30 #include "ui/views/controls/button/label_button_border.h" |
31 #include "ui/views/controls/menu/menu_controller.h" | 31 #include "ui/views/controls/menu/menu_controller.h" |
32 #include "ui/views/controls/menu/menu_model_adapter.h" | 32 #include "ui/views/controls/menu/menu_model_adapter.h" |
33 #include "ui/views/controls/menu/menu_runner.h" | 33 #include "ui/views/controls/menu/menu_runner.h" |
34 #include "ui/views/mouse_constants.h" | 34 #include "ui/views/mouse_constants.h" |
35 #include "ui/views/resources/grit/views_resources.h" | 35 #include "ui/views/resources/grit/views_resources.h" |
| 36 #include "ui/views/style/platform_style.h" |
36 | 37 |
37 using views::LabelButtonBorder; | 38 using views::LabelButtonBorder; |
38 | 39 |
39 namespace { | 40 namespace { |
40 | 41 |
41 // Toolbar action buttons have no insets because the badges are drawn right at | 42 // Toolbar action buttons have no insets because the badges are drawn right at |
42 // the edge of the view's area. Other badding (such as centering the icon) is | 43 // the edge of the view's area. Other badding (such as centering the icon) is |
43 // handled directly by the Image. | 44 // handled directly by the Image. |
44 const int kBorderInset = 0; | 45 const int kBorderInset = 0; |
45 | 46 |
(...skipping 24 matching lines...) Expand all Loading... |
70 SetHorizontalAlignment(gfx::ALIGN_CENTER); | 71 SetHorizontalAlignment(gfx::ALIGN_CENTER); |
71 set_drag_controller(delegate_); | 72 set_drag_controller(delegate_); |
72 | 73 |
73 set_context_menu_controller(this); | 74 set_context_menu_controller(this); |
74 | 75 |
75 // If the button is within a menu, we need to make it focusable in order to | 76 // If the button is within a menu, we need to make it focusable in order to |
76 // have it accessible via keyboard navigation, but it shouldn't request focus | 77 // have it accessible via keyboard navigation, but it shouldn't request focus |
77 // (because that would close the menu). | 78 // (because that would close the menu). |
78 if (delegate_->ShownInsideMenu()) { | 79 if (delegate_->ShownInsideMenu()) { |
79 set_request_focus_on_press(false); | 80 set_request_focus_on_press(false); |
80 SetFocusable(true); | 81 views::PlatformStyle::ConfigureFocus( |
| 82 views::PlatformStyle::CONTROL::IN_MENU_BUTTON, this); |
81 } | 83 } |
82 | 84 |
83 UpdateState(); | 85 UpdateState(); |
84 } | 86 } |
85 | 87 |
86 ToolbarActionView::~ToolbarActionView() { | 88 ToolbarActionView::~ToolbarActionView() { |
87 // Avoid access to a destroyed InkDropDelegate when the |pressed_lock_| is | 89 // Avoid access to a destroyed InkDropDelegate when the |pressed_lock_| is |
88 // destroyed. | 90 // destroyed. |
89 set_ink_drop_delegate(nullptr); | 91 set_ink_drop_delegate(nullptr); |
90 view_controller_->SetDelegate(nullptr); | 92 view_controller_->SetDelegate(nullptr); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 if (menu_controller->in_nested_run()) { | 328 if (menu_controller->in_nested_run()) { |
327 // There is another menu showing. Close the outermost menu (since we are | 329 // There is another menu showing. Close the outermost menu (since we are |
328 // shown in the same menu, we don't want to close the whole thing). | 330 // shown in the same menu, we don't want to close the whole thing). |
329 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); | 331 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); |
330 return true; | 332 return true; |
331 } | 333 } |
332 } | 334 } |
333 | 335 |
334 return false; | 336 return false; |
335 } | 337 } |
OLD | NEW |