| 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_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ |
| 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 bool remove_nodes); | 53 bool remove_nodes); |
| 54 | 54 |
| 55 // Pastes from the clipboard. The new nodes are added to |parent|, unless | 55 // Pastes from the clipboard. The new nodes are added to |parent|, unless |
| 56 // |parent| is null in which case this does nothing. The nodes are inserted | 56 // |parent| is null in which case this does nothing. The nodes are inserted |
| 57 // at |index|. If |index| is -1 the nodes are added to the end. | 57 // at |index|. If |index| is -1 the nodes are added to the end. |
| 58 void PasteFromClipboard(BookmarkModel* model, | 58 void PasteFromClipboard(BookmarkModel* model, |
| 59 const BookmarkNode* parent, | 59 const BookmarkNode* parent, |
| 60 int index); | 60 int index); |
| 61 | 61 |
| 62 // Returns true if the user can copy from the pasteboard. | 62 // Returns true if the user can copy from the pasteboard. |
| 63 bool CanPasteFromClipboard(const BookmarkNode* node); | 63 bool CanPasteFromClipboard(BookmarkModel* model, const BookmarkNode* node); |
| 64 | 64 |
| 65 // Returns a vector containing up to |max_count| of the most recently modified | 65 // Returns a vector containing up to |max_count| of the most recently modified |
| 66 // folders. This never returns an empty vector. | 66 // user folders. This never returns an empty vector. |
| 67 std::vector<const BookmarkNode*> GetMostRecentlyModifiedFolders( | 67 std::vector<const BookmarkNode*> GetMostRecentlyModifiedUserFolders( |
| 68 BookmarkModel* model, size_t max_count); | 68 BookmarkModel* model, size_t max_count); |
| 69 | 69 |
| 70 // Returns the most recently added bookmarks. This does not return folders, | 70 // Returns the most recently added bookmarks. This does not return folders, |
| 71 // only nodes of type url. | 71 // only nodes of type url. |
| 72 void GetMostRecentlyAddedEntries(BookmarkModel* model, | 72 void GetMostRecentlyAddedEntries(BookmarkModel* model, |
| 73 size_t count, | 73 size_t count, |
| 74 std::vector<const BookmarkNode*>* nodes); | 74 std::vector<const BookmarkNode*>* nodes); |
| 75 | 75 |
| 76 // Returns true if |n1| was added more recently than |n2|. | 76 // Returns true if |n1| was added more recently than |n2|. |
| 77 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2); | 77 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 94 // |parent| is returned. If |index| is non-null it is set to the index newly | 94 // |parent| is returned. If |index| is non-null it is set to the index newly |
| 95 // added nodes should be added at. | 95 // added nodes should be added at. |
| 96 const BookmarkNode* GetParentForNewNodes( | 96 const BookmarkNode* GetParentForNewNodes( |
| 97 const BookmarkNode* parent, | 97 const BookmarkNode* parent, |
| 98 const std::vector<const BookmarkNode*>& selection, | 98 const std::vector<const BookmarkNode*>& selection, |
| 99 int* index); | 99 int* index); |
| 100 | 100 |
| 101 // Deletes the bookmark folders for the given list of |ids|. | 101 // Deletes the bookmark folders for the given list of |ids|. |
| 102 void DeleteBookmarkFolders(BookmarkModel* model, const std::vector<int64>& ids); | 102 void DeleteBookmarkFolders(BookmarkModel* model, const std::vector<int64>& ids); |
| 103 | 103 |
| 104 // If there are no bookmarks for url, a bookmark is created. | 104 // If there are no user bookmarks for url, a bookmark is created. |
| 105 void AddIfNotBookmarked(BookmarkModel* model, | 105 void AddIfNotBookmarked(BookmarkModel* model, |
| 106 const GURL& url, | 106 const GURL& url, |
| 107 const base::string16& title); | 107 const base::string16& title); |
| 108 | 108 |
| 109 // Removes all bookmarks for the given |url|. | 109 // Removes all bookmarks for the given |url|. |
| 110 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); | 110 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); |
| 111 | 111 |
| 112 // Truncates an overly-long URL, unescapes it and interprets the characters | 112 // Truncates an overly-long URL, unescapes it and interprets the characters |
| 113 // as UTF-8 (both via net::FormatUrl()), and lower-cases it, returning the | 113 // as UTF-8 (both via net::FormatUrl()), and lower-cases it, returning the |
| 114 // result. |languages| is passed to net::FormatUrl(). |adjustments|, if | 114 // result. |languages| is passed to net::FormatUrl(). |adjustments|, if |
| (...skipping 20 matching lines...) Expand all Loading... |
| 135 // Returns the lower-cased title, possibly truncated if the original title | 135 // Returns the lower-cased title, possibly truncated if the original title |
| 136 // is overly-long. | 136 // is overly-long. |
| 137 base::string16 CleanUpTitleForMatching(const base::string16& title); | 137 base::string16 CleanUpTitleForMatching(const base::string16& title); |
| 138 | 138 |
| 139 } // namespace bookmark_utils | 139 } // namespace bookmark_utils |
| 140 | 140 |
| 141 // Returns the node with |id|, or NULL if there is no node with |id|. | 141 // Returns the node with |id|, or NULL if there is no node with |id|. |
| 142 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); | 142 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); |
| 143 | 143 |
| 144 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ | 144 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ |
| OLD | NEW |