OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 IOS_CHROME_BROWSER_BOOKMARKS_BOOKMARKS_UTILS_H_ | 5 #ifndef IOS_CHROME_BROWSER_BOOKMARKS_BOOKMARKS_UTILS_H_ |
6 #define IOS_CHROME_BROWSER_BOOKMARKS_BOOKMARKS_UTILS_H_ | 6 #define IOS_CHROME_BROWSER_BOOKMARKS_BOOKMARKS_UTILS_H_ |
7 | 7 |
| 8 #include <set> |
| 9 #include <vector> |
| 10 |
8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
9 | 12 |
| 13 namespace bookmarks { |
| 14 class BookmarkModel; |
| 15 class BookmarkNode; |
| 16 } |
| 17 |
10 namespace ios { | 18 namespace ios { |
11 class ChromeBrowserState; | 19 class ChromeBrowserState; |
12 } | 20 } |
13 | 21 |
14 // Possible locations where a bookmark can be opened from. | 22 // Possible locations where a bookmark can be opened from. |
15 enum BookmarkLaunchLocation { | 23 enum BookmarkLaunchLocation { |
16 BOOKMARK_LAUNCH_LOCATION_ALL_ITEMS, | 24 BOOKMARK_LAUNCH_LOCATION_ALL_ITEMS, |
17 BOOKMARK_LAUNCH_LOCATION_UNCATEGORIZED_DEPRECATED, | 25 BOOKMARK_LAUNCH_LOCATION_UNCATEGORIZED_DEPRECATED, |
18 BOOKMARK_LAUNCH_LOCATION_FOLDER, | 26 BOOKMARK_LAUNCH_LOCATION_FOLDER, |
19 BOOKMARK_LAUNCH_LOCATION_FILTER_DEPRECATED, | 27 BOOKMARK_LAUNCH_LOCATION_FILTER_DEPRECATED, |
20 BOOKMARK_LAUNCH_LOCATION_SEARCH_DEPRECATED, | 28 BOOKMARK_LAUNCH_LOCATION_SEARCH_DEPRECATED, |
21 BOOKMARK_LAUNCH_LOCATION_BOOKMARK_EDITOR_DEPRECATED, | 29 BOOKMARK_LAUNCH_LOCATION_BOOKMARK_EDITOR_DEPRECATED, |
22 BOOKMARK_LAUNCH_LOCATION_OMNIBOX, | 30 BOOKMARK_LAUNCH_LOCATION_OMNIBOX, |
23 BOOKMARK_LAUNCH_LOCATION_COUNT, | 31 BOOKMARK_LAUNCH_LOCATION_COUNT, |
24 }; | 32 }; |
25 | 33 |
26 // Records the proper metric based on the launch location. | 34 // Records the proper metric based on the launch location. |
27 void RecordBookmarkLaunch(BookmarkLaunchLocation launch_location); | 35 void RecordBookmarkLaunch(BookmarkLaunchLocation launch_location); |
28 | 36 |
29 // Removes all user bookmarks and clears bookmark-related pref. Requires | 37 // Removes all user bookmarks and clears bookmark-related pref. Requires |
30 // bookmark model to be loaded. | 38 // bookmark model to be loaded. |
31 // Return true if the bookmarks were successfully removed and false otherwise. | 39 // Return true if the bookmarks were successfully removed and false otherwise. |
32 bool RemoveAllUserBookmarksIOS(ios::ChromeBrowserState* browser_state) | 40 bool RemoveAllUserBookmarksIOS(ios::ChromeBrowserState* browser_state) |
33 WARN_UNUSED_RESULT; | 41 WARN_UNUSED_RESULT; |
34 | 42 |
| 43 // Returns the permanent nodes whose url children are considered uncategorized |
| 44 // and whose folder children should be shown in the bookmark menu. |
| 45 // |model| must be loaded. |
| 46 std::vector<const bookmarks::BookmarkNode*> PrimaryPermanentNodes( |
| 47 bookmarks::BookmarkModel* model); |
| 48 |
| 49 // Returns an unsorted vector of folders that are considered to be at the "root" |
| 50 // level of the bookmark hierarchy. Functionally, this means all direct |
| 51 // descendants of PrimaryPermanentNodes. |
| 52 std::vector<const bookmarks::BookmarkNode*> RootLevelFolders( |
| 53 bookmarks::BookmarkModel* model); |
| 54 |
| 55 // Returns whether |node| is a primary permanent node in the sense of |
| 56 // |PrimaryPermanentNodes|. |
| 57 bool IsPrimaryPermanentNode(const bookmarks::BookmarkNode* node, |
| 58 bookmarks::BookmarkModel* model); |
| 59 |
| 60 // Returns the root level folder in which this node is directly, or indirectly |
| 61 // via subfolders, located. |
| 62 const bookmarks::BookmarkNode* RootLevelFolderForNode( |
| 63 const bookmarks::BookmarkNode* node, |
| 64 bookmarks::BookmarkModel* model); |
| 65 |
35 #endif // IOS_CHROME_BROWSER_BOOKMARKS_BOOKMARKS_UTILS_H_ | 66 #endif // IOS_CHROME_BROWSER_BOOKMARKS_BOOKMARKS_UTILS_H_ |
OLD | NEW |