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

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

Issue 8776025: Makes views show the 'mobile' bookmark folder where appropriate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 20 matching lines...) Expand all
31 31
32 // BookmarkMenuDelegate acts as the (informal) views::MenuDelegate for showing 32 // BookmarkMenuDelegate acts as the (informal) views::MenuDelegate for showing
33 // bookmarks in a MenuItemView. BookmarkMenuDelegate informally implements 33 // bookmarks in a MenuItemView. BookmarkMenuDelegate informally implements
34 // MenuDelegate as its assumed another class is going to forward the appropriate 34 // MenuDelegate as its assumed another class is going to forward the appropriate
35 // methods to this class. Doing so allows this class to be used for both menus 35 // methods to this class. Doing so allows this class to be used for both menus
36 // on the bookmark bar and the bookmarks in the wrench menu. 36 // on the bookmark bar and the bookmarks in the wrench menu.
37 class BookmarkMenuDelegate : public BaseBookmarkModelObserver, 37 class BookmarkMenuDelegate : public BaseBookmarkModelObserver,
38 public BookmarkContextMenuObserver { 38 public BookmarkContextMenuObserver {
39 public: 39 public:
40 enum ShowOptions { 40 enum ShowOptions {
41 // Indicates a menu should be added containing the 'other' bookmarks folder 41 // Indicates a menu should be added containing the permanent folders (other
42 // and all its contents. This only makes sense when showing the contents 42 // than then bookmark bar folder). This only makes sense when showing the
43 // of the bookmark folder. 43 // contents of the bookmark bar folder.
44 SHOW_OTHER_FOLDER, 44 SHOW_PERMANENT_FOLDERS,
45 45
46 // Don't show the 'other' bookmarks folder. 46 // Don't show any additional folders.
47 HIDE_OTHER_FOLDER 47 HIDE_PERMANENT_FOLDERS
48 }; 48 };
49 49
50 BookmarkMenuDelegate(Profile* profile, 50 BookmarkMenuDelegate(Profile* profile,
51 PageNavigator* navigator, 51 PageNavigator* navigator,
52 views::Widget* parent, 52 views::Widget* parent,
53 int first_menu_id); 53 int first_menu_id);
54 virtual ~BookmarkMenuDelegate(); 54 virtual ~BookmarkMenuDelegate();
55 55
56 // Creates the menus from the model. 56 // Creates the menus from the model.
57 void Init(views::MenuDelegate* real_delegate, 57 void Init(views::MenuDelegate* real_delegate,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 typedef std::map<int, const BookmarkNode*> MenuIDToNodeMap; 127 typedef std::map<int, const BookmarkNode*> MenuIDToNodeMap;
128 typedef std::map<const BookmarkNode*, int> NodeToMenuIDMap; 128 typedef std::map<const BookmarkNode*, int> NodeToMenuIDMap;
129 typedef std::map<const BookmarkNode*, views::MenuItemView*> NodeToMenuMap; 129 typedef std::map<const BookmarkNode*, views::MenuItemView*> NodeToMenuMap;
130 130
131 // Creates a menu and adds it to node_to_menu_id_map_. This uses 131 // Creates a menu and adds it to node_to_menu_id_map_. This uses
132 // BuildMenu to recursively populate the menu. 132 // BuildMenu to recursively populate the menu.
133 views::MenuItemView* CreateMenu(const BookmarkNode* parent, 133 views::MenuItemView* CreateMenu(const BookmarkNode* parent,
134 int start_child_index, 134 int start_child_index,
135 ShowOptions show_options); 135 ShowOptions show_options);
136 136
137 // Builds the menu for the other bookmarks folder. This is added as the last 137 // Invokes BuildMenuForPermanentNode() for the permanent nodes (excluding
138 // item to menu_. 138 // 'other bookmarks' folder).
139 void BuildOtherFolderMenu(views::MenuItemView* menu, int* next_menu_id); 139 void BuildMenusForPermanentNodes(views::MenuItemView* menu,
140 int* next_menu_id);
141
142 // If |node| has children a new menu is created and added to |menu| to
143 // represent it. If |node| is not empty and |added_separator| is false, a
144 // separator is added before the new menu items and |added_separator| is set
145 // to true.
146 void BuildMenuForPermanentNode(const BookmarkNode* node,
147 views::MenuItemView* menu,
148 int* next_menu_id,
149 bool* added_separator);
140 150
141 // Creates an entry in menu for each child node of |parent| starting at 151 // Creates an entry in menu for each child node of |parent| starting at
142 // |start_child_index|. 152 // |start_child_index|.
143 void BuildMenu(const BookmarkNode* parent, 153 void BuildMenu(const BookmarkNode* parent,
144 int start_child_index, 154 int start_child_index,
145 views::MenuItemView* menu, 155 views::MenuItemView* menu,
146 int* next_menu_id); 156 int* next_menu_id);
147 157
148 // Returns the menu whose id is |id|. 158 // Returns the menu whose id is |id|.
149 views::MenuItemView* GetMenuByID(int id); 159 views::MenuItemView* GetMenuByID(int id);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // Is the model being changed? 198 // Is the model being changed?
189 bool is_mutating_model_; 199 bool is_mutating_model_;
190 200
191 // The location where this bookmark menu will be displayed (for UMA). 201 // The location where this bookmark menu will be displayed (for UMA).
192 bookmark_utils::BookmarkLaunchLocation location_; 202 bookmark_utils::BookmarkLaunchLocation location_;
193 203
194 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuDelegate); 204 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuDelegate);
195 }; 205 };
196 206
197 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_ 207 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698