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 "chrome/browser/bookmarks/bookmark_node_data.h" | 12 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
13 | 13 |
14 class BookmarkModel; | 14 class BookmarkModel; |
15 class BookmarkNode; | 15 class BookmarkNode; |
16 class Profile; | 16 class Profile; |
| 17 class GURL; |
17 | 18 |
18 namespace user_prefs { | 19 namespace user_prefs { |
19 class PrefRegistrySyncable; | 20 class PrefRegistrySyncable; |
20 } | 21 } |
21 | 22 |
22 // A collection of bookmark utility functions used by various parts of the UI | 23 // A collection of bookmark utility functions used by various parts of the UI |
23 // that show bookmarks: bookmark manager, bookmark bar view ... | 24 // that show bookmarks (bookmark manager, bookmark bar view, ...) and other |
| 25 // systems that involve indexing and searching bookmarks. |
24 namespace bookmark_utils { | 26 namespace bookmark_utils { |
25 | 27 |
26 // Fields to use when finding matching bookmarks. | 28 // Fields to use when finding matching bookmarks. |
27 struct QueryFields { | 29 struct QueryFields { |
28 QueryFields(); | 30 QueryFields(); |
29 ~QueryFields(); | 31 ~QueryFields(); |
30 | 32 |
31 scoped_ptr<base::string16> word_phrase_query; | 33 scoped_ptr<base::string16> word_phrase_query; |
32 scoped_ptr<base::string16> url; | 34 scoped_ptr<base::string16> url; |
33 scoped_ptr<base::string16> title; | 35 scoped_ptr<base::string16> title; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void DeleteBookmarkFolders(BookmarkModel* model, const std::vector<int64>& ids); | 102 void DeleteBookmarkFolders(BookmarkModel* model, const std::vector<int64>& ids); |
101 | 103 |
102 // If there are no bookmarks for url, a bookmark is created. | 104 // If there are no bookmarks for url, a bookmark is created. |
103 void AddIfNotBookmarked(BookmarkModel* model, | 105 void AddIfNotBookmarked(BookmarkModel* model, |
104 const GURL& url, | 106 const GURL& url, |
105 const base::string16& title); | 107 const base::string16& title); |
106 | 108 |
107 // Removes all bookmarks for the given |url|. | 109 // Removes all bookmarks for the given |url|. |
108 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); | 110 void RemoveAllBookmarks(BookmarkModel* model, const GURL& url); |
109 | 111 |
| 112 // Truncates an overly-long URL, unescapes it, and lower-cases it, |
| 113 // returning the result. This unescaping makes it possible to match |
| 114 // substrings that were originally escaped for navigation; for |
| 115 // example, if the user searched for "a&p", the query would be escaped |
| 116 // as "a%26p", so without unescaping, an input string of "a&p" would |
| 117 // no longer match this URL. Note that the resulting unescaped URL |
| 118 // may not be directly navigable (which is why we escaped it to begin |
| 119 // with). |languages| is passed to net::FormatUrl(). |
| 120 base::string16 CleanUpUrlForMatching(const GURL& gurl, |
| 121 const std::string& languages); |
| 122 |
| 123 // Returns the lower-cased title, possibly truncated if the original title |
| 124 // is overly-long. |
| 125 base::string16 CleanUpTitleForMatching(const base::string16& title); |
| 126 |
110 } // namespace bookmark_utils | 127 } // namespace bookmark_utils |
111 | 128 |
112 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ | 129 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ |
OLD | NEW |