Chromium Code Reviews| Index: chrome/browser/autocomplete/search_provider.cc |
| diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc |
| index c059c6ec2030c57e826980c33907b53beb5e7646..7fd06c3ac4b86be66ed2ae7e7d1e06d70cecc258 100644 |
| --- a/chrome/browser/autocomplete/search_provider.cc |
| +++ b/chrome/browser/autocomplete/search_provider.cc |
| @@ -409,10 +409,14 @@ void SearchProvider::UpdateMatches() { |
| // These blocks attempt to repair undesirable behavior by suggested |
| // relevances with minimal impact, preserving other suggested relevances. |
| - if ((providers_.GetKeywordProviderURL() != NULL) && |
| + const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); |
| + if ((keyword_url != NULL) && |
| + (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION) && |
|
msw
2014/08/22 00:48:00
nit: maybe make a local bool is_extension_keyword?
Mark P
2014/08/22 15:47:06
Good idea. Done.
|
| (FindTopMatch() == matches_.end())) { |
| - // In keyword mode, disregard the keyword verbatim suggested relevance |
| - // if necessary, so at least one match is allowed to be default. |
| + // In non-extension keyword mode, disregard the keyword verbatim suggested |
| + // relevance if necessary, so at least one match is allowed to be default. |
| + // (In extension keyword mode this is not necessary because the extension |
| + // will return a default match.) |
| keyword_results_.verbatim_relevance = -1; |
| ConvertResultsToAutocompleteMatches(); |
| } |
| @@ -427,15 +431,21 @@ void SearchProvider::UpdateMatches() { |
| keyword_results_.verbatim_relevance = -1; |
| ConvertResultsToAutocompleteMatches(); |
| } |
| - if (FindTopMatch() == matches_.end()) { |
| - // Guarantee that SearchProvider returns a legal default match. (The |
| - // omnibox always needs at least one legal default match, and it relies |
| - // on SearchProvider to always return one.) |
| + if ((FindTopMatch() == matches_.end()) && |
| + ((keyword_url == NULL) || |
| + (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION))) { |
| + // Guarantee that SearchProvider returns a legal default match (except |
| + // when in an extension-based keyword mode). The omnibox always needs |
|
Peter Kasting
2014/08/22 00:21:09
Nit: Remove "an"
Mark P
2014/08/22 15:47:06
Done.
|
| + // at least one legal default match, and it relies on SearchProvider in |
| + // combination with KeywordProvider (for extension-based keywords) to |
| + // always return one. |
| ApplyCalculatedRelevance(); |
| ConvertResultsToAutocompleteMatches(); |
| } |
| DCHECK(!IsTopMatchSearchWithURLInput()); |
| - DCHECK(FindTopMatch() != matches_.end()); |
| + DCHECK((FindTopMatch() != matches_.end()) || |
| + ((keyword_url != NULL) && |
| + (keyword_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION))); |
| } |
| UMA_HISTOGRAM_CUSTOM_COUNTS( |
| "Omnibox.SearchProviderMatches", matches_.size(), 1, 6, 7); |