Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: chrome/browser/bookmarks/bookmark_utils.h

Issue 255423002: Omnibox: Highlight Matches in URLs Properly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter's comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 interprets the characters
113 // returning the result. This unescaping makes it possible to match 114 // as UTF-8 (both via net::FormatUrl()), and lower-cases it, returning the
114 // substrings that were originally escaped for navigation; for 115 // result. |languages| is passed to net::FormatUrl(). |adjustments|, if
115 // example, if the user searched for "a&p", the query would be escaped 116 // non-NULL, is set to reflect the transformations the URL spec underwent to
116 // as "a%26p", so without unescaping, an input string of "a&p" would 117 // become the return value. If a caller computes offsets (e.g., for the
117 // no longer match this URL. Note that the resulting unescaped URL 118 // position of matched text) in this cleaned-up string, it can use
118 // may not be directly navigable (which is why we escaped it to begin 119 // |adjustments| to calculate the location of these offsets in the original
119 // with). |languages| is passed to net::FormatUrl(). 120 // string. Precisely, the caller should use base::OffsetAdjuster::
120 base::string16 CleanUpUrlForMatching(const GURL& gurl, 121 // UnadjustOffsets() to reverse the transformation specified by |adjustments|
121 const std::string& languages); 122 // to translate offsets in the adjusted string to offsets in the original
123 // string.
Peter Kasting 2014/04/24 21:00:52 You've expanded the comment here, but by adding mo
Mark P 2014/04/24 23:05:17 Done.
124 //
125 // The unescaping done by this function makes it possible to match substrings
126 // that were originally escaped for navigation; for example, if the user
127 // searched for "a&p", the query would be escaped as "a%26p", so without
128 // unescaping, an input string of "a&p" would no longer match this URL. Note
129 // that the resulting unescaped URL may not be directly navigable (which is
130 // why it was escaped to begin with).
131 base::string16 CleanUpUrlForMatching(
132 const GURL& gurl,
133 const std::string& languages,
134 base::OffsetAdjuster::Adjustments* adjustments);
122 135
123 // Returns the lower-cased title, possibly truncated if the original title 136 // Returns the lower-cased title, possibly truncated if the original title
124 // is overly-long. 137 // is overly-long.
125 base::string16 CleanUpTitleForMatching(const base::string16& title); 138 base::string16 CleanUpTitleForMatching(const base::string16& title);
126 139
127 } // namespace bookmark_utils 140 } // namespace bookmark_utils
128 141
129 // Returns the node with |id|, or NULL if there is no node with |id|. 142 // Returns the node with |id|, or NULL if there is no node with |id|.
130 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id); 143 const BookmarkNode* GetBookmarkNodeByID(const BookmarkModel* model, int64 id);
131 144
132 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_ 145 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698