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

Side by Side Diff: chrome/browser/ui/views/toolbar/wrench_menu.h

Issue 431473003: Make all views platforms use 'new' (cros-style) wrench menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile errors Created 6 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 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_WRENCH_MENU_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 20 matching lines...) Expand all
31 class MenuRunner; 31 class MenuRunner;
32 class View; 32 class View;
33 } // namespace views 33 } // namespace views
34 34
35 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes. 35 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes.
36 class WrenchMenu : public views::MenuDelegate, 36 class WrenchMenu : public views::MenuDelegate,
37 public BaseBookmarkModelObserver, 37 public BaseBookmarkModelObserver,
38 public content::NotificationObserver { 38 public content::NotificationObserver {
39 public: 39 public:
40 enum RunFlags { 40 enum RunFlags {
41 // TODO: remove |USE_NEW_MENU| and |SUPPORTS_NEW_SEPARATORS|.
42 USE_NEW_MENU = 1 << 0,
43 SUPPORTS_NEW_SEPARATORS = 1 << 1,
44
45 // Indicates that the menu was opened for a drag-and-drop operation. 41 // Indicates that the menu was opened for a drag-and-drop operation.
46 FOR_DROP = 1 << 2, 42 FOR_DROP = 1 << 0,
47 }; 43 };
48 44
49 WrenchMenu(Browser* browser, int run_flags); 45 WrenchMenu(Browser* browser, int run_flags);
50 virtual ~WrenchMenu(); 46 virtual ~WrenchMenu();
51 47
52 void Init(ui::MenuModel* model); 48 void Init(ui::MenuModel* model);
53 49
54 // Shows the menu relative to the specified view. 50 // Shows the menu relative to the specified view.
55 void RunMenu(views::MenuButton* host); 51 void RunMenu(views::MenuButton* host);
56 52
57 // Closes the menu if it is open, otherwise does nothing. 53 // Closes the menu if it is open, otherwise does nothing.
58 void CloseMenu(); 54 void CloseMenu();
59 55
60 // Whether the menu is currently visible to the user. 56 // Whether the menu is currently visible to the user.
61 bool IsShowing(); 57 bool IsShowing();
62 58
63 bool use_new_menu() const { return (run_flags_ & USE_NEW_MENU) != 0; }
64 bool for_drop() const { return (run_flags_ & FOR_DROP) != 0; } 59 bool for_drop() const { return (run_flags_ & FOR_DROP) != 0; }
65 60
66 void AddObserver(WrenchMenuObserver* observer); 61 void AddObserver(WrenchMenuObserver* observer);
67 void RemoveObserver(WrenchMenuObserver* observer); 62 void RemoveObserver(WrenchMenuObserver* observer);
68 63
69 // MenuDelegate overrides: 64 // MenuDelegate overrides:
70 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; 65 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE;
71 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( 66 virtual bool GetShouldUseDisabledEmphasizedForegroundColor(
72 int command_id) const OVERRIDE; 67 int command_id) const OVERRIDE;
73 virtual base::string16 GetTooltipText(int command_id, 68 virtual base::string16 GetTooltipText(int command_id,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const content::NotificationDetails& details) OVERRIDE; 109 const content::NotificationDetails& details) OVERRIDE;
115 110
116 private: 111 private:
117 class CutCopyPasteView; 112 class CutCopyPasteView;
118 class RecentTabsMenuModelDelegate; 113 class RecentTabsMenuModelDelegate;
119 class ZoomView; 114 class ZoomView;
120 115
121 typedef std::pair<ui::MenuModel*,int> Entry; 116 typedef std::pair<ui::MenuModel*,int> Entry;
122 typedef std::map<int,Entry> CommandIDToEntry; 117 typedef std::map<int,Entry> CommandIDToEntry;
123 118
124 bool supports_new_separators() const {
125 return (run_flags_ & SUPPORTS_NEW_SEPARATORS) != 0;
126 }
127
128 // Populates |parent| with all the child menus in |model|. Recursively invokes 119 // Populates |parent| with all the child menus in |model|. Recursively invokes
129 // |PopulateMenu| for any submenu. 120 // |PopulateMenu| for any submenu.
130 void PopulateMenu(views::MenuItemView* parent, 121 void PopulateMenu(views::MenuItemView* parent,
131 ui::MenuModel* model); 122 ui::MenuModel* model);
132 123
133 // Adds a new menu item to |parent| at |menu_index| to represent the item in 124 // Adds a new menu item to |parent| at |menu_index| to represent the item in
134 // |model| at |model_index|: 125 // |model| at |model_index|:
135 // - |menu_index|: position in |parent| to add the new item. 126 // - |menu_index|: position in |parent| to add the new item.
136 // - |model_index|: position in |model| to retrieve information about the 127 // - |model_index|: position in |model| to retrieve information about the
137 // new menu item. 128 // new menu item.
138 // - |height|: For button containing menu items, a |height| override can be
139 // specified with a number bigger then 0.
140 // The returned item's MenuItemView::GetCommand() is the same as that of 129 // The returned item's MenuItemView::GetCommand() is the same as that of
141 // |model|->GetCommandIdAt(|model_index|). 130 // |model|->GetCommandIdAt(|model_index|).
142 views::MenuItemView* AddMenuItem(views::MenuItemView* parent, 131 views::MenuItemView* AddMenuItem(views::MenuItemView* parent,
143 int menu_index, 132 int menu_index,
144 ui::MenuModel* model, 133 ui::MenuModel* model,
145 int model_index, 134 int model_index,
146 ui::MenuModel::ItemType menu_type, 135 ui::MenuModel::ItemType menu_type);
147 int height);
148 136
149 // Invoked from the cut/copy/paste menus. Cancels the current active menu and 137 // Invoked from the cut/copy/paste menus. Cancels the current active menu and
150 // activates the menu item in |model| at |index|. 138 // activates the menu item in |model| at |index|.
151 void CancelAndEvaluate(ui::MenuModel* model, int index); 139 void CancelAndEvaluate(ui::MenuModel* model, int index);
152 140
153 // Creates the bookmark menu if necessary. Does nothing if already created or 141 // Creates the bookmark menu if necessary. Does nothing if already created or
154 // the bookmark model isn't loaded. 142 // the bookmark model isn't loaded.
155 void CreateBookmarkMenu(); 143 void CreateBookmarkMenu();
156 144
157 // Returns the index of the MenuModel/index pair representing the |command_id| 145 // Returns the index of the MenuModel/index pair representing the |command_id|
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 181
194 // The bit mask of RunFlags. 182 // The bit mask of RunFlags.
195 const int run_flags_; 183 const int run_flags_;
196 184
197 ObserverList<WrenchMenuObserver> observer_list_; 185 ObserverList<WrenchMenuObserver> observer_list_;
198 186
199 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); 187 DISALLOW_COPY_AND_ASSIGN(WrenchMenu);
200 }; 188 };
201 189
202 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ 190 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_view.cc ('k') | chrome/browser/ui/views/toolbar/wrench_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698