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

Side by Side Diff: chrome/browser/autocomplete/history_provider.cc

Issue 77453007: Omnibox: Make HistoryURL Highlight Titles like HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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 #include "chrome/browser/autocomplete/history_provider.h" 5 #include "chrome/browser/autocomplete/history_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/autocomplete/autocomplete_input.h" 11 #include "chrome/browser/autocomplete/autocomplete_input.h"
12 #include "chrome/browser/autocomplete/autocomplete_match.h" 12 #include "chrome/browser/autocomplete/autocomplete_match.h"
13 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 13 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
14 #include "chrome/browser/history/history_service.h" 14 #include "chrome/browser/history/history_service.h"
15 #include "chrome/browser/history/history_service_factory.h" 15 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/history/in_memory_url_index_types.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/net/url_fixer_upper.h" 18 #include "chrome/common/net/url_fixer_upper.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "url/url_util.h" 20 #include "url/url_util.h"
20 21
21 HistoryProvider::HistoryProvider(AutocompleteProviderListener* listener, 22 HistoryProvider::HistoryProvider(AutocompleteProviderListener* listener,
22 Profile* profile, 23 Profile* profile,
23 AutocompleteProvider::Type type) 24 AutocompleteProvider::Type type)
24 : AutocompleteProvider(listener, profile, type) { 25 : AutocompleteProvider(listener, profile, type) {
25 } 26 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return (scheme_pos == 0) ? prefix_end : 0; 151 return (scheme_pos == 0) ? prefix_end : 0;
151 } 152 }
152 153
153 // static 154 // static
154 bool HistoryProvider::PreventInlineAutocomplete( 155 bool HistoryProvider::PreventInlineAutocomplete(
155 const AutocompleteInput& input) { 156 const AutocompleteInput& input) {
156 return input.prevent_inline_autocomplete() || 157 return input.prevent_inline_autocomplete() ||
157 (!input.text().empty() && 158 (!input.text().empty() &&
158 IsWhitespace(input.text()[input.text().length() - 1])); 159 IsWhitespace(input.text()[input.text().length() - 1]));
159 } 160 }
161
162 // static
163 ACMatchClassifications HistoryProvider::SpansFromTermMatch(
164 const history::TermMatches& matches,
165 size_t text_length,
166 bool is_url) {
167 ACMatchClassification::Style url_style =
168 is_url ? ACMatchClassification::URL : ACMatchClassification::NONE;
169 ACMatchClassifications spans;
170 if (matches.empty()) {
171 if (text_length)
172 spans.push_back(ACMatchClassification(0, url_style));
173 return spans;
174 }
175 if (matches[0].offset)
176 spans.push_back(ACMatchClassification(0, url_style));
177 size_t match_count = matches.size();
178 for (size_t i = 0; i < match_count;) {
179 size_t offset = matches[i].offset;
180 spans.push_back(ACMatchClassification(offset,
181 ACMatchClassification::MATCH | url_style));
182 // Skip all adjacent matches.
183 do {
184 offset += matches[i].length;
185 ++i;
186 } while ((i < match_count) && (offset == matches[i].offset));
187 if (offset < text_length)
188 spans.push_back(ACMatchClassification(offset, url_style));
189 }
190
191 return spans;
192 }
193
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_provider.h ('k') | chrome/browser/autocomplete/history_quick_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698