OLD | NEW |
---|---|
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 // Sets the PageNavigator. | 74 // Sets the PageNavigator. |
75 void SetPageNavigator(content::PageNavigator* navigator); | 75 void SetPageNavigator(content::PageNavigator* navigator); |
76 | 76 |
77 // Returns the id given to the next menu. | 77 // Returns the id given to the next menu. |
78 int next_menu_id() const { return next_menu_id_; } | 78 int next_menu_id() const { return next_menu_id_; } |
79 | 79 |
80 // Makes the menu for |node| the active menu. |start_index| is the index of | 80 // Makes the menu for |node| the active menu. |start_index| is the index of |
81 // the first child of |node| to show in the menu. | 81 // the first child of |node| to show in the menu. |
82 void SetActiveMenu(const bookmarks::BookmarkNode* node, int start_index); | 82 void SetActiveMenu(const bookmarks::BookmarkNode* node, int start_index); |
83 | 83 |
84 bookmarks::BookmarkModel* GetBookmarkModel(); | 84 bookmarks::BookmarkModel* GetBookmarkModel() { |
85 return const_cast<bookmarks::BookmarkModel*>( | |
86 const_cast<const BookmarkMenuDelegate*>(this)->GetBookmarkModel()); | |
87 } | |
88 const bookmarks::BookmarkModel* GetBookmarkModel() const; | |
85 bookmarks::ManagedBookmarkService* GetManagedBookmarkService(); | 89 bookmarks::ManagedBookmarkService* GetManagedBookmarkService(); |
86 | 90 |
87 // Returns the menu. | 91 // Returns the menu. |
88 views::MenuItemView* menu() { return menu_; } | 92 views::MenuItemView* menu() { return menu_; } |
89 | 93 |
90 // Returns the context menu, or NULL if the context menu isn't showing. | 94 // Returns the context menu, or NULL if the context menu isn't showing. |
91 views::MenuItemView* context_menu() { | 95 views::MenuItemView* context_menu() { |
92 return context_menu_.get() ? context_menu_->menu() : NULL; | 96 return context_menu_.get() ? context_menu_->menu() : NULL; |
93 } | 97 } |
94 | 98 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 const std::vector<const bookmarks::BookmarkNode*>& bookmarks) override; | 141 const std::vector<const bookmarks::BookmarkNode*>& bookmarks) override; |
138 void DidRemoveBookmarks() override; | 142 void DidRemoveBookmarks() override; |
139 | 143 |
140 private: | 144 private: |
141 friend class BookmarkMenuDelegateTest; | 145 friend class BookmarkMenuDelegateTest; |
142 | 146 |
143 typedef std::map<int, const bookmarks::BookmarkNode*> MenuIDToNodeMap; | 147 typedef std::map<int, const bookmarks::BookmarkNode*> MenuIDToNodeMap; |
144 typedef std::map<const bookmarks::BookmarkNode*, views::MenuItemView*> | 148 typedef std::map<const bookmarks::BookmarkNode*, views::MenuItemView*> |
145 NodeToMenuMap; | 149 NodeToMenuMap; |
146 | 150 |
151 // Returns the value to supply to creation of BookmarkContextMenu for | |
Devlin
2015/12/29 19:30:04
nit: I think it'd be clearer to describe the meani
sky
2015/12/29 19:38:43
Done.
| |
152 // |close_on_remove|. | |
153 bool ShouldCloseOnRemove(const bookmarks::BookmarkNode* node) const; | |
154 | |
147 // Creates a menu. This uses BuildMenu() to recursively populate the menu. | 155 // Creates a menu. This uses BuildMenu() to recursively populate the menu. |
148 views::MenuItemView* CreateMenu(const bookmarks::BookmarkNode* parent, | 156 views::MenuItemView* CreateMenu(const bookmarks::BookmarkNode* parent, |
149 int start_child_index, | 157 int start_child_index, |
150 ShowOptions show_options); | 158 ShowOptions show_options); |
151 | 159 |
152 // Invokes BuildMenuForPermanentNode() for the permanent nodes (excluding | 160 // Invokes BuildMenuForPermanentNode() for the permanent nodes (excluding |
153 // 'other bookmarks' folder). | 161 // 'other bookmarks' folder). |
154 void BuildMenusForPermanentNodes(views::MenuItemView* menu); | 162 void BuildMenusForPermanentNodes(views::MenuItemView* menu); |
155 | 163 |
156 // If |node| has children a new menu is created and added to |menu| to | 164 // If |node| has children a new menu is created and added to |menu| to |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 // Is the model being changed? | 217 // Is the model being changed? |
210 bool is_mutating_model_; | 218 bool is_mutating_model_; |
211 | 219 |
212 // The location where this bookmark menu will be displayed (for UMA). | 220 // The location where this bookmark menu will be displayed (for UMA). |
213 BookmarkLaunchLocation location_; | 221 BookmarkLaunchLocation location_; |
214 | 222 |
215 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuDelegate); | 223 DISALLOW_COPY_AND_ASSIGN(BookmarkMenuDelegate); |
216 }; | 224 }; |
217 | 225 |
218 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_ | 226 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_MENU_DELEGATE_H_ |
OLD | NEW |