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 #include "chrome/browser/autocomplete/zero_suggest_provider.h" | 5 #include "chrome/browser/autocomplete/zero_suggest_provider.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 AutocompleteMatchType::NAVSUGGEST); | 342 AutocompleteMatchType::NAVSUGGEST); |
343 match.destination_url = navigation.url(); | 343 match.destination_url = navigation.url(); |
344 | 344 |
345 const std::string languages( | 345 const std::string languages( |
346 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 346 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
347 match.contents = net::FormatUrl(navigation.url(), languages, | 347 match.contents = net::FormatUrl(navigation.url(), languages, |
348 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, NULL); | 348 net::kFormatUrlOmitAll, net::UnescapeRule::SPACES, NULL, NULL, NULL); |
349 match.fill_into_edit += | 349 match.fill_into_edit += |
350 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url(), | 350 AutocompleteInput::FormattedStringWithEquivalentMeaning(navigation.url(), |
351 match.contents); | 351 match.contents); |
352 match.inline_autocomplete_offset = string16::npos; | |
353 | 352 |
354 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, | 353 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, |
355 match.contents.length(), ACMatchClassification::URL, | 354 match.contents.length(), ACMatchClassification::URL, |
356 &match.contents_class); | 355 &match.contents_class); |
357 | 356 |
358 match.description = | 357 match.description = |
359 AutocompleteMatch::SanitizeString(navigation.description()); | 358 AutocompleteMatch::SanitizeString(navigation.description()); |
360 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, | 359 AutocompleteMatch::ClassifyLocationInString(string16::npos, 0, |
361 match.description.length(), ACMatchClassification::NONE, | 360 match.description.length(), ACMatchClassification::NONE, |
362 &match.description_class); | 361 &match.description_class); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 450 |
452 AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() { | 451 AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() { |
453 AutocompleteInput input(permanent_text_, string16::npos, | 452 AutocompleteInput input(permanent_text_, string16::npos, |
454 string16(), GURL(current_query_), | 453 string16(), GURL(current_query_), |
455 false, false, true, AutocompleteInput::ALL_MATCHES); | 454 false, false, true, AutocompleteInput::ALL_MATCHES); |
456 | 455 |
457 AutocompleteMatch match( | 456 AutocompleteMatch match( |
458 HistoryURLProvider::SuggestExactInput(this, input, | 457 HistoryURLProvider::SuggestExactInput(this, input, |
459 !HasHTTPScheme(input.text()))); | 458 !HasHTTPScheme(input.text()))); |
460 match.is_history_what_you_typed_match = false; | 459 match.is_history_what_you_typed_match = false; |
461 match.inline_autocomplete_offset = string16::npos; | |
462 | 460 |
463 // The placeholder suggestion for the current URL has high relevance so | 461 // The placeholder suggestion for the current URL has high relevance so |
464 // that it is in the first suggestion slot and inline autocompleted. It | 462 // that it is in the first suggestion slot and inline autocompleted. It |
465 // gets dropped as soon as the user types something. | 463 // gets dropped as soon as the user types something. |
466 match.relevance = verbatim_relevance_; | 464 match.relevance = verbatim_relevance_; |
467 | 465 |
468 return match; | 466 return match; |
469 } | 467 } |
OLD | NEW |