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 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" | 10 #include "chrome/browser/ui/views/toolbar/toolbar_action_view_delegate_views.h" |
11 #include "ui/views/animation/ink_drop_host.h" | |
12 #include "ui/views/context_menu_controller.h" | 11 #include "ui/views/context_menu_controller.h" |
13 #include "ui/views/controls/button/menu_button.h" | 12 #include "ui/views/controls/button/menu_button.h" |
14 #include "ui/views/controls/button/menu_button_listener.h" | 13 #include "ui/views/controls/button/menu_button_listener.h" |
15 #include "ui/views/drag_controller.h" | 14 #include "ui/views/drag_controller.h" |
16 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
17 | 16 |
18 class ExtensionAction; | 17 class ExtensionAction; |
19 class Profile; | 18 class Profile; |
20 | 19 |
21 namespace extensions { | 20 namespace extensions { |
22 class Extension; | 21 class Extension; |
23 } | 22 } |
24 | 23 |
25 namespace gfx { | 24 namespace gfx { |
26 class Image; | 25 class Image; |
27 } | 26 } |
28 | 27 |
29 namespace views { | 28 namespace views { |
30 class MenuItemView; | 29 class MenuItemView; |
31 class MenuRunner; | 30 class MenuRunner; |
32 } | 31 } |
33 | 32 |
34 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
35 // ToolbarActionView | 34 // ToolbarActionView |
36 // A wrapper around a ToolbarActionViewController to display a toolbar action | 35 // A wrapper around a ToolbarActionViewController to display a toolbar action |
37 // action in the BrowserActionsContainer. | 36 // action in the BrowserActionsContainer. |
38 class ToolbarActionView : public views::MenuButton, | 37 class ToolbarActionView : public views::MenuButton, |
39 public ToolbarActionViewDelegateViews, | 38 public ToolbarActionViewDelegateViews, |
40 public views::MenuButtonListener, | 39 public views::MenuButtonListener, |
41 public views::ContextMenuController, | 40 public views::ContextMenuController { |
42 public views::InkDropHost { | |
43 public: | 41 public: |
44 // Need DragController here because ToolbarActionView could be | 42 // Need DragController here because ToolbarActionView could be |
45 // dragged/dropped. | 43 // dragged/dropped. |
46 class Delegate : public views::DragController { | 44 class Delegate : public views::DragController { |
47 public: | 45 public: |
48 // Returns the current web contents. | 46 // Returns the current web contents. |
49 virtual content::WebContents* GetCurrentWebContents() = 0; | 47 virtual content::WebContents* GetCurrentWebContents() = 0; |
50 | 48 |
51 // Whether the container for this button is shown inside a menu. | 49 // Whether the container for this button is shown inside a menu. |
52 virtual bool ShownInsideMenu() const = 0; | 50 virtual bool ShownInsideMenu() const = 0; |
(...skipping 18 matching lines...) Expand all Loading... |
71 ToolbarActionView(ToolbarActionViewController* view_controller, | 69 ToolbarActionView(ToolbarActionViewController* view_controller, |
72 Profile* profile, | 70 Profile* profile, |
73 Delegate* delegate); | 71 Delegate* delegate); |
74 ~ToolbarActionView() override; | 72 ~ToolbarActionView() override; |
75 | 73 |
76 // views::MenuButton: | 74 // views::MenuButton: |
77 void GetAccessibleState(ui::AXViewState* state) override; | 75 void GetAccessibleState(ui::AXViewState* state) override; |
78 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; | 76 scoped_ptr<views::LabelButtonBorder> CreateDefaultBorder() const override; |
79 void OnMouseEntered(const ui::MouseEvent& event) override; | 77 void OnMouseEntered(const ui::MouseEvent& event) override; |
80 bool ShouldEnterPushedState(const ui::Event& event) override; | 78 bool ShouldEnterPushedState(const ui::Event& event) override; |
| 79 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; |
| 80 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; |
81 | 81 |
82 // ToolbarActionViewDelegateViews: | 82 // ToolbarActionViewDelegateViews: |
83 content::WebContents* GetCurrentWebContents() const override; | 83 content::WebContents* GetCurrentWebContents() const override; |
84 void UpdateState() override; | 84 void UpdateState() override; |
85 | 85 |
86 // views::MenuButtonListener: | 86 // views::MenuButtonListener: |
87 void OnMenuButtonClicked(views::View* sender, | 87 void OnMenuButtonClicked(views::View* sender, |
88 const gfx::Point& point) override; | 88 const gfx::Point& point) override; |
89 | 89 |
90 // views::InkDropHost: | |
91 void AddInkDropLayer(ui::Layer* ink_drop_layer) override; | |
92 void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override; | |
93 | |
94 ToolbarActionViewController* view_controller() { | 90 ToolbarActionViewController* view_controller() { |
95 return view_controller_; | 91 return view_controller_; |
96 } | 92 } |
97 | 93 |
98 // Returns button icon so it can be accessed during tests. | 94 // Returns button icon so it can be accessed during tests. |
99 gfx::ImageSkia GetIconForTest(); | 95 gfx::ImageSkia GetIconForTest(); |
100 | 96 |
101 bool wants_to_run_for_testing() const { return wants_to_run_; } | 97 bool wants_to_run_for_testing() const { return wants_to_run_; } |
102 | 98 |
103 // Set a callback to be called directly before the context menu is shown. | 99 // Set a callback to be called directly before the context menu is shown. |
(...skipping 18 matching lines...) Expand all Loading... |
122 views::View* GetReferenceViewForPopup() override; | 118 views::View* GetReferenceViewForPopup() override; |
123 bool IsMenuRunning() const override; | 119 bool IsMenuRunning() const override; |
124 void OnPopupShown(bool by_user) override; | 120 void OnPopupShown(bool by_user) override; |
125 void OnPopupClosed() override; | 121 void OnPopupClosed() override; |
126 | 122 |
127 // views::ContextMenuController: | 123 // views::ContextMenuController: |
128 void ShowContextMenuForView(views::View* source, | 124 void ShowContextMenuForView(views::View* source, |
129 const gfx::Point& point, | 125 const gfx::Point& point, |
130 ui::MenuSourceType source_type) override; | 126 ui::MenuSourceType source_type) override; |
131 | 127 |
132 // views::InkDropHost: | |
133 gfx::Point CalculateInkDropCenter() const override; | |
134 | |
135 // Shows the context menu (if one exists) for the toolbar action. | 128 // Shows the context menu (if one exists) for the toolbar action. |
136 void DoShowContextMenu(ui::MenuSourceType source_type); | 129 void DoShowContextMenu(ui::MenuSourceType source_type); |
137 | 130 |
138 // Closes the currently-active menu, if needed. This is the case when there | 131 // Closes the currently-active menu, if needed. This is the case when there |
139 // is an active menu that wouldn't close automatically when a new one is | 132 // is an active menu that wouldn't close automatically when a new one is |
140 // opened. | 133 // opened. |
141 // Returns true if a menu was closed, false otherwise. | 134 // Returns true if a menu was closed, false otherwise. |
142 bool CloseActiveMenuIfNeeded(); | 135 bool CloseActiveMenuIfNeeded(); |
143 | 136 |
144 // A lock to keep the MenuButton pressed when a menu or popup is visible. | 137 // A lock to keep the MenuButton pressed when a menu or popup is visible. |
(...skipping 30 matching lines...) Expand all Loading... |
175 base::TimeTicks popup_closed_time_; | 168 base::TimeTicks popup_closed_time_; |
176 | 169 |
177 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; | 170 scoped_ptr<views::InkDropDelegate> ink_drop_delegate_; |
178 | 171 |
179 base::WeakPtrFactory<ToolbarActionView> weak_factory_; | 172 base::WeakPtrFactory<ToolbarActionView> weak_factory_; |
180 | 173 |
181 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); | 174 DISALLOW_COPY_AND_ASSIGN(ToolbarActionView); |
182 }; | 175 }; |
183 | 176 |
184 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ | 177 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_TOOLBAR_ACTION_VIEW_H_ |
OLD | NEW |