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

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

Issue 490383002: Loosen DCHECK for Omnibox Extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more polish Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1acd38da7ab059c60abff4f37560e55698b16fc3 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -409,10 +409,15 @@ 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();
+ const bool is_extension_keyword = (keyword_url != NULL) &&
+ (keyword_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION);
+ if ((keyword_url != NULL) && !is_extension_keyword &&
(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 +432,17 @@ 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 (!is_extension_keyword && (FindTopMatch() == matches_.end())) {
+ // Guarantee that SearchProvider returns a legal default match (except
+ // when in extension-based keyword mode). The omnibox always needs 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(is_extension_keyword || (FindTopMatch() != matches_.end()));
}
UMA_HISTOGRAM_CUSTOM_COUNTS(
"Omnibox.SearchProviderMatches", matches_.size(), 1, 6, 7);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698