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_APP_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/ui/toolbar/app_menu_badge_controller.h" |
12 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" | 13 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" |
13 #include "ui/views/controls/button/menu_button.h" | 14 #include "ui/views/controls/button/menu_button.h" |
14 #include "ui/views/controls/button/menu_button_listener.h" | 15 #include "ui/views/controls/button/menu_button_listener.h" |
15 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
16 | 17 |
17 class AppMenu; | 18 class AppMenu; |
18 class AppMenuModel; | 19 class AppMenuModel; |
19 | 20 |
20 namespace views { | 21 namespace views { |
21 class InkDropDelegate; | 22 class InkDropDelegate; |
22 class LabelButtonBorder; | 23 class LabelButtonBorder; |
23 class MenuListener; | 24 class MenuListener; |
24 } | 25 } |
25 | 26 |
26 class ToolbarView; | 27 class ToolbarView; |
27 | 28 |
28 class AppMenuButton : public views::MenuButton, | 29 class AppMenuButton : public views::MenuButton, |
29 public AppMenuIconPainter::Delegate { | 30 public AppMenuIconPainter::Delegate { |
30 public: | 31 public: |
31 explicit AppMenuButton(ToolbarView* toolbar_view); | 32 explicit AppMenuButton(ToolbarView* toolbar_view); |
32 ~AppMenuButton() override; | 33 ~AppMenuButton() override; |
33 | 34 |
34 void SetSeverity(AppMenuIconPainter::Severity severity, bool animate); | 35 void SetSeverity(AppMenuBadgeController::BadgeType type, |
| 36 AppMenuIconPainter::Severity severity, |
| 37 bool animate); |
35 | 38 |
36 // Shows the app menu. |for_drop| indicates whether the menu is opened for a | 39 // Shows the app menu. |for_drop| indicates whether the menu is opened for a |
37 // drag-and-drop operation. | 40 // drag-and-drop operation. |
38 void ShowMenu(bool for_drop); | 41 void ShowMenu(bool for_drop); |
39 | 42 |
40 // Closes the app menu, if it's open. | 43 // Closes the app menu, if it's open. |
41 void CloseMenu(); | 44 void CloseMenu(); |
42 | 45 |
43 AppMenu* app_menu_for_testing() { return menu_.get(); } | 46 AppMenu* app_menu_for_testing() { return menu_.get(); } |
44 | 47 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 int OnDragUpdated(const ui::DropTargetEvent& event) override; | 87 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
85 void OnDragExited() override; | 88 void OnDragExited() override; |
86 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 89 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
87 void OnPaint(gfx::Canvas* canvas) override; | 90 void OnPaint(gfx::Canvas* canvas) override; |
88 | 91 |
89 // Only used in pre-MD. | 92 // Only used in pre-MD. |
90 std::unique_ptr<AppMenuIconPainter> icon_painter_; | 93 std::unique_ptr<AppMenuIconPainter> icon_painter_; |
91 | 94 |
92 // Only used in MD. | 95 // Only used in MD. |
93 AppMenuIconPainter::Severity severity_; | 96 AppMenuIconPainter::Severity severity_; |
| 97 AppMenuBadgeController::BadgeType type_; |
94 | 98 |
95 // Our owning toolbar view. | 99 // Our owning toolbar view. |
96 ToolbarView* toolbar_view_; | 100 ToolbarView* toolbar_view_; |
97 | 101 |
98 // Whether or not we should allow dragging extension icons onto this button | 102 // Whether or not we should allow dragging extension icons onto this button |
99 // (in order to open the overflow in the app menu). | 103 // (in order to open the overflow in the app menu). |
100 bool allow_extension_dragging_; | 104 bool allow_extension_dragging_; |
101 | 105 |
102 // Listeners to call when the menu opens. | 106 // Listeners to call when the menu opens. |
103 base::ObserverList<views::MenuListener> menu_listeners_; | 107 base::ObserverList<views::MenuListener> menu_listeners_; |
104 | 108 |
105 // App model and menu. | 109 // App model and menu. |
106 // Note that the menu should be destroyed before the model it uses, so the | 110 // Note that the menu should be destroyed before the model it uses, so the |
107 // menu should be listed later. | 111 // menu should be listed later. |
108 std::unique_ptr<AppMenuModel> menu_model_; | 112 std::unique_ptr<AppMenuModel> menu_model_; |
109 std::unique_ptr<AppMenu> menu_; | 113 std::unique_ptr<AppMenu> menu_; |
110 | 114 |
111 // Any trailing margin to be applied. Used when the browser is in | 115 // Any trailing margin to be applied. Used when the browser is in |
112 // a maximized state to extend to the full window width. | 116 // a maximized state to extend to the full window width. |
113 int margin_trailing_; | 117 int margin_trailing_; |
114 | 118 |
115 // Used to spawn weak pointers for delayed tasks to open the overflow menu. | 119 // Used to spawn weak pointers for delayed tasks to open the overflow menu. |
116 base::WeakPtrFactory<AppMenuButton> weak_factory_; | 120 base::WeakPtrFactory<AppMenuButton> weak_factory_; |
117 | 121 |
118 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); | 122 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); |
119 }; | 123 }; |
120 | 124 |
121 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 125 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
OLD | NEW |