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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h

Issue 26350003: OLD: reland "views: change WrenchMenu to use each model's command ID's when creating MenuItemView's" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // contents of the bookmark bar folder. 46 // contents of the bookmark bar folder.
47 SHOW_PERMANENT_FOLDERS, 47 SHOW_PERMANENT_FOLDERS,
48 48
49 // Don't show any additional folders. 49 // Don't show any additional folders.
50 HIDE_PERMANENT_FOLDERS 50 HIDE_PERMANENT_FOLDERS
51 }; 51 };
52 52
53 BookmarkMenuDelegate(Browser* browser, 53 BookmarkMenuDelegate(Browser* browser,
54 content::PageNavigator* navigator, 54 content::PageNavigator* navigator,
55 views::Widget* parent, 55 views::Widget* parent,
56 int first_menu_id); 56 int first_menu_id,
57 int max_menu_id);
57 virtual ~BookmarkMenuDelegate(); 58 virtual ~BookmarkMenuDelegate();
58 59
59 // Creates the menus from the model. 60 // Creates the menus from the model.
60 void Init(views::MenuDelegate* real_delegate, 61 void Init(views::MenuDelegate* real_delegate,
61 views::MenuItemView* parent, 62 views::MenuItemView* parent,
62 const BookmarkNode* node, 63 const BookmarkNode* node,
63 int start_child_index, 64 int start_child_index,
64 ShowOptions show_options, 65 ShowOptions show_options,
65 BookmarkLaunchLocation location); 66 BookmarkLaunchLocation location);
66 67
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 virtual void BookmarkModelChanged() OVERRIDE; 123 virtual void BookmarkModelChanged() OVERRIDE;
123 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model, 124 virtual void BookmarkNodeFaviconChanged(BookmarkModel* model,
124 const BookmarkNode* node) OVERRIDE; 125 const BookmarkNode* node) OVERRIDE;
125 126
126 // BookmarkContextMenu::Observer methods. 127 // BookmarkContextMenu::Observer methods.
127 virtual void WillRemoveBookmarks( 128 virtual void WillRemoveBookmarks(
128 const std::vector<const BookmarkNode*>& bookmarks) OVERRIDE; 129 const std::vector<const BookmarkNode*>& bookmarks) OVERRIDE;
129 virtual void DidRemoveBookmarks() OVERRIDE; 130 virtual void DidRemoveBookmarks() OVERRIDE;
130 131
131 private: 132 private:
133 friend class BookmarkMenuDelegateTest;
134 FRIEND_TEST_ALL_PREFIXES(BookmarkMenuDelegateTest, MaximumAllowed);
135
132 typedef std::map<int, const BookmarkNode*> MenuIDToNodeMap; 136 typedef std::map<int, const BookmarkNode*> MenuIDToNodeMap;
133 typedef std::map<const BookmarkNode*, views::MenuItemView*> NodeToMenuMap; 137 typedef std::map<const BookmarkNode*, views::MenuItemView*> NodeToMenuMap;
134 138
135 // Creates a menu. This uses BuildMenu() to recursively populate the menu. 139 // Creates a menu. This uses BuildMenu() to recursively populate the menu.
136 views::MenuItemView* CreateMenu(const BookmarkNode* parent, 140 views::MenuItemView* CreateMenu(const BookmarkNode* parent,
137 int start_child_index, 141 int start_child_index,
138 ShowOptions show_options); 142 ShowOptions show_options);
139 143
140 // Invokes BuildMenuForPermanentNode() for the permanent nodes (excluding 144 // Invokes BuildMenuForPermanentNode() for the permanent nodes (excluding
141 // 'other bookmarks' folder). 145 // 'other bookmarks' folder).
142 void BuildMenusForPermanentNodes(views::MenuItemView* menu, 146 void BuildMenusForPermanentNodes(views::MenuItemView* menu,
143 int* next_menu_id); 147 int* next_menu_id);
144 148
145 // If |node| has children a new menu is created and added to |menu| to 149 // If |node| has children a new menu is created and added to |menu| to
146 // represent it. If |node| is not empty and |added_separator| is false, a 150 // represent it. If |node| is not empty and |added_separator| is false, a
147 // separator is added before the new menu items and |added_separator| is set 151 // separator is added before the new menu items and |added_separator| is set
148 // to true. 152 // to true.
149 void BuildMenuForPermanentNode(const BookmarkNode* node, 153 void BuildMenuForPermanentNode(const BookmarkNode* node,
150 views::MenuItemView* menu, 154 views::MenuItemView* menu,
151 int* next_menu_id, 155 int* next_menu_id,
152 bool* added_separator); 156 bool* added_separator);
153 157
154 // Creates an entry in menu for each child node of |parent| starting at 158 // Creates an entry in menu for each child node of |parent| starting at
155 // |start_child_index|. 159 // |start_child_index|.
156 void BuildMenu(const BookmarkNode* parent, 160 void BuildMenu(const BookmarkNode* parent,
157 int start_child_index, 161 int start_child_index,
158 views::MenuItemView* menu, 162 views::MenuItemView* menu,
159 int* next_menu_id); 163 int* next_menu_id);
160 164
165 // Returns true if |menu_id_| exceeds the maximum menu ID allowed.
166 bool ExceedsMaximumMenuId(int menu_id) const;
167
161 Browser* browser_; 168 Browser* browser_;
162 Profile* profile_; 169 Profile* profile_;
163 170
164 content::PageNavigator* page_navigator_; 171 content::PageNavigator* page_navigator_;
165 172
166 // Parent of menus. 173 // Parent of menus.
167 views::Widget* parent_; 174 views::Widget* parent_;
168 175
169 // Maps from menu id to BookmarkNode. 176 // Maps from menu id to BookmarkNode.
170 MenuIDToNodeMap menu_id_to_node_map_; 177 MenuIDToNodeMap menu_id_to_node_map_;
(...skipping 12 matching lines...) Expand all
183 190
184 // If non-NULL this is the |parent| passed to Init and is NOT owned by us. 191 // If non-NULL this is the |parent| passed to Init and is NOT owned by us.
185 views::MenuItemView* parent_menu_item_; 192 views::MenuItemView* parent_menu_item_;
186 193
187 // Maps from node to menu. 194 // Maps from node to menu.
188 NodeToMenuMap node_to_menu_map_; 195 NodeToMenuMap node_to_menu_map_;
189 196
190 // ID of the next menu item. 197 // ID of the next menu item.
191 int next_menu_id_; 198 int next_menu_id_;
192 199
200 // Maximum ID to use for menu item.
201 int max_menu_id_;
202
193 views::MenuDelegate* real_delegate_; 203 views::MenuDelegate* real_delegate_;
194 204
195 // Is the model being changed? 205 // Is the model being changed?
196 bool is_mutating_model_; 206 bool is_mutating_model_;
197 207
198 // The location where this bookmark menu will be displayed (for UMA). 208 // The location where this bookmark menu will be displayed (for UMA).
199 BookmarkLaunchLocation location_; 209 BookmarkLaunchLocation location_;
200 210
201 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuDelegate); 211 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuDelegate);
202 }; 212 };
203 213
204 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_ 214 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698