OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ | 5 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ |
6 #define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ | 6 #define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 class BookmarkNode; | 12 class BookmarkNode; |
13 | 13 |
14 namespace bookmarks { | 14 namespace bookmarks { |
15 class BookmarkModel; | 15 class BookmarkModel; |
16 } | 16 } |
17 | 17 |
18 namespace enhanced_bookmarks { | 18 namespace enhanced_bookmarks { |
19 | 19 |
| 20 static const char kLaunchLocationUMA[] = "Stars.LaunchLocation"; |
| 21 |
| 22 // Possible locations where a bookmark can be opened from. |
| 23 // Please sync with the corresponding histograms.xml. |
| 24 // |
| 25 // A Java counterpart will be generated for this enum. |
| 26 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.enhancedbookmark |
| 27 enum LaunchLocation { |
| 28 ALL_ITEMS = 0, |
| 29 UNCATEGORIZED = 1, // Deprecated. |
| 30 FOLDER = 2, |
| 31 FILTER = 3, |
| 32 SEARCH = 4, |
| 33 BOOKMARK_EDITOR = 5, |
| 34 COUNT = 6, |
| 35 }; |
| 36 |
20 // The vector is sorted in place. | 37 // The vector is sorted in place. |
21 // All of the bookmarks in |nodes| must be urls. | 38 // All of the bookmarks in |nodes| must be urls. |
22 void SortBookmarksByName(std::vector<const BookmarkNode*>& nodes); | 39 void SortBookmarksByName(std::vector<const BookmarkNode*>& nodes); |
23 | 40 |
24 // Returns the permanent nodes whose url children are considered uncategorized | 41 // Returns the permanent nodes whose url children are considered uncategorized |
25 // and whose folder children should be shown in the bookmark menu. | 42 // and whose folder children should be shown in the bookmark menu. |
26 // |model| must be loaded. | 43 // |model| must be loaded. |
27 std::vector<const BookmarkNode*> PrimaryPermanentNodes( | 44 std::vector<const BookmarkNode*> PrimaryPermanentNodes( |
28 bookmarks::BookmarkModel* model); | 45 bookmarks::BookmarkModel* model); |
29 | 46 |
30 // Returns an unsorted vector of folders that are considered to be at the "root" | 47 // Returns an unsorted vector of folders that are considered to be at the "root" |
31 // level of the bookmark hierarchy. Functionally, this means all direct | 48 // level of the bookmark hierarchy. Functionally, this means all direct |
32 // descendants of PrimaryPermanentNodes. | 49 // descendants of PrimaryPermanentNodes. |
33 std::vector<const BookmarkNode*> RootLevelFolders( | 50 std::vector<const BookmarkNode*> RootLevelFolders( |
34 bookmarks::BookmarkModel* model); | 51 bookmarks::BookmarkModel* model); |
35 | 52 |
36 // Returns whether |node| is a primary permanent node in the sense of | 53 // Returns whether |node| is a primary permanent node in the sense of |
37 // |PrimaryPermanentNodes|. | 54 // |PrimaryPermanentNodes|. |
38 bool IsPrimaryPermanentNode(const BookmarkNode* node, | 55 bool IsPrimaryPermanentNode(const BookmarkNode* node, |
39 bookmarks::BookmarkModel* model); | 56 bookmarks::BookmarkModel* model); |
40 | 57 |
41 // Returns the root level folder in which this node is directly, or indirectly | 58 // Returns the root level folder in which this node is directly, or indirectly |
42 // via subfolders, located. | 59 // via subfolders, located. |
43 const BookmarkNode* RootLevelFolderForNode(const BookmarkNode* node, | 60 const BookmarkNode* RootLevelFolderForNode(const BookmarkNode* node, |
44 bookmarks::BookmarkModel* model); | 61 bookmarks::BookmarkModel* model); |
45 | 62 |
46 } // namespace enhanced_bookmarks | 63 } // namespace enhanced_bookmarks |
47 | 64 |
48 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ | 65 #endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ |
OLD | NEW |