Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/ui/views/extensions/browser_action_overflow_menu_controller.h

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Action box menu Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 associated with BrowserActionOverflowMenuController.
94 Browser* browser_;
95
91 // The observer, may be null. 96 // The observer, may be null.
92 Observer* observer_; 97 Observer* observer_;
93 98
94 // A pointer to the overflow menu button that we are showing the menu for. 99 // A pointer to the overflow menu button that we are showing the menu for.
95 views::MenuButton* menu_button_; 100 views::MenuButton* menu_button_;
96 101
97 // The overflow menu for the menu button. Owned by |menu_runner_|. 102 // The overflow menu for the menu button. Owned by |menu_runner_|.
98 views::MenuItemView* menu_; 103 views::MenuItemView* menu_;
99 104
100 // Resposible for running the menu. 105 // Resposible for running the menu.
101 scoped_ptr<views::MenuRunner> menu_runner_; 106 scoped_ptr<views::MenuRunner> menu_runner_;
102 107
103 // The views vector of all the browser actions the container knows about. We 108 // 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. 109 // won't show all items, just the one starting at |start_index| and above.
105 const std::vector<BrowserActionView*>* views_; 110 const std::vector<BrowserActionView*>* views_;
106 111
107 // The index into the BrowserActionView vector, indicating where to start 112 // The index into the BrowserActionView vector, indicating where to start
108 // picking browser actions to draw. 113 // picking browser actions to draw.
109 int start_index_; 114 int start_index_;
110 115
111 // Whether this controller is being used for drop. 116 // Whether this controller is being used for drop.
112 bool for_drop_; 117 bool for_drop_;
113 118
114 friend class base::DeleteHelper<BrowserActionOverflowMenuController>; 119 friend class base::DeleteHelper<BrowserActionOverflowMenuController>;
115 120
116 DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController); 121 DISALLOW_COPY_AND_ASSIGN(BrowserActionOverflowMenuController);
117 }; 122 };
118 123
119 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTR OLLER_H_ 124 #endif // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_BROWSER_ACTION_OVERFLOW_MENU_CONTR OLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698