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

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: Lacks -> has 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/shortcuts_provider.cc
diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc
index cf121be0bd3a49eefebb8635c947d4decd04ccb9..30b21a07d2b0aeaedbdc39f6ab4a9482bf1c41cb 100644
--- a/chrome/browser/autocomplete/shortcuts_provider.cc
+++ b/chrome/browser/autocomplete/shortcuts_provider.cc
@@ -174,15 +174,25 @@ 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 match is given a score that may
+ // allow it to become the highest ranked match (i.e., the default match)
+ // unless the omnibox will reorder matches as necessary to correct the
+ // problem. (Shortcuts matches are sometimes not inline-autocompletable
+ // and, even when they are, the KeywordProvider does not bother to set
Peter Kasting 2013/08/09 21:59:34 Nit: Was KeywordProvider intended to be ShortcutsP
Mark P 2013/08/09 22:24:11 Yes. Fixed.
+ // |inline_autocompletion|. Hence these matches can never be displayed
+ // corectly in the omnibox as the default match.) In the process of
+ // resetting scores, guarantee that all scores are decreasing (but do
+ // not assign any scores below 1).
+ if (!OmniboxFieldTrial::ReorderForLegalDefaultMatch(
+ input.current_page_classification())) {
+ 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