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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // If there are no user bookmarks for url, a bookmark is created. | 106 // If there are no user bookmarks for url, a bookmark is created. |
107 void AddIfNotBookmarked(BookmarkModel* model, | 107 void AddIfNotBookmarked(BookmarkModel* model, |
108 const GURL& url, | 108 const GURL& url, |
109 const base::string16& title); | 109 const base::string16& title); |
110 | 110 |
111 // Removes all bookmarks for the given |url|. | 111 // Removes all bookmarks for the given |url|. |
112 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); | 112 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); |
113 | 113 |
114 // Truncates an overly-long URL, unescapes it and interprets the characters | 114 // Truncates an overly-long URL, unescapes it and interprets the characters |
115 // as UTF-8 (both via net::FormatUrl()), and lower-cases it, returning the | 115 // as UTF-8 (both via url_formatter::FormatUrl()), and lower-cases it, returning |
116 // result. |languages| is passed to net::FormatUrl(). |adjustments|, if | 116 // the result. |languages| is passed to url_formatter::FormatUrl(). |
117 // non-NULL, is set to reflect the transformations the URL spec underwent to | 117 // |adjustments|, if non-NULL, is set to reflect the transformations the URL |
118 // become the return value. If a caller computes offsets (e.g., for the | 118 // spec underwent to become the return value. If a caller computes offsets |
119 // position of matched text) in this cleaned-up string, it can use | 119 // (e.g., for the position of matched text) in this cleaned-up string, it can |
120 // |adjustments| to calculate the location of these offsets in the original | 120 // use |adjustments| to calculate the location of these offsets in the original |
121 // string (via base::OffsetAdjuster::UnadjustOffsets()). This is useful if | 121 // string (via base::OffsetAdjuster::UnadjustOffsets()). This is useful if |
122 // later the original string gets formatted in a different way for displaying. | 122 // later the original string gets formatted in a different way for displaying. |
123 // In this case, knowing the offsets in the original string will allow them to | 123 // In this case, knowing the offsets in the original string will allow them to |
124 // be properly translated to offsets in the newly-formatted string. | 124 // be properly translated to offsets in the newly-formatted string. |
125 // | 125 // |
126 // The unescaping done by this function makes it possible to match substrings | 126 // The unescaping done by this function makes it possible to match substrings |
127 // that were originally escaped for navigation; for example, if the user | 127 // that were originally escaped for navigation; for example, if the user |
128 // searched for "a&p", the query would be escaped as "a%26p", so without | 128 // searched for "a&p", the query would be escaped as "a%26p", so without |
129 // unescaping, an input string of "a&p" would no longer match this URL. Note | 129 // unescaping, an input string of "a&p" would no longer match this URL. Note |
130 // that the resulting unescaped URL may not be directly navigable (which is | 130 // that the resulting unescaped URL may not be directly navigable (which is |
(...skipping 22 matching lines...) Expand all Loading... |
153 // Returns true if |node| is a descendant of |root|. | 153 // Returns true if |node| is a descendant of |root|. |
154 bool IsDescendantOf(const BookmarkNode* node, const BookmarkNode* root); | 154 bool IsDescendantOf(const BookmarkNode* node, const BookmarkNode* root); |
155 | 155 |
156 // Returns true if any node in |list| is a descendant of |root|. | 156 // Returns true if any node in |list| is a descendant of |root|. |
157 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, | 157 bool HasDescendantsOf(const std::vector<const BookmarkNode*>& list, |
158 const BookmarkNode* root); | 158 const BookmarkNode* root); |
159 | 159 |
160 } // namespace bookmarks | 160 } // namespace bookmarks |
161 | 161 |
162 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ | 162 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_UTILS_H_ |
OLD | NEW |