| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLL
ER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLL
ER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLL
ER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTROLL
ER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/sequenced_task_runner_helpers.h" | 13 #include "base/sequenced_task_runner_helpers.h" |
| 14 #include "ui/views/controls/menu/menu_delegate.h" | 14 #include "ui/views/controls/menu/menu_delegate.h" |
| 15 | 15 |
| 16 class Browser; |
| 16 class BrowserActionsContainer; | 17 class BrowserActionsContainer; |
| 17 class BrowserActionView; | 18 class BrowserActionView; |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| 20 class MenuRunner; | 21 class MenuRunner; |
| 21 class Widget; | 22 class Widget; |
| 22 } | 23 } |
| 23 | 24 |
| 24 // This class handles the overflow menu for browser actions (showing the menu, | 25 // This class handles the overflow menu for browser actions (showing the menu, |
| 25 // drag and drop, etc). This class manages its own lifetime. | 26 // drag and drop, etc). This class manages its own lifetime. |
| 26 class BrowserActionOverflowMenuController : public views::MenuDelegate { | 27 class BrowserActionOverflowMenuController : public views::MenuDelegate { |
| 27 public: | 28 public: |
| 28 // The observer is notified prior to the menu being deleted. | 29 // The observer is notified prior to the menu being deleted. |
| 29 class Observer { | 30 class Observer { |
| 30 public: | 31 public: |
| 31 virtual void NotifyMenuDeleted( | 32 virtual void NotifyMenuDeleted( |
| 32 BrowserActionOverflowMenuController* controller) = 0; | 33 BrowserActionOverflowMenuController* controller) = 0; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 BrowserActionOverflowMenuController( | 36 BrowserActionOverflowMenuController( |
| 36 BrowserActionsContainer* owner, | 37 BrowserActionsContainer* owner, |
| 38 Browser* browser, |
| 37 views::MenuButton* menu_button, | 39 views::MenuButton* menu_button, |
| 38 const std::vector<BrowserActionView*>& views, | 40 const std::vector<BrowserActionView*>& views, |
| 39 int start_index); | 41 int start_index); |
| 40 | 42 |
| 41 void set_observer(Observer* observer) { observer_ = observer; } | 43 void set_observer(Observer* observer) { observer_ = observer; } |
| 42 | 44 |
| 43 // Shows the overflow menu. | 45 // Shows the overflow menu. |
| 44 bool RunMenu(views::Widget* widget, bool for_drop); | 46 bool RunMenu(views::Widget* widget, bool for_drop); |
| 45 | 47 |
| 46 // Closes the overflow menu (and its context menu if open as well). | 48 // Closes the overflow menu (and its context menu if open as well). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 virtual ~BrowserActionOverflowMenuController(); | 83 virtual ~BrowserActionOverflowMenuController(); |
| 82 | 84 |
| 83 // Converts a menu item |id| into a BrowserActionView by adding the |id| value | 85 // Converts a menu item |id| into a BrowserActionView by adding the |id| value |
| 84 // to the number of visible views (according to the container owner). If | 86 // to the number of visible views (according to the container owner). If |
| 85 // |index| is specified, it will point to the absolute index of the view. | 87 // |index| is specified, it will point to the absolute index of the view. |
| 86 BrowserActionView* ViewForId(int id, size_t* index); | 88 BrowserActionView* ViewForId(int id, size_t* index); |
| 87 | 89 |
| 88 // A pointer to the browser action container that owns the overflow menu. | 90 // A pointer to the browser action container that owns the overflow menu. |
| 89 BrowserActionsContainer* owner_; | 91 BrowserActionsContainer* owner_; |
| 90 | 92 |
| 93 Browser* browser_; |
| 94 |
| 91 // The observer, may be null. | 95 // The observer, may be null. |
| 92 Observer* observer_; | 96 Observer* observer_; |
| 93 | 97 |
| 94 // A pointer to the overflow menu button that we are showing the menu for. | 98 // A pointer to the overflow menu button that we are showing the menu for. |
| 95 views::MenuButton* menu_button_; | 99 views::MenuButton* menu_button_; |
| 96 | 100 |
| 97 // The overflow menu for the menu button. Owned by |menu_runner_|. | 101 // The overflow menu for the menu button. Owned by |menu_runner_|. |
| 98 views::MenuItemView* menu_; | 102 views::MenuItemView* menu_; |
| 99 | 103 |
| 100 // Resposible for running the menu. | 104 // Resposible for running the menu. |
| 101 scoped_ptr<views::MenuRunner> menu_runner_; | 105 scoped_ptr<views::MenuRunner> menu_runner_; |
| 102 | 106 |
| 103 // The views vector of all the browser actions the container knows about. We | 107 // The views vector of all the browser actions the container knows about. We |
| 104 // won't show all items, just the one starting at |start_index| and above. | 108 // won't show all items, just the one starting at |start_index| and above. |
| 105 const std::vector<BrowserActionView*>* views_; | 109 const std::vector<BrowserActionView*>* views_; |
| 106 | 110 |
| 107 // The index into the BrowserActionView vector, indicating where to start | 111 // The index into the BrowserActionView vector, indicating where to start |
| 108 // picking browser actions to draw. | 112 // picking browser actions to draw. |
| 109 int start_index_; | 113 int start_index_; |
| 110 | 114 |
| 111 // Whether this controller is being used for drop. | 115 // Whether this controller is being used for drop. |
| 112 bool for_drop_; | 116 bool for_drop_; |
| 113 | 117 |
| 114 friend class base::DeleteHelper<BrowserActionOverflowMenuController>; | 118 friend class base::DeleteHelper<BrowserActionOverflowMenuController>; |
| 115 | 119 |
| 116 DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController); | 120 DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController); |
| 117 }; | 121 }; |
| 118 | 122 |
| 119 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTR
OLLER_H_ | 123 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTR
OLLER_H_ |
| OLD | NEW |