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

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

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

Powered by Google App Engine
This is Rietveld 408576698