| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_EXTENSION_TOOLBAR_MENU_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/scoped_observer.h" | 9 #include "base/scoped_observer.h" |
| 10 #include "chrome/browser/ui/views/toolbar/browser_actions_container_observer.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_observer.h" |
| 11 #include "ui/views/controls/scroll_view.h" | 11 #include "ui/views/controls/scroll_view.h" |
| 12 | 12 |
| 13 class AppMenu; | 13 class AppMenu; |
| 14 class Browser; | 14 class Browser; |
| 15 class BrowserActionsContainer; | 15 class BrowserActionsContainer; |
| 16 class ToolbarActionsBar; |
| 16 | 17 |
| 17 // ExtensionToolbarMenuView is the view containing the extension actions that | 18 // ExtensionToolbarMenuView is the view containing the extension actions that |
| 18 // overflowed from the BrowserActionsContainer, and is contained in and owned by | 19 // overflowed from the BrowserActionsContainer, and is contained in and owned by |
| 19 // the app menu. | 20 // the app menu. |
| 20 // In the event that the app menu was opened for an Extension Action drag-and- | 21 // In the event that the app menu was opened for an Extension Action drag-and- |
| 21 // drop, this will also close the menu upon completion. | 22 // drop, this will also close the menu upon completion. |
| 22 class ExtensionToolbarMenuView : public views::ScrollView, | 23 class ExtensionToolbarMenuView : public views::ScrollView, |
| 23 public BrowserActionsContainerObserver { | 24 public ToolbarActionsBarObserver { |
| 24 public: | 25 public: |
| 25 ExtensionToolbarMenuView(Browser* browser, AppMenu* app_menu); | 26 ExtensionToolbarMenuView(Browser* browser, AppMenu* app_menu); |
| 26 ~ExtensionToolbarMenuView() override; | 27 ~ExtensionToolbarMenuView() override; |
| 27 | 28 |
| 28 // Returns whether the app menu should show this view. This is true when | 29 // Returns whether the app menu should show this view. This is true when |
| 29 // either |container_| has icons to display or the menu was opened for a drag- | 30 // either |container_| has icons to display or the menu was opened for a drag- |
| 30 // and-drop operation. | 31 // and-drop operation. |
| 31 bool ShouldShow(); | 32 bool ShouldShow(); |
| 32 | 33 |
| 33 // views::View: | 34 // views::View: |
| 34 gfx::Size GetPreferredSize() const override; | 35 gfx::Size GetPreferredSize() const override; |
| 35 int GetHeightForWidth(int width) const override; | 36 int GetHeightForWidth(int width) const override; |
| 36 void Layout() override; | 37 void Layout() override; |
| 37 | 38 |
| 38 BrowserActionsContainer* container_for_testing() { | 39 BrowserActionsContainer* container_for_testing() { |
| 39 return container_; | 40 return container_; |
| 40 } | 41 } |
| 41 | 42 |
| 42 // Sets the time delay the app menu takes to close after a drag-and-drop | 43 // Sets the time delay the app menu takes to close after a drag-and-drop |
| 43 // operation. | 44 // operation. |
| 44 static void set_close_menu_delay_for_testing(int delay); | 45 static void set_close_menu_delay_for_testing(int delay); |
| 45 | 46 |
| 46 private: | 47 private: |
| 47 // BrowserActionsContainerObserver: | 48 // ToolbarActionsBarObserver: |
| 48 void OnBrowserActionsContainerDestroyed( | 49 void OnToolbarActionsBarDestroyed() override; |
| 49 BrowserActionsContainer* browser_actions_container) override; | 50 void OnToolbarActionDragDone() override; |
| 50 void OnBrowserActionDragDone() override; | 51 void OnToolbarActionsBarDidStartResize() override; |
| 51 | 52 |
| 52 // Closes the |app_menu_|. | 53 // Closes the |app_menu_|. |
| 53 void CloseAppMenu(); | 54 void CloseAppMenu(); |
| 54 | 55 |
| 56 // Resizes and lays out the view. |
| 57 void Redraw(); |
| 58 |
| 55 // Returns the padding before the BrowserActionsContainer in the menu. | 59 // Returns the padding before the BrowserActionsContainer in the menu. |
| 56 int start_padding() const; | 60 int start_padding() const; |
| 57 | 61 |
| 58 // The associated browser. | 62 // The associated browser. |
| 59 Browser* browser_; | 63 Browser* browser_; |
| 60 | 64 |
| 61 // The app menu, which may need to be closed after a drag-and-drop. | 65 // The app menu, which may need to be closed after a drag-and-drop. |
| 62 AppMenu* app_menu_; | 66 AppMenu* app_menu_; |
| 63 | 67 |
| 64 // The overflow BrowserActionsContainer which is nested in this view. | 68 // The overflow BrowserActionsContainer which is nested in this view. |
| 65 BrowserActionsContainer* container_; | 69 BrowserActionsContainer* container_; |
| 66 | 70 |
| 67 // The maximum allowed height for the view. | 71 // The maximum allowed height for the view. |
| 68 int max_height_; | 72 int max_height_; |
| 69 | 73 |
| 70 ScopedObserver<BrowserActionsContainer, BrowserActionsContainerObserver> | 74 ScopedObserver<ToolbarActionsBar, ToolbarActionsBarObserver> |
| 71 browser_actions_container_observer_; | 75 toolbar_actions_bar_observer_; |
| 72 | 76 |
| 73 base::WeakPtrFactory<ExtensionToolbarMenuView> weak_factory_; | 77 base::WeakPtrFactory<ExtensionToolbarMenuView> weak_factory_; |
| 74 | 78 |
| 75 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarMenuView); | 79 DISALLOW_COPY_AND_ASSIGN(ExtensionToolbarMenuView); |
| 76 }; | 80 }; |
| 77 | 81 |
| 78 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_ | 82 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_EXTENSION_TOOLBAR_MENU_VIEW_H_ |
| OLD | NEW |