Chromium Code Reviews| Index: chrome/browser/autocomplete/keyword_provider.cc |
| diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc |
| index c37da20e228f36040e821a071aecc4df86b70668..e43a092839bd2afb5e150b8844ac8780d2a1cd55 100644 |
| --- a/chrome/browser/autocomplete/keyword_provider.cc |
| +++ b/chrome/browser/autocomplete/keyword_provider.cc |
| @@ -285,14 +285,25 @@ void KeywordProvider::Start(const AutocompleteInput& input, |
| // Any exact match is going to be the highest quality match, and thus at the |
| // front of our vector. |
| if (keyword_matches.front() == keyword) { |
| - const TemplateURL* template_url(model->GetTemplateURLForKeyword(keyword)); |
| + const TemplateURL* template_url = model->GetTemplateURLForKeyword(keyword); |
| + const bool is_extension_keyword = |
| + profile_ && template_url->IsExtensionKeyword(); |
| + |
| + // We only create an exact match if remaining_input is empty or |
| + // if this is an extension keyword; if remaining_input is a non-empty |
| + // non-extension keyword (i.e., we have a regular keyword that |
| + // supports replacement and has extra text following it), then we |
| + // let SearchProvider create the exact (a.k.a. verbatim) match. |
| + if (!remaining_input.empty() && !is_extension_keyword) |
| + return; |
| + |
| // TODO(pkasting): We should probably check that if the user explicitly |
| // typed a scheme, that scheme matches the one in |template_url|. |
| matches_.push_back(CreateAutocompleteMatch(model, keyword, input, |
| keyword.length(), |
| remaining_input, -1)); |
| - if (profile_ && template_url->IsExtensionKeyword()) { |
| + if (is_extension_keyword) { |
| if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { |
| if (template_url->GetExtensionId() != current_keyword_extension_id_) |
| MaybeEndExtensionKeywordMode(); |
| @@ -315,7 +326,8 @@ void KeywordProvider::Start(const AutocompleteInput& input, |
| matches_.push_back(extension_suggest_matches_[i]); |
| matches_.back().relevance = matches_[0].relevance - (i + 1); |
| } |
| - } else if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { |
| + } else if (input.matches_requested() == |
| + AutocompleteInput::ALL_MATCHES) { |
| extension_suggest_last_input_ = input; |
| extension_suggest_matches_.clear(); |
| @@ -330,17 +342,19 @@ void KeywordProvider::Start(const AutocompleteInput& input, |
| done_ = false; |
| } |
| } |
| - } else { |
| - if (keyword_matches.size() > kMaxMatches) { |
| - keyword_matches.erase(keyword_matches.begin() + kMaxMatches, |
| - keyword_matches.end()); |
| - } |
| - for (std::vector<string16>::const_iterator i(keyword_matches.begin()); |
| - i != keyword_matches.end(); ++i) { |
| - matches_.push_back(CreateAutocompleteMatch(model, *i, |
| - input, keyword.length(), |
| - remaining_input, -1)); |
| - } |
| + return; |
| + } |
|
Bart N.
2013/01/30 21:36:21
I think "else" here was probably better than now (
Mark P
2013/01/30 22:19:45
Done.
|
| + |
| + // If we reached here, we have no exact keyword match. |
| + if (keyword_matches.size() > kMaxMatches) { |
| + keyword_matches.erase(keyword_matches.begin() + kMaxMatches, |
| + keyword_matches.end()); |
| + } |
| + for (std::vector<string16>::const_iterator i(keyword_matches.begin()); |
| + i != keyword_matches.end(); ++i) { |
| + matches_.push_back(CreateAutocompleteMatch(model, *i, |
| + input, keyword.length(), |
| + remaining_input, -1)); |
| } |
| } |