blob: 6e585a88bfbc2ceb811ef14d0c26d75e2fe9e10d [file] [log] [blame]
[email protected]6ce7f612012-09-05 23:53:071// 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
3// found in the LICENSE file.
4
5#include "chrome/browser/autocomplete/zero_suggest_provider.h"
6
7#include "base/callback.h"
[email protected]bb1fb2b2013-05-31 00:21:018#include "base/i18n/case_conversion.h"
[email protected]6ce7f612012-09-05 23:53:079#include "base/json/json_string_value_serializer.h"
[email protected]bb1fb2b2013-05-31 00:21:0110#include "base/metrics/histogram.h"
[email protected]3853a4c2013-02-11 17:15:5711#include "base/prefs/pref_service.h"
[email protected]98570e12013-06-10 19:54:2212#include "base/strings/string16.h"
13#include "base/strings/string_util.h"
[email protected]135cb802013-06-09 16:44:2014#include "base/strings/utf_string_conversions.h"
[email protected]4dcb7972013-06-28 15:15:4115#include "base/time/time.h"
[email protected]6ce7f612012-09-05 23:53:0716#include "chrome/browser/autocomplete/autocomplete_input.h"
17#include "chrome/browser/autocomplete/autocomplete_match.h"
18#include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
[email protected]bb1fb2b2013-05-31 00:21:0119#include "chrome/browser/autocomplete/history_url_provider.h"
20#include "chrome/browser/autocomplete/search_provider.h"
21#include "chrome/browser/autocomplete/url_prefix.h"
22#include "chrome/browser/metrics/variations/variations_http_header_provider.h"
23#include "chrome/browser/net/url_fixer_upper.h"
24#include "chrome/browser/omnibox/omnibox_field_trial.h"
[email protected]6ce7f612012-09-05 23:53:0725#include "chrome/browser/profiles/profile.h"
[email protected]bb1fb2b2013-05-31 00:21:0126#include "chrome/browser/search/search.h"
[email protected]6ce7f612012-09-05 23:53:0727#include "chrome/browser/search_engines/template_url_service.h"
28#include "chrome/browser/search_engines/template_url_service_factory.h"
[email protected]bb1fb2b2013-05-31 00:21:0129#include "chrome/browser/sync/profile_sync_service.h"
30#include "chrome/browser/sync/profile_sync_service_factory.h"
[email protected]a00008d42012-09-15 05:07:5831#include "chrome/common/pref_names.h"
[email protected]6ce7f612012-09-05 23:53:0732#include "chrome/common/url_constants.h"
[email protected]bb1fb2b2013-05-31 00:21:0133#include "net/base/escape.h"
[email protected]6ce7f612012-09-05 23:53:0734#include "net/base/load_flags.h"
[email protected]bb1fb2b2013-05-31 00:21:0135#include "net/base/net_util.h"
36#include "net/http/http_request_headers.h"
[email protected]6ce7f612012-09-05 23:53:0737#include "net/http/http_response_headers.h"
38#include "net/url_request/url_fetcher.h"
39#include "net/url_request/url_request_status.h"
[email protected]761fa4702013-07-02 15:25:1540#include "url/gurl.h"
[email protected]6ce7f612012-09-05 23:53:0741
42namespace {
[email protected]bb1fb2b2013-05-31 00:21:0143
44// TODO(hfung): The histogram code was copied and modified from
45// search_provider.cc. Refactor and consolidate the code.
46// We keep track in a histogram how many suggest requests we send, how
47// many suggest requests we invalidate (e.g., due to a user typing
48// another character), and how many replies we receive.
49// *** ADD NEW ENUMS AFTER ALL PREVIOUSLY DEFINED ONES! ***
50// (excluding the end-of-list enum value)
51// We do not want values of existing enums to change or else it screws
52// up the statistics.
53enum ZeroSuggestRequestsHistogramValue {
54 ZERO_SUGGEST_REQUEST_SENT = 1,
55 ZERO_SUGGEST_REQUEST_INVALIDATED,
56 ZERO_SUGGEST_REPLY_RECEIVED,
57 ZERO_SUGGEST_MAX_REQUEST_HISTOGRAM_VALUE
58};
59
60void LogOmniboxZeroSuggestRequest(
61 ZeroSuggestRequestsHistogramValue request_value) {
62 UMA_HISTOGRAM_ENUMERATION("Omnibox.ZeroSuggestRequests", request_value,
63 ZERO_SUGGEST_MAX_REQUEST_HISTOGRAM_VALUE);
64}
65
66// The maximum relevance of the top match from this provider.
67const int kDefaultVerbatimZeroSuggestRelevance = 1300;
68
69// Relevance value to use if it was not set explicitly by the server.
70const int kDefaultZeroSuggestRelevance = 100;
71
[email protected]6ce7f612012-09-05 23:53:0772} // namespace
73
[email protected]a00008d42012-09-15 05:07:5874// static
75ZeroSuggestProvider* ZeroSuggestProvider::Create(
76 AutocompleteProviderListener* listener,
77 Profile* profile) {
[email protected]bb1fb2b2013-05-31 00:21:0178 return new ZeroSuggestProvider(listener, profile);
[email protected]6ce7f612012-09-05 23:53:0779}
80
[email protected]6ce7f612012-09-05 23:53:0781void ZeroSuggestProvider::Start(const AutocompleteInput& input,
82 bool /*minimal_changes*/) {
[email protected]bb1fb2b2013-05-31 00:21:0183}
84
85void ZeroSuggestProvider::Stop(bool clear_cached_results) {
86 if (have_pending_request_)
87 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_INVALIDATED);
88 have_pending_request_ = false;
89 fetcher_.reset();
90 done_ = true;
91 if (clear_cached_results) {
92 query_matches_map_.clear();
93 navigation_results_.clear();
94 current_query_.clear();
95 matches_.clear();
96 }
97}
98
99void ZeroSuggestProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
100 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo());
101 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back();
102 new_entry.set_provider(AsOmniboxEventProviderType());
103 new_entry.set_provider_done(done_);
104 std::vector<uint32> field_trial_hashes;
105 OmniboxFieldTrial::GetActiveSuggestFieldTrialHashes(&field_trial_hashes);
106 for (size_t i = 0; i < field_trial_hashes.size(); ++i) {
107 if (field_trial_triggered_)
108 new_entry.mutable_field_trial_triggered()->Add(field_trial_hashes[i]);
109 if (field_trial_triggered_in_session_) {
110 new_entry.mutable_field_trial_triggered_in_session()->Add(
111 field_trial_hashes[i]);
112 }
113 }
114}
115
116void ZeroSuggestProvider::ResetSession() {
117 // The user has started editing in the omnibox, so leave
118 // |field_trial_triggered_in_session_| unchanged and set
119 // |field_trial_triggered_| to false since zero suggest is inactive now.
120 field_trial_triggered_ = false;
[email protected]9c97f89c2013-06-25 03:12:16121 Stop(true);
[email protected]bb1fb2b2013-05-31 00:21:01122}
123
124void ZeroSuggestProvider::OnURLFetchComplete(const net::URLFetcher* source) {
125 have_pending_request_ = false;
126 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REPLY_RECEIVED);
127
128 std::string json_data;
129 source->GetResponseAsString(&json_data);
130 const bool request_succeeded =
131 source->GetStatus().is_success() && source->GetResponseCode() == 200;
132
133 bool have_results = false;
134 if (request_succeeded) {
135 JSONStringValueSerializer deserializer(json_data);
136 deserializer.set_allow_trailing_comma(true);
137 scoped_ptr<Value> data(deserializer.Deserialize(NULL, NULL));
138 if (data.get()) {
139 ParseSuggestResults(*data.get());
140 have_results = !query_matches_map_.empty() ||
141 !navigation_results_.empty();
142 }
143 }
144 done_ = true;
145
146 if (have_results) {
[email protected]9c97f89c2013-06-25 03:12:16147 ConvertResultsToAutocompleteMatches();
[email protected]bb1fb2b2013-05-31 00:21:01148 listener_->OnProviderUpdate(true);
149 }
[email protected]6ce7f612012-09-05 23:53:07150}
151
152void ZeroSuggestProvider::StartZeroSuggest(const GURL& url,
[email protected]2a959a642013-06-13 22:30:48153 const string16& permanent_text) {
[email protected]bb1fb2b2013-05-31 00:21:01154 Stop(true);
155 field_trial_triggered_ = false;
156 field_trial_triggered_in_session_ = false;
157 if (!ShouldRunZeroSuggest(url))
[email protected]6ce7f612012-09-05 23:53:07158 return;
[email protected]bb1fb2b2013-05-31 00:21:01159 verbatim_relevance_ = kDefaultVerbatimZeroSuggestRelevance;
[email protected]6ce7f612012-09-05 23:53:07160 done_ = false;
[email protected]2a959a642013-06-13 22:30:48161 permanent_text_ = permanent_text;
[email protected]6ce7f612012-09-05 23:53:07162 current_query_ = url.spec();
[email protected]bb1fb2b2013-05-31 00:21:01163 current_url_match_ = MatchForCurrentURL();
[email protected]6ce7f612012-09-05 23:53:07164 // TODO(jered): Consider adding locally-sourced zero-suggestions here too.
165 // These may be useful on the NTP or more relevant to the user than server
166 // suggestions, if based on local browsing history.
167 Run();
168}
169
[email protected]bb1fb2b2013-05-31 00:21:01170ZeroSuggestProvider::ZeroSuggestProvider(
171 AutocompleteProviderListener* listener,
172 Profile* profile)
173 : AutocompleteProvider(listener, profile,
174 AutocompleteProvider::TYPE_ZERO_SUGGEST),
175 template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)),
[email protected]bb1fb2b2013-05-31 00:21:01176 have_pending_request_(false),
177 verbatim_relevance_(kDefaultVerbatimZeroSuggestRelevance),
178 field_trial_triggered_(false),
179 field_trial_triggered_in_session_(false) {
[email protected]6ce7f612012-09-05 23:53:07180}
181
182ZeroSuggestProvider::~ZeroSuggestProvider() {
183}
184
[email protected]bb1fb2b2013-05-31 00:21:01185bool ZeroSuggestProvider::ShouldRunZeroSuggest(const GURL& url) const {
186 if (!url.is_valid())
[email protected]6ce7f612012-09-05 23:53:07187 return false;
188
[email protected]bb1fb2b2013-05-31 00:21:01189 // Do not query non-http URLs. There will be no useful suggestions for https
190 // or chrome URLs.
191 if (url.scheme() != chrome::kHttpScheme)
192 return false;
[email protected]6ce7f612012-09-05 23:53:07193
[email protected]bb1fb2b2013-05-31 00:21:01194 // Don't enable ZeroSuggest until InstantExtended works with ZeroSuggest.
195 if (chrome::IsInstantExtendedAPIEnabled())
196 return false;
197
198 // Don't run if there's no profile or in incognito mode.
199 if (profile_ == NULL || profile_->IsOffTheRecord())
200 return false;
201
202 // Don't run if we can't get preferences or search suggest is not enabled.
203 PrefService* prefs = profile_->GetPrefs();
204 if (prefs == NULL || !prefs->GetBoolean(prefs::kSearchSuggestEnabled))
205 return false;
206
207 ProfileSyncService* service =
208 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
209 browser_sync::SyncPrefs sync_prefs(prefs);
210 // The user has needs to have Chrome Sync enabled (for permissions to
211 // transmit their current URL) and be in the field trial.
212 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() ||
213 service == NULL ||
214 !service->IsSyncEnabledAndLoggedIn() ||
215 !sync_prefs.HasKeepEverythingSynced()) {
216 return false;
217 }
[email protected]6ce7f612012-09-05 23:53:07218 return true;
219}
220
[email protected]bb1fb2b2013-05-31 00:21:01221void ZeroSuggestProvider::FillResults(
222 const Value& root_val,
223 int* verbatim_relevance,
224 SearchProvider::SuggestResults* suggest_results,
225 SearchProvider::NavigationResults* navigation_results) {
226 string16 query;
227 const ListValue* root_list = NULL;
228 const ListValue* results = NULL;
229 const ListValue* relevances = NULL;
230 // The response includes the query, which should be empty for ZeroSuggest
231 // responses.
232 if (!root_val.GetAsList(&root_list) || !root_list->GetString(0, &query) ||
233 (!query.empty()) || !root_list->GetList(1, &results))
234 return;
235
236 // 3rd element: Description list.
237 const ListValue* descriptions = NULL;
238 root_list->GetList(2, &descriptions);
239
240 // 4th element: Disregard the query URL list for now.
241
242 // Reset suggested relevance information from the provider.
243 *verbatim_relevance = kDefaultVerbatimZeroSuggestRelevance;
244
245 // 5th element: Optional key-value pairs from the Suggest server.
246 const ListValue* types = NULL;
247 const DictionaryValue* extras = NULL;
248 if (root_list->GetDictionary(4, &extras)) {
249 extras->GetList("google:suggesttype", &types);
250
251 // Discard this list if its size does not match that of the suggestions.
252 if (extras->GetList("google:suggestrelevance", &relevances) &&
253 relevances->GetSize() != results->GetSize())
254 relevances = NULL;
255 extras->GetInteger("google:verbatimrelevance", verbatim_relevance);
256
257 // Check if the active suggest field trial (if any) has triggered.
258 bool triggered = false;
259 extras->GetBoolean("google:fieldtrialtriggered", &triggered);
260 field_trial_triggered_ |= triggered;
261 field_trial_triggered_in_session_ |= triggered;
262 }
263
264 // Clear the previous results now that new results are available.
265 suggest_results->clear();
266 navigation_results->clear();
267
268 string16 result, title;
269 std::string type;
270 for (size_t index = 0; results->GetString(index, &result); ++index) {
271 // Google search may return empty suggestions for weird input characters,
272 // they make no sense at all and can cause problems in our code.
273 if (result.empty())
274 continue;
275
276 int relevance = kDefaultZeroSuggestRelevance;
277
278 // Apply valid suggested relevance scores; discard invalid lists.
279 if (relevances != NULL && !relevances->GetInteger(index, &relevance))
280 relevances = NULL;
281 if (types && types->GetString(index, &type) && (type == "NAVIGATION")) {
282 // Do not blindly trust the URL coming from the server to be valid.
283 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(result), std::string()));
284 if (url.is_valid()) {
285 if (descriptions != NULL)
286 descriptions->GetString(index, &title);
287 navigation_results->push_back(SearchProvider::NavigationResult(
[email protected]d30268a2013-06-25 22:31:07288 *this, url, title, false, relevance, relevances != NULL));
[email protected]bb1fb2b2013-05-31 00:21:01289 }
290 } else {
291 suggest_results->push_back(SearchProvider::SuggestResult(
[email protected]d30268a2013-06-25 22:31:07292 result, false, relevance, relevances != NULL));
[email protected]bb1fb2b2013-05-31 00:21:01293 }
294 }
295}
296
297void ZeroSuggestProvider::AddSuggestResultsToMap(
298 const SearchProvider::SuggestResults& results,
[email protected]bba9e632013-06-28 22:52:19299 const TemplateURL* template_url,
[email protected]bb1fb2b2013-05-31 00:21:01300 SearchProvider::MatchMap* map) {
301 for (size_t i = 0; i < results.size(); ++i) {
[email protected]bba9e632013-06-28 22:52:19302 AddMatchToMap(results[i].relevance(), AutocompleteMatchType::SEARCH_SUGGEST,
303 template_url, results[i].suggestion(), i, map);
[email protected]bb1fb2b2013-05-31 00:21:01304 }
305}
306
[email protected]bba9e632013-06-28 22:52:19307void ZeroSuggestProvider::AddMatchToMap(int relevance,
[email protected]bb1fb2b2013-05-31 00:21:01308 AutocompleteMatch::Type type,
[email protected]bba9e632013-06-28 22:52:19309 const TemplateURL* template_url,
310 const string16& query_string,
[email protected]bb1fb2b2013-05-31 00:21:01311 int accepted_suggestion,
312 SearchProvider::MatchMap* map) {
313 // Pass in query_string as the input_text since we don't want any bolding.
[email protected]f3e46eec2013-06-11 14:46:28314 // TODO(samarth|melevin): use the actual omnibox margin here as well instead
315 // of passing in -1.
[email protected]bb1fb2b2013-05-31 00:21:01316 AutocompleteMatch match = SearchProvider::CreateSearchSuggestion(
[email protected]bba9e632013-06-28 22:52:19317 this, relevance, type, template_url, query_string, query_string,
318 AutocompleteInput(), false, accepted_suggestion, -1);
[email protected]bb1fb2b2013-05-31 00:21:01319 if (!match.destination_url.is_valid())
320 return;
321
322 // Try to add |match| to |map|. If a match for |query_string| is already in
323 // |map|, replace it if |match| is more relevant.
324 // NOTE: Keep this ToLower() call in sync with url_database.cc.
[email protected]bc8bb0cd2013-06-24 21:50:23325 const std::pair<SearchProvider::MatchMap::iterator, bool> i(map->insert(
326 std::make_pair(base::i18n::ToLower(query_string), match)));
[email protected]bb1fb2b2013-05-31 00:21:01327 // NOTE: We purposefully do a direct relevance comparison here instead of
328 // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items added
329 // first" rather than "items alphabetically first" when the scores are equal.
330 // The only case this matters is when a user has results with the same score
331 // that differ only by capitalization; because the history system returns
332 // results sorted by recency, this means we'll pick the most recent such
333 // result even if the precision of our relevance score is too low to
334 // distinguish the two.
335 if (!i.second && (match.relevance > i.first->second.relevance))
336 i.first->second = match;
337}
338
339AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
340 const SearchProvider::NavigationResult& navigation) {
341 AutocompleteMatch match(this, navigation.relevance(), false,
342 AutocompleteMatchType::NAVSUGGEST);
343 match.destination_url = navigation.url();
344
345 const std::string languages(
346 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
347 match.contents = net::FormatUrl(navigation.url(), languages,
348 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, NULL);
349 match.fill_into_edit +=
350 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url(),
351 match.contents);
352 match.inline_autocomplete_offset = string16::npos;
353
354 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0,
355 match.contents.length(), ACMatchClassification::URL,
356 &match.contents_class);
[email protected]9c97f89c2013-06-25 03:12:16357
358 match.description =
359 AutocompleteMatch::SanitizeString(navigation.description());
360 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0,
361 match.description.length(), ACMatchClassification::NONE,
362 &match.description_class);
[email protected]bb1fb2b2013-05-31 00:21:01363 return match;
364}
365
366void ZeroSuggestProvider::Run() {
367 have_pending_request_ = false;
368 const int kFetcherID = 1;
369
370 const TemplateURL* default_provider =
371 template_url_service_->GetDefaultSearchProvider();
372 // TODO(hfung): Generalize if the default provider supports zero suggest.
373 // Only make the request if we know that the provider supports zero suggest
374 // (currently only the prepopulated Google provider).
375 if (default_provider == NULL || !default_provider->SupportsReplacement() ||
376 default_provider->prepopulate_id() != 1) {
377 Stop(true);
378 return;
379 }
380 string16 prefix;
381 TemplateURLRef::SearchTermsArgs search_term_args(prefix);
382 search_term_args.zero_prefix_url = current_query_;
383 std::string req_url = default_provider->suggestions_url_ref().
384 ReplaceSearchTerms(search_term_args);
385 GURL suggest_url(req_url);
386 // Make sure we are sending the suggest request through HTTPS.
387 if (!suggest_url.SchemeIs(chrome::kHttpsScheme)) {
388 Stop(true);
389 return;
390 }
391
392 fetcher_.reset(
393 net::URLFetcher::Create(kFetcherID,
394 suggest_url,
395 net::URLFetcher::GET, this));
396 fetcher_->SetRequestContext(profile_->GetRequestContext());
397 fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES);
398 // Add Chrome experiment state to the request headers.
399 net::HttpRequestHeaders headers;
400 chrome_variations::VariationsHttpHeaderProvider::GetInstance()->AppendHeaders(
401 fetcher_->GetOriginalURL(), profile_->IsOffTheRecord(), false, &headers);
402 fetcher_->SetExtraRequestHeaders(headers.ToString());
403
404 fetcher_->Start();
405 have_pending_request_ = true;
406 LogOmniboxZeroSuggestRequest(ZERO_SUGGEST_REQUEST_SENT);
407}
408
[email protected]bb1fb2b2013-05-31 00:21:01409void ZeroSuggestProvider::ParseSuggestResults(const Value& root_val) {
410 SearchProvider::SuggestResults suggest_results;
411 FillResults(root_val, &verbatim_relevance_,
412 &suggest_results, &navigation_results_);
413
414 query_matches_map_.clear();
[email protected]bba9e632013-06-28 22:52:19415 AddSuggestResultsToMap(suggest_results,
416 template_url_service_->GetDefaultSearchProvider(),
[email protected]bb1fb2b2013-05-31 00:21:01417 &query_matches_map_);
418}
419
[email protected]9c97f89c2013-06-25 03:12:16420void ZeroSuggestProvider::ConvertResultsToAutocompleteMatches() {
[email protected]bb1fb2b2013-05-31 00:21:01421 matches_.clear();
422
423 const TemplateURL* default_provider =
[email protected]6ce7f612012-09-05 23:53:07424 template_url_service_->GetDefaultSearchProvider();
425 // Fail if we can't set the clickthrough URL for query suggestions.
[email protected]bb1fb2b2013-05-31 00:21:01426 if (default_provider == NULL || !default_provider->SupportsReplacement())
[email protected]6ce7f612012-09-05 23:53:07427 return;
[email protected]6ce7f612012-09-05 23:53:07428
[email protected]bb1fb2b2013-05-31 00:21:01429 const int num_query_results = query_matches_map_.size();
430 const int num_nav_results = navigation_results_.size();
431 const int num_results = num_query_results + num_nav_results;
[email protected]9c97f89c2013-06-25 03:12:16432 UMA_HISTOGRAM_COUNTS("ZeroSuggest.QueryResults", num_query_results);
433 UMA_HISTOGRAM_COUNTS("ZeroSuggest.URLResults", num_nav_results);
434 UMA_HISTOGRAM_COUNTS("ZeroSuggest.AllResults", num_results);
[email protected]bb1fb2b2013-05-31 00:21:01435
[email protected]9c97f89c2013-06-25 03:12:16436 if (num_results == 0)
[email protected]bb1fb2b2013-05-31 00:21:01437 return;
438
439 // TODO(jered): Rip this out once the first match is decoupled from the
440 // current typing in the omnibox.
[email protected]bb1fb2b2013-05-31 00:21:01441 matches_.push_back(current_url_match_);
442
[email protected]bc8bb0cd2013-06-24 21:50:23443 for (SearchProvider::MatchMap::const_iterator it(query_matches_map_.begin());
444 it != query_matches_map_.end(); ++it)
[email protected]bb1fb2b2013-05-31 00:21:01445 matches_.push_back(it->second);
[email protected]bb1fb2b2013-05-31 00:21:01446
[email protected]bc8bb0cd2013-06-24 21:50:23447 for (SearchProvider::NavigationResults::const_iterator it(
448 navigation_results_.begin()); it != navigation_results_.end(); ++it)
[email protected]bb1fb2b2013-05-31 00:21:01449 matches_.push_back(NavigationToMatch(*it));
[email protected]6ce7f612012-09-05 23:53:07450}
451
[email protected]bb1fb2b2013-05-31 00:21:01452AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() {
[email protected]2a959a642013-06-13 22:30:48453 AutocompleteInput input(permanent_text_, string16::npos,
[email protected]bb1fb2b2013-05-31 00:21:01454 string16(), GURL(current_query_),
455 false, false, true, AutocompleteInput::ALL_MATCHES);
[email protected]6ce7f612012-09-05 23:53:07456
[email protected]bb1fb2b2013-05-31 00:21:01457 AutocompleteMatch match(
[email protected]2a959a642013-06-13 22:30:48458 HistoryURLProvider::SuggestExactInput(this, input,
459 !HasHTTPScheme(input.text())));
[email protected]bb1fb2b2013-05-31 00:21:01460 match.is_history_what_you_typed_match = false;
[email protected]9c97f89c2013-06-25 03:12:16461 match.inline_autocomplete_offset = string16::npos;
[email protected]6ce7f612012-09-05 23:53:07462
[email protected]bb1fb2b2013-05-31 00:21:01463 // The placeholder suggestion for the current URL has high relevance so
464 // that it is in the first suggestion slot and inline autocompleted. It
465 // gets dropped as soon as the user types something.
466 match.relevance = verbatim_relevance_;
[email protected]6ce7f612012-09-05 23:53:07467
[email protected]bb1fb2b2013-05-31 00:21:01468 return match;
[email protected]6ce7f612012-09-05 23:53:07469}