| 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 "components/omnibox/browser/zero_suggest_provider.h" | 5 #include "components/omnibox/browser/zero_suggest_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 AddMatchToMap(results[i], std::string(), i, false, false, map); | 368 AddMatchToMap(results[i], std::string(), i, false, false, map); |
| 369 } | 369 } |
| 370 | 370 |
| 371 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch( | 371 AutocompleteMatch ZeroSuggestProvider::NavigationToMatch( |
| 372 const SearchSuggestionParser::NavigationResult& navigation) { | 372 const SearchSuggestionParser::NavigationResult& navigation) { |
| 373 AutocompleteMatch match(this, navigation.relevance(), false, | 373 AutocompleteMatch match(this, navigation.relevance(), false, |
| 374 navigation.type()); | 374 navigation.type()); |
| 375 match.destination_url = navigation.url(); | 375 match.destination_url = navigation.url(); |
| 376 | 376 |
| 377 // Zero suggest results should always omit protocols and never appear bold. | 377 // Zero suggest results should always omit protocols and never appear bold. |
| 378 match.contents = AutocompleteMatch::FormatUrlForSuggestionDisplay( | 378 auto format_types = AutocompleteMatch::GetFormatTypes(true); |
| 379 navigation.url(), true /* trim_scheme */, nullptr); | 379 match.contents = url_formatter::FormatUrl(navigation.url(), format_types, |
| 380 net::UnescapeRule::SPACES, nullptr, |
| 381 nullptr, nullptr); |
| 380 match.fill_into_edit += | 382 match.fill_into_edit += |
| 381 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 383 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
| 382 navigation.url(), match.contents, client()->GetSchemeClassifier()); | 384 navigation.url(), match.contents, client()->GetSchemeClassifier()); |
| 383 | 385 |
| 384 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, | 386 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, |
| 385 match.contents.length(), ACMatchClassification::URL, | 387 match.contents.length(), ACMatchClassification::URL, |
| 386 &match.contents_class); | 388 &match.contents_class); |
| 387 | 389 |
| 388 match.description = | 390 match.description = |
| 389 AutocompleteMatch::SanitizeString(navigation.description()); | 391 AutocompleteMatch::SanitizeString(navigation.description()); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if (!json_data.empty()) { | 601 if (!json_data.empty()) { |
| 600 std::unique_ptr<base::Value> data( | 602 std::unique_ptr<base::Value> data( |
| 601 SearchSuggestionParser::DeserializeJsonData(json_data)); | 603 SearchSuggestionParser::DeserializeJsonData(json_data)); |
| 602 if (data && ParseSuggestResults( | 604 if (data && ParseSuggestResults( |
| 603 *data, kDefaultZeroSuggestRelevance, false, &results_)) { | 605 *data, kDefaultZeroSuggestRelevance, false, &results_)) { |
| 604 ConvertResultsToAutocompleteMatches(); | 606 ConvertResultsToAutocompleteMatches(); |
| 605 results_from_cache_ = !matches_.empty(); | 607 results_from_cache_ = !matches_.empty(); |
| 606 } | 608 } |
| 607 } | 609 } |
| 608 } | 610 } |
| OLD | NEW |