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

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

Issue 476263002: Omnibox - Search Provider - Cleanup Keyword Mode's Legal Matches (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mike's comments 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
Index: chrome/browser/autocomplete/base_search_provider.cc
diff --git a/chrome/browser/autocomplete/base_search_provider.cc b/chrome/browser/autocomplete/base_search_provider.cc
index 29a6ac0c7225ee38eb04a4322b8c999aae250402..cab4a27fb82b73812cbe417c37556ceafb83db27 100644
--- a/chrome/browser/autocomplete/base_search_provider.cc
+++ b/chrome/browser/autocomplete/base_search_provider.cc
@@ -110,6 +110,10 @@ bool BaseSearchProvider::ShouldPrefetch(const AutocompleteMatch& match) {
}
// static
+// This wrapper uses a number of default values that may or may not be
msw 2014/08/15 19:06:06 This comment is valuable, but belongs integrated w
Mark P 2014/08/15 19:14:49 Done.
+// appropriate for your needs. For instance, it assumes that if this match
+// is from a keyword provider than the user is in keyword mode.
+// See warning by this function's declaration in the header file.
AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
const base::string16& suggestion,
AutocompleteMatchType::Type type,
@@ -117,7 +121,8 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
const TemplateURL* template_url,
const SearchTermsData& search_terms_data) {
return CreateSearchSuggestion(
- NULL, AutocompleteInput(), SearchSuggestionParser::SuggestResult(
+ NULL, AutocompleteInput(), from_keyword_provider,
+ SearchSuggestionParser::SuggestResult(
suggestion, type, suggestion, base::string16(), base::string16(),
base::string16(), base::string16(), std::string(), std::string(),
from_keyword_provider, 0, false, false, base::string16()),
@@ -208,6 +213,7 @@ void BaseSearchProvider::SetDeletionURL(const std::string& deletion_url,
AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
AutocompleteProvider* autocomplete_provider,
const AutocompleteInput& input,
+ const bool in_keyword_mode,
const SearchSuggestionParser::SuggestResult& suggestion,
const TemplateURL* template_url,
const SearchTermsData& search_terms_data,
@@ -240,6 +246,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
// suggestion.match_contents() should have already been collapsed.
match.allowed_to_be_default_match =
+ (!in_keyword_mode || suggestion.from_keyword_provider()) &&
(base::CollapseWhitespace(input.text(), false) ==
suggestion.match_contents());
@@ -251,6 +258,7 @@ AutocompleteMatch BaseSearchProvider::CreateSearchSuggestion(
if (suggestion.from_keyword_provider())
match.fill_into_edit.append(match.keyword + base::char16(' '));
if (!input.prevent_inline_autocomplete() &&
+ (!in_keyword_mode || suggestion.from_keyword_provider()) &&
StartsWith(suggestion.suggestion(), input.text(), false)) {
match.inline_autocompletion =
suggestion.suggestion().substr(input.text().length());
@@ -370,9 +378,10 @@ void BaseSearchProvider::AddMatchToMap(
const std::string& metadata,
int accepted_suggestion,
bool mark_as_deletable,
+ bool in_keyword_mode,
MatchMap* map) {
AutocompleteMatch match = CreateSearchSuggestion(
- this, GetInput(result.from_keyword_provider()), result,
+ this, GetInput(result.from_keyword_provider()), in_keyword_mode, result,
GetTemplateURL(result.from_keyword_provider()),
template_url_service_->search_terms_data(), accepted_suggestion,
ShouldAppendExtraParams(result));

Powered by Google App Engine
This is Rietveld 408576698