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

Unified Diff: chrome/browser/autocomplete/zero_suggest_provider.cc

Issue 23164011: Omnibox: Reduce Bolding Flicker in SearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: even fancier solution Created 7 years, 4 months 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 side-by-side diff with in-line comments
Download patch
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));

Powered by Google App Engine
This is Rietveld 408576698