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 3// found in the LICENSE file. 4 5#ifndef COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ 6#define COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ 7 8#include <set> 9#include <string> 10#include <vector> 11 12class BookmarkModel; 13class BookmarkNode; 14 15namespace enhanced_bookmarks { 16 17// Returns an ordered vector of bookmarks that are urls that match |query|. 18// |query| must be UTF8 encoded. 19std::vector<const BookmarkNode*> FindBookmarksWithQuery( 20 BookmarkModel* bookmark_model, 21 const std::string& query); 22 23// The vector is sorted in place. 24// All of the bookmarks in |nodes| must be urls. 25void SortBookmarksByName(std::vector<const BookmarkNode*>& nodes); 26 27// Returns the permanent nodes whose url children are considered uncategorized 28// and whose folder children should be shown in the bookmark menu. 29// |model| must be loaded. 30std::vector<const BookmarkNode*> PrimaryPermanentNodes(BookmarkModel* model); 31 32// Returns an unsorted vector of folders that are considered to be at the "root" 33// level of the bookmark hierarchy. Functionally, this means all direct 34// descendants of PrimaryPermanentNodes, and possibly a node for the bookmarks 35// bar. 36std::vector<const BookmarkNode*> RootLevelFolders(BookmarkModel* model); 37 38// Returns whether |node| is a primary permanent node in the sense of 39// |PrimaryPermanentNodes|. 40bool IsPrimaryPermanentNode(const BookmarkNode* node, BookmarkModel* model); 41 42// Returns the root level folder in which this node is directly, or indirectly 43// via subfolders, located. 44const BookmarkNode* RootLevelFolderForNode(const BookmarkNode* node, 45 BookmarkModel* model); 46 47} // namespace enhanced_bookmarks 48 49#endif // COMPONENTS_ENHANCED_BOOKMARKS_ENHANCED_BOOKMARK_UTILS_H_ 50