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 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/utf_offset_string_conversions.h" | 12 #include "base/strings/utf_offset_string_conversions.h" |
13 #include "components/bookmarks/browser/bookmark_node_data.h" | 13 #include "components/bookmarks/browser/bookmark_node_data.h" |
14 | 14 |
15 class BookmarkClient; | |
15 class BookmarkModel; | 16 class BookmarkModel; |
16 class BookmarkNode; | 17 class BookmarkNode; |
17 class GURL; | 18 class GURL; |
18 | 19 |
19 namespace user_prefs { | 20 namespace user_prefs { |
20 class PrefRegistrySyncable; | 21 class PrefRegistrySyncable; |
21 } | 22 } |
22 | 23 |
23 // A collection of bookmark utility functions used by various parts of the UI | 24 // A collection of bookmark utility functions used by various parts of the UI |
24 // that show bookmarks (bookmark manager, bookmark bar view, ...) and other | 25 // that show bookmarks (bookmark manager, bookmark bar view, ...) and other |
(...skipping 28 matching lines...) Expand all Loading... | |
53 bool remove_nodes); | 54 bool remove_nodes); |
54 | 55 |
55 // Pastes from the clipboard. The new nodes are added to |parent|, unless | 56 // 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 | 57 // |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. | 58 // at |index|. If |index| is -1 the nodes are added to the end. |
58 void PasteFromClipboard(BookmarkModel* model, | 59 void PasteFromClipboard(BookmarkModel* model, |
59 const BookmarkNode* parent, | 60 const BookmarkNode* parent, |
60 int index); | 61 int index); |
61 | 62 |
62 // Returns true if the user can copy from the pasteboard. | 63 // Returns true if the user can copy from the pasteboard. |
63 bool CanPasteFromClipboard(const BookmarkNode* node); | 64 bool CanPasteFromClipboard(BookmarkModel* model, const BookmarkNode* node); |
64 | 65 |
65 // Returns a vector containing up to |max_count| of the most recently modified | 66 // Returns a vector containing up to |max_count| of the most recently modified |
66 // folders. This never returns an empty vector. | 67 // user folders. This never returns an empty vector. |
67 std::vector<const BookmarkNode*> GetMostRecentlyModifiedFolders( | 68 std::vector<const BookmarkNode*> GetMostRecentlyModifiedUserFolders( |
68 BookmarkModel* model, size_t max_count); | 69 BookmarkModel* model, size_t max_count); |
69 | 70 |
70 // Returns the most recently added bookmarks. This does not return folders, | 71 // Returns the most recently added bookmarks. This does not return folders, |
71 // only nodes of type url. | 72 // only nodes of type url. |
72 void GetMostRecentlyAddedEntries(BookmarkModel* model, | 73 void GetMostRecentlyAddedEntries(BookmarkModel* model, |
73 size_t count, | 74 size_t count, |
74 std::vector<const BookmarkNode*>* nodes); | 75 std::vector<const BookmarkNode*>* nodes); |
75 | 76 |
76 // Returns true if |n1| was added more recently than |n2|. | 77 // Returns true if |n1| was added more recently than |n2|. |
77 bool MoreRecentlyAdded(const BookmarkNode* n1, const BookmarkNode* n2); | 78 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 | 95 // |parent| is returned. If |index| is non-null it is set to the index newly |
95 // added nodes should be added at. | 96 // added nodes should be added at. |
96 const BookmarkNode* GetParentForNewNodes( | 97 const BookmarkNode* GetParentForNewNodes( |
97 const BookmarkNode* parent, | 98 const BookmarkNode* parent, |
98 const std::vector<const BookmarkNode*>& selection, | 99 const std::vector<const BookmarkNode*>& selection, |
99 int* index); | 100 int* index); |
100 | 101 |
101 // Deletes the bookmark folders for the given list of |ids|. | 102 // Deletes the bookmark folders for the given list of |ids|. |
102 void DeleteBookmarkFolders(BookmarkModel* model, const std::vector<int64>& ids); | 103 void DeleteBookmarkFolders(BookmarkModel* model, const std::vector<int64>& ids); |
103 | 104 |
104 // If there are no bookmarks for url, a bookmark is created. | 105 // If there are no user bookmarks for url, a bookmark is created. |
105 void AddIfNotBookmarked(BookmarkModel* model, | 106 void AddIfNotBookmarked(BookmarkModel* model, |
106 const GURL& url, | 107 const GURL& url, |
107 const base::string16& title); | 108 const base::string16& title); |
108 | 109 |
109 // Removes all bookmarks for the given |url|. | 110 // Removes all bookmarks for the given |url|. |
110 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); | 111 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); |
111 | 112 |
112 // Truncates an overly-long URL, unescapes it and interprets the characters | 113 // 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 | 114 // as UTF-8 (both via net::FormatUrl()), and lower-cases it, returning the |
114 // result. |languages| is passed to net::FormatUrl(). |adjustments|, if | 115 // result. |languages| is passed to net::FormatUrl(). |adjustments|, if |
(...skipping 14 matching lines...) Expand all Loading... | |
129 // why it was escaped to begin with). | 130 // why it was escaped to begin with). |
130 base::string16 CleanUpUrlForMatching( | 131 base::string16 CleanUpUrlForMatching( |
131 const GURL& gurl, | 132 const GURL& gurl, |
132 const std::string& languages, | 133 const std::string& languages, |
133 base::OffsetAdjuster::Adjustments* adjustments); | 134 base::OffsetAdjuster::Adjustments* adjustments); |
134 | 135 |
135 // Returns the lower-cased title, possibly truncated if the original title | 136 // Returns the lower-cased title, possibly truncated if the original title |
136 // is overly-long. | 137 // is overly-long. |
137 base::string16 CleanUpTitleForMatching(const base::string16& title); | 138 base::string16 CleanUpTitleForMatching(const base::string16& title); |
138 | 139 |
140 // Returns true all the nodes in the |list| can be edited by the user, as | |
sky
2014/06/06 16:29:47
all -> id all
Joao da Silva
2014/06/06 17:46:40
Done.
| |
141 // determined by BookmarkClient::CanBeEditedByUser. | |
sky
2014/06/06 16:29:47
nit: use () when referring to function names in co
Joao da Silva
2014/06/06 17:46:40
Done.
| |
142 bool CanAllBeEditedByUser(BookmarkClient* client, | |
143 const std::vector<const BookmarkNode*>& list); | |
sky
2014/06/06 16:29:47
nit: using the name list for vector is a bit odd.
Joao da Silva
2014/06/06 17:46:40
Done.
| |
144 | |
145 // Returns true if |url| has a bookmark in the |model| that can be edited | |
146 // by the user. | |
147 bool IsBookmarkedByUser(BookmarkModel* model, const GURL& url); | |
148 | |
139 } // namespace bookmark_utils | 149 } // namespace bookmark_utils |
140 | 150 |
141 // Returns the node with |id|, or NULL if there is no node with |id|. | 151 // Returns the node with |id|, or NULL if there is no node with |id|. |
142 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); | 152 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); |
143 | 153 |
144 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ | 154 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ |
OLD | NEW |