Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_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 "chrome/browser/bookmarks/bookmark_node_data.h" | 13 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 13 | 14 |
| 14 class BookmarkModel; | 15 class BookmarkModel; |
| 15 class BookmarkNode; | 16 class BookmarkNode; |
| 16 class Profile; | 17 class Profile; |
| 17 class GURL; | 18 class GURL; |
| 18 | 19 |
| 19 namespace user_prefs { | 20 namespace user_prefs { |
| 20 class PrefRegistrySyncable; | 21 class PrefRegistrySyncable; |
| 21 } | 22 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 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 lower-cases it, | 113 // Truncates an overly-long URL, unescapes it, and lower-cases it, returning |
| 113 // returning the result. This unescaping makes it possible to match | 114 // the result. |adjustments| is set to reflect the transformations that make |
| 114 // substrings that were originally escaped for navigation; for | 115 // the URL spec underwent to become the return value. This unescaping makes |
|
Peter Kasting
2014/04/23 23:18:01
"that make the URL spec underwent"?
Mark P
2014/04/24 14:05:02
Done.
Also rewrite much of the test of the commen
| |
| 115 // example, if the user searched for "a&p", the query would be escaped | 116 // it possible to match substrings that were originally escaped for navigation; |
| 116 // as "a%26p", so without unescaping, an input string of "a&p" would | 117 // for example, if the user searched for "a&p", the query would be escaped as |
| 117 // no longer match this URL. Note that the resulting unescaped URL | 118 // "a%26p", so without unescaping, an input string of "a&p" would no longer |
| 118 // may not be directly navigable (which is why we escaped it to begin | 119 // match this URL. Note that the resulting unescaped URL may not be directly |
| 119 // with). |languages| is passed to net::FormatUrl(). | 120 // navigable (which is why it was escaped to begin with). |languages| is |
| 120 base::string16 CleanUpUrlForMatching(const GURL& gurl, | 121 // passed to net::FormatUrl(). |
| 121 const std::string& languages); | 122 base::string16 CleanUpUrlForMatching( |
| 123 const GURL& gurl, | |
| 124 const std::string& languages, | |
| 125 base::OffsetAdjuster::Adjustments* adjustments); | |
| 122 | 126 |
| 123 // Returns the lower-cased title, possibly truncated if the original title | 127 // Returns the lower-cased title, possibly truncated if the original title |
| 124 // is overly-long. | 128 // is overly-long. |
| 125 base::string16 CleanUpTitleForMatching(const base::string16& title); | 129 base::string16 CleanUpTitleForMatching(const base::string16& title); |
| 126 | 130 |
| 127 } // namespace bookmark_utils | 131 } // namespace bookmark_utils |
| 128 | 132 |
| 129 // Returns the node with |id|, or NULL if there is no node with |id|. | 133 // Returns the node with |id|, or NULL if there is no node with |id|. |
| 130 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); | 134 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); |
| 131 | 135 |
| 132 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ | 136 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ |
| OLD | NEW |