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

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

Issue 18878007: Omnibox: Make the Controller Reorder Matches for Inlining (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Peter's comments Created 7 years, 5 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/shortcuts_provider.cc
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc
index cf121be0bd3a49eefebb8635c947d4decd04ccb9..d993d30eabe50be4eba4c786c9563ec7d59ebc16 100644
--- a/chrome/browser/autocomplete/shortcuts_provider.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider.cc
@@ -55,7 +55,9 @@ ShortcutsProvider::ShortcutsProvider(AutocompleteProviderListener* listener,
AutocompleteProvider::TYPE_SHORTCUTS),
languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)),
initialized_(false),
- max_relevance_(AutocompleteResult::kLowestDefaultScore - 1) {
+ max_relevance_(AutocompleteResult::kLowestDefaultScore - 1),
+ omnibox_will_reorder_for_legal_default_match_(
+ OmniboxFieldTrial::InReorderForLegalDefaultMatchGroup()) {
scoped_refptr<history::ShortcutsBackend> backend =
ShortcutsBackendFactory::GetForProfile(profile_);
if (backend.get()) {
@@ -174,15 +176,20 @@ void ShortcutsProvider::GetMatches(const AutocompleteInput& input) {
matches_.erase(matches_.begin() + AutocompleteProvider::kMaxMatches,
matches_.end());
}
- // Reset relevance scores to guarantee no results are given an
- // inlineable score and all scores are decreasing (but not do assign
- // any scores below 1).
- int max_relevance = AutocompleteResult::kLowestDefaultScore - 1;
- for (ACMatches::iterator it = matches_.begin(); it != matches_.end(); ++it) {
- max_relevance = std::min(max_relevance, it->relevance);
- it->relevance = max_relevance;
- if (max_relevance > 1)
- --max_relevance;
+ // Reset relevance scores to guarantee no result is given a score that
+ // may allow it to become the highest ranked matches (= default match)
msw 2013/07/18 06:23:57 nit: s/matches/match, also s/=/i.e. the/
Mark P 2013/07/21 20:31:05 Done.
+ // unless the omnibox will reorder matches as necessary to correct the
+ // problem. In the process of resetting scores, guarantee that all scores
+ // are decreasing (but not do assign any scores below 1).
+ if (!omnibox_will_reorder_for_legal_default_match_) {
+ int max_relevance = AutocompleteResult::kLowestDefaultScore - 1;
+ for (ACMatches::iterator it = matches_.begin(); it != matches_.end();
+ ++it) {
+ max_relevance = std::min(max_relevance, it->relevance);
+ it->relevance = max_relevance;
+ if (max_relevance > 1)
+ --max_relevance;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698