| Index: chrome/browser/autocomplete/zero_suggest_provider.cc
|
| diff --git a/chrome/browser/autocomplete/zero_suggest_provider.cc b/chrome/browser/autocomplete/zero_suggest_provider.cc
|
| index f19b287574c83496553575720dec031fcca38ad9..fa270cca887e4820d4bf5f68114fcbeab650a8f2 100644
|
| --- a/chrome/browser/autocomplete/zero_suggest_provider.cc
|
| +++ b/chrome/browser/autocomplete/zero_suggest_provider.cc
|
| @@ -274,6 +274,9 @@ void ZeroSuggestProvider::FillResults(
|
|
|
| string16 result, title;
|
| std::string type;
|
| + const string16 current_query_str16 = ASCIIToUTF16(current_query_);
|
| + const std::string& languages =
|
| + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
|
| for (size_t index = 0; results->GetString(index, &result); ++index) {
|
| // Google search may return empty suggestions for weird input characters,
|
| // they make no sense at all and can cause problems in our code.
|
| @@ -292,11 +295,11 @@ void ZeroSuggestProvider::FillResults(
|
| if (descriptions != NULL)
|
| descriptions->GetString(index, &title);
|
| navigation_results->push_back(SearchProvider::NavigationResult(
|
| - *this, url, title, false, relevance, relevances != NULL));
|
| + *this, url, title, false, relevance, relevances != NULL, current_query_str16, languages));
|
| }
|
| } else {
|
| suggest_results->push_back(SearchProvider::SuggestResult(
|
| - result, false, relevance, relevances != NULL));
|
| + result, false, relevance, relevances != NULL, current_query_str16));
|
| }
|
| }
|
| }
|
| @@ -306,23 +309,22 @@ void ZeroSuggestProvider::AddSuggestResultsToMap(
|
| const TemplateURL* template_url,
|
| SearchProvider::MatchMap* map) {
|
| for (size_t i = 0; i < results.size(); ++i) {
|
| - AddMatchToMap(results[i].relevance(), AutocompleteMatchType::SEARCH_SUGGEST,
|
| - template_url, results[i].suggestion(), i, map);
|
| + AddMatchToMap(results[i], AutocompleteMatchType::SEARCH_SUGGEST,
|
| + template_url, i, map);
|
| }
|
| }
|
|
|
| -void ZeroSuggestProvider::AddMatchToMap(int relevance,
|
| +void ZeroSuggestProvider::AddMatchToMap(const SearchProvider::SuggestResult& result,
|
| AutocompleteMatch::Type type,
|
| const TemplateURL* template_url,
|
| - const string16& query_string,
|
| int accepted_suggestion,
|
| SearchProvider::MatchMap* map) {
|
| - // Pass in query_string as the input_text since we don't want any bolding.
|
| + // Pass in result.suggestion() as the input_text since we don't want any bolding.
|
| // TODO(samarth|melevin): use the actual omnibox margin here as well instead
|
| // of passing in -1.
|
| AutocompleteMatch match = SearchProvider::CreateSearchSuggestion(
|
| - this, relevance, type, template_url, query_string, query_string,
|
| - AutocompleteInput(), false, accepted_suggestion, -1, true);
|
| + this, result, type, template_url, result.suggestion(),
|
| + AutocompleteInput(), accepted_suggestion, -1, true);
|
| if (!match.destination_url.is_valid())
|
| return;
|
|
|
| @@ -330,7 +332,7 @@ void ZeroSuggestProvider::AddMatchToMap(int relevance,
|
| // |map|, replace it if |match| is more relevant.
|
| // NOTE: Keep this ToLower() call in sync with url_database.cc.
|
| const std::pair<SearchProvider::MatchMap::iterator, bool> i(map->insert(
|
| - std::make_pair(base::i18n::ToLower(query_string), match)));
|
| + std::make_pair(base::i18n::ToLower(result.suggestion()), match)));
|
| // NOTE: We purposefully do a direct relevance comparison here instead of
|
| // using AutocompleteMatch::MoreRelevant(), so that we'll prefer "items added
|
| // first" rather than "items alphabetically first" when the scores are equal.
|
| @@ -348,6 +350,11 @@ AutocompleteMatch ZeroSuggestProvider::NavigationToMatch(
|
| AutocompleteMatch match(this, navigation.relevance(), false,
|
| AutocompleteMatchType::NAVSUGGEST);
|
| match.destination_url = navigation.url();
|
| + // We ignore navigation.contents() and navigation.contents_class()
|
| + // and instead compute our own contents and contents_class
|
| + // because we want a uniform style of display in zero suggest:
|
| + // no highlighting of URLs (it doesn't matter if the URL shares
|
| + // a prefix with the current URL) and always omit the protocol.
|
|
|
| const std::string languages(
|
| profile_->GetPrefs()->GetString(prefs::kAcceptLanguages));
|
|
|