| 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/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
| 14 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 15 #include "ui/views/controls/menu/menu_delegate.h" | 15 #include "ui/views/controls/menu/menu_delegate.h" |
| 16 | 16 |
| 17 class Browser; | 17 class Browser; |
| 18 class BrowserActionsContainer; | 18 class BrowserActionsContainer; |
| 19 class BrowserActionView; | 19 class BrowserActionView; |
| 20 | |
| 21 class IconUpdater; | 20 class IconUpdater; |
| 22 | 21 |
| 23 namespace views { | 22 namespace views { |
| 24 class MenuRunner; | 23 class MenuRunner; |
| 25 class Widget; | 24 class Widget; |
| 26 } | 25 } |
| 27 | 26 |
| 28 // This class handles the overflow menu for browser actions (showing the menu, | 27 // This class handles the overflow menu for browser actions (showing the menu, |
| 29 // drag and drop, etc). This class manages its own lifetime. | 28 // drag and drop, etc). This class manages its own lifetime. |
| 30 class BrowserActionOverflowMenuController : public views::MenuDelegate { | 29 class BrowserActionOverflowMenuController : public views::MenuDelegate { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // overflow menu. | 81 // overflow menu. |
| 83 virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE; | 82 virtual bool CanDrag(views::MenuItemView* menu) OVERRIDE; |
| 84 virtual void WriteDragData(views::MenuItemView* sender, | 83 virtual void WriteDragData(views::MenuItemView* sender, |
| 85 ui::OSExchangeData* data) OVERRIDE; | 84 ui::OSExchangeData* data) OVERRIDE; |
| 86 virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE; | 85 virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE; |
| 87 | 86 |
| 88 private: | 87 private: |
| 89 // This class manages its own lifetime. | 88 // This class manages its own lifetime. |
| 90 virtual ~BrowserActionOverflowMenuController(); | 89 virtual ~BrowserActionOverflowMenuController(); |
| 91 | 90 |
| 92 // Converts a menu item |id| into a BrowserActionView by adding the |id| value | 91 // Returns the offset into |views_| for the given |id|. |
| 93 // to the number of visible views (according to the container owner). If | 92 size_t IndexForId(int id) const; |
| 94 // |index| is specified, it will point to the absolute index of the view. | |
| 95 BrowserActionView* ViewForId(int id, size_t* index); | |
| 96 | 93 |
| 97 // A pointer to the browser action container that owns the overflow menu. | 94 // A pointer to the browser action container that owns the overflow menu. |
| 98 BrowserActionsContainer* owner_; | 95 BrowserActionsContainer* owner_; |
| 99 | 96 |
| 100 Browser* browser_; | 97 Browser* browser_; |
| 101 | 98 |
| 102 // The observer, may be null. | 99 // The observer, may be null. |
| 103 Observer* observer_; | 100 Observer* observer_; |
| 104 | 101 |
| 105 // A pointer to the overflow menu button that we are showing the menu for. | 102 // A pointer to the overflow menu button that we are showing the menu for. |
| 106 views::MenuButton* menu_button_; | 103 views::MenuButton* menu_button_; |
| 107 | 104 |
| 108 // The overflow menu for the menu button. Owned by |menu_runner_|. | 105 // The overflow menu for the menu button. Owned by |menu_runner_|. |
| 109 views::MenuItemView* menu_; | 106 views::MenuItemView* menu_; |
| 110 | 107 |
| 111 // Resposible for running the menu. | 108 // Resposible for running the menu. |
| 112 scoped_ptr<views::MenuRunner> menu_runner_; | 109 scoped_ptr<views::MenuRunner> menu_runner_; |
| 113 | 110 |
| 114 // The views vector of all the browser actions the container knows about. We | 111 // The views vector of all the browser actions the container knows about. We |
| 115 // won't show all items, just the one starting at |start_index| and above. | 112 // won't show all items, just the one starting at |start_index| and above. |
| 116 const std::vector<BrowserActionView*>* views_; | 113 // Owned by |owner_|. |
| 114 const std::vector<BrowserActionView*>& views_; |
| 117 | 115 |
| 118 // The index into the BrowserActionView vector, indicating where to start | 116 // The index into the BrowserActionView vector, indicating where to start |
| 119 // picking browser actions to draw. | 117 // picking browser actions to draw. |
| 120 int start_index_; | 118 int start_index_; |
| 121 | 119 |
| 122 // Whether this controller is being used for drop. | 120 // Whether this controller is being used for drop. |
| 123 bool for_drop_; | 121 bool for_drop_; |
| 124 | 122 |
| 125 // The vector keeps all icon updaters associated with menu item views in the | 123 // The vector keeps all icon updaters associated with menu item views in the |
| 126 // controller. The icon updater will update the menu item view's icon when | 124 // controller. The icon updater will update the menu item view's icon when |
| 127 // the browser action view's icon has been updated. | 125 // the browser action view's icon has been updated. |
| 128 ScopedVector<IconUpdater> icon_updaters_; | 126 ScopedVector<IconUpdater> icon_updaters_; |
| 129 | 127 |
| 130 friend class base::DeleteHelper<BrowserActionOverflowMenuController>; | 128 friend class base::DeleteHelper<BrowserActionOverflowMenuController>; |
| 131 | 129 |
| 132 DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController); | 130 DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController); |
| 133 }; | 131 }; |
| 134 | 132 |
| 135 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTR
OLLER_H_ | 133 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTR
OLLER_H_ |
| OLD | NEW |