summaryrefslogtreecommitdiffstats
path: root/components/enhanced_bookmarks/enhanced_bookmark_utils.h
diff options
context:
space:
mode:
authornoyau@chromium.org <noyau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 19:06:20 +0000
committernoyau@chromium.org <noyau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 19:07:29 +0000
commitce789a9b75ca40d92346187e77cf99b71788fd95 (patch)
tree9242a3021c76d0941d8f6290bc04936b88ff8749 /components/enhanced_bookmarks/enhanced_bookmark_utils.h
parent755211feabeb6e195b7c8486a8a154853d361b6c (diff)
downloadchromium_src-ce789a9b75ca40d92346187e77cf99b71788fd95.zip
chromium_src-ce789a9b75ca40d92346187e77cf99b71788fd95.tar.gz
chromium_src-ce789a9b75ca40d92346187e77cf99b71788fd95.tar.bz2
First implementation of enhanced_bookmark_utils.
These utility functions are used on iOS and Android. BUG=None Review URL: https://codereview.chromium.org/452913002 Cr-Commit-Position: refs/heads/master@{#288408} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/enhanced_bookmarks/enhanced_bookmark_utils.h')
-rw-r--r--components/enhanced_bookmarks/enhanced_bookmark_utils.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/components/enhanced_bookmarks/enhanced_bookmark_utils.h b/components/enhanced_bookmarks/enhanced_bookmark_utils.h
new file mode 100644
index 0000000..54417e1
--- /dev/null
+++ b/components/enhanced_bookmarks/enhanced_bookmark_utils.h
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_
+#define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_
+
+#include <set>
+#include <string>
+#include <vector>
+
+class BookmarkModel;
+class BookmarkNode;
+
+namespace enhanced_bookmark_utils {
+
+// Returns an ordered vector of bookmarks that are urls that match |query|.
+// |query| must be UTF8 encoded.
+std::vector<const BookmarkNode*> FindBookmarksWithQuery(
+ BookmarkModel* bookmark_model,
+ const std::string& query);
+
+// The vector is sorted in place.
+// All of the bookmarks in |nodes| must be urls.
+void SortBookmarksByName(std::vector<const BookmarkNode*>& nodes);
+
+// Returns the permanent nodes whose url children are considered uncategorized
+// and whose folder children should be shown in the bookmark menu.
+// |model| must be loaded.
+std::vector<const BookmarkNode*> PrimaryPermanentNodes(BookmarkModel* model);
+
+// Returns an unsorted vector of folders that are considered to be at the "root"
+// level of the bookmark hierarchy. Functionally, this means all direct
+// descendants of PrimaryPermanentNodes, and possibly a node for the bookmarks
+// bar.
+std::vector<const BookmarkNode*> RootLevelFolders(BookmarkModel* model);
+
+// Returns whether |node| is a primary permanent node in the sense of
+// |PrimaryPermanentNodes|.
+bool IsPrimaryPermanentNode(const BookmarkNode* node, BookmarkModel* model);
+
+// Returns the root level folder in which this node is directly, or indirectly
+// via subfolders, located.
+const BookmarkNode* RootLevelFolderForNode(const BookmarkNode* node,
+ BookmarkModel* model);
+
+} // namespace enhanced_bookmark_utils
+
+#endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_