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

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

Issue 6334017: Always allow exact match non-substituting keywords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update. Created 9 years, 11 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/keyword_provider.cc
diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc
index 10cf328dacb9dfeac3a4dc54d80f7f8504041518..97ccc5c036e1a6d10607426aeee468d0f6a07d48 100644
--- a/chrome/browser/autocomplete/keyword_provider.cc
+++ b/chrome/browser/autocomplete/keyword_provider.cc
@@ -365,15 +365,15 @@ void KeywordProvider::FillInURLAndContents(
// static
int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type,
bool complete,
- bool no_query_text_needed,
+ bool supports_replacement,
+ bool prefer_keyword,
bool allow_exact_keyword_match) {
if (!complete)
return (type == AutocompleteInput::URL) ? 700 : 450;
- if (!allow_exact_keyword_match)
- return 1100;
- if (no_query_text_needed)
+ if (!supports_replacement || (allow_exact_keyword_match && prefer_keyword))
return 1500;
- return (type == AutocompleteInput::QUERY) ? 1450 : 1100;
+ return (allow_exact_keyword_match && (type == AutocompleteInput::QUERY)) ?
+ 1450 : 1100;
}
AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
@@ -400,7 +400,7 @@ AutocompleteMatch KeywordProvider::CreateAutocompleteMatch(
// When the user wants keyword matches to take
// preference, score them highly regardless of
// whether the input provides query text.
- input.prefer_keyword() || !supports_replacement,
+ supports_replacement, input.prefer_keyword(),
input.allow_exact_keyword_match());
}
AutocompleteMatch result(this, relevance, false,
@@ -494,7 +494,7 @@ void KeywordProvider::Observe(NotificationType type,
// and subtract 1 for each subsequent suggestion from the extension.
// We know that |complete| is true, because we wouldn't get results from
// the extension unless the full keyword had been typed.
- int first_relevance = CalculateRelevance(input.type(), true,
+ int first_relevance = CalculateRelevance(input.type(), true, true,
input.prefer_keyword(), input.allow_exact_keyword_match());
extension_suggest_matches_.push_back(CreateAutocompleteMatch(
model, keyword, input, keyword.length(),

Powered by Google App Engine
This is Rietveld 408576698