| 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_controller.h" |
| 13 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" | 13 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" |
| 14 #include "ui/views/controls/button/menu_button.h" | 14 #include "ui/views/controls/button/menu_button.h" |
| 15 #include "ui/views/controls/button/menu_button_listener.h" | 15 #include "ui/views/controls/button/menu_button_listener.h" |
| 16 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 17 | 17 |
| 18 class AppMenu; | 18 class AppMenu; |
| 19 class AppMenuModel; | 19 class AppMenuModel; |
| 20 | 20 |
| 21 namespace views { | 21 namespace views { |
| 22 class InkDropDelegate; | 22 class InkDropDelegate; |
| 23 class LabelButtonBorder; | 23 class LabelButtonBorder; |
| 24 class MenuListener; | 24 class MenuListener; |
| 25 } | 25 } |
| 26 | 26 |
| 27 class ToolbarView; | 27 class ToolbarView; |
| 28 | 28 |
| 29 class AppMenuButton : public views::MenuButton, | 29 class AppMenuButton : public views::MenuButton, |
| 30 public AppMenuIconPainter::Delegate { | 30 public AppMenuIconPainter::Delegate { |
| 31 public: | 31 public: |
| 32 explicit AppMenuButton(ToolbarView* toolbar_view); | 32 explicit AppMenuButton(ToolbarView* toolbar_view); |
| 33 ~AppMenuButton() override; | 33 ~AppMenuButton() override; |
| 34 | 34 |
| 35 void SetSeverity(AppMenuBadgeController::BadgeType type, | 35 void SetSeverity(AppMenuIconController::IconType type, |
| 36 AppMenuIconPainter::Severity severity, | 36 AppMenuIconPainter::Severity severity, |
| 37 bool animate); | 37 bool animate); |
| 38 | 38 |
| 39 // 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 |
| 40 // drag-and-drop operation. | 40 // drag-and-drop operation. |
| 41 void ShowMenu(bool for_drop); | 41 void ShowMenu(bool for_drop); |
| 42 | 42 |
| 43 // Closes the app menu, if it's open. | 43 // Closes the app menu, if it's open. |
| 44 void CloseMenu(); | 44 void CloseMenu(); |
| 45 | 45 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int OnDragUpdated(const ui::DropTargetEvent& event) override; | 87 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
| 88 void OnDragExited() override; | 88 void OnDragExited() override; |
| 89 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 89 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 90 void OnPaint(gfx::Canvas* canvas) override; | 90 void OnPaint(gfx::Canvas* canvas) override; |
| 91 | 91 |
| 92 // Only used in pre-MD. | 92 // Only used in pre-MD. |
| 93 std::unique_ptr<AppMenuIconPainter> icon_painter_; | 93 std::unique_ptr<AppMenuIconPainter> icon_painter_; |
| 94 | 94 |
| 95 // Only used in MD. | 95 // Only used in MD. |
| 96 AppMenuIconPainter::Severity severity_; | 96 AppMenuIconPainter::Severity severity_; |
| 97 AppMenuBadgeController::BadgeType type_; | 97 AppMenuIconController::IconType type_; |
| 98 | 98 |
| 99 // Our owning toolbar view. | 99 // Our owning toolbar view. |
| 100 ToolbarView* toolbar_view_; | 100 ToolbarView* toolbar_view_; |
| 101 | 101 |
| 102 // 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 |
| 103 // (in order to open the overflow in the app menu). | 103 // (in order to open the overflow in the app menu). |
| 104 bool allow_extension_dragging_; | 104 bool allow_extension_dragging_; |
| 105 | 105 |
| 106 // Listeners to call when the menu opens. | 106 // Listeners to call when the menu opens. |
| 107 base::ObserverList<views::MenuListener> menu_listeners_; | 107 base::ObserverList<views::MenuListener> menu_listeners_; |
| 108 | 108 |
| 109 // App model and menu. | 109 // App model and menu. |
| 110 // 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 |
| 111 // menu should be listed later. | 111 // menu should be listed later. |
| 112 std::unique_ptr<AppMenuModel> menu_model_; | 112 std::unique_ptr<AppMenuModel> menu_model_; |
| 113 std::unique_ptr<AppMenu> menu_; | 113 std::unique_ptr<AppMenu> menu_; |
| 114 | 114 |
| 115 // 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 |
| 116 // a maximized state to extend to the full window width. | 116 // a maximized state to extend to the full window width. |
| 117 int margin_trailing_; | 117 int margin_trailing_; |
| 118 | 118 |
| 119 // 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. |
| 120 base::WeakPtrFactory<AppMenuButton> weak_factory_; | 120 base::WeakPtrFactory<AppMenuButton> weak_factory_; |
| 121 | 121 |
| 122 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); | 122 DISALLOW_COPY_AND_ASSIGN(AppMenuButton); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ | 125 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_BUTTON_H_ |
| OLD | NEW |