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

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

Issue 67693004: Omnibox: Don't Let Users Escape Keyword Mode Accidentally (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/search_provider.cc
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 2e79b08f3841cd8c1562bf669ea5ce13ea10a12b..c484c763afa111c0f2c70e81bd1aafc01b6f292e 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -1208,8 +1208,9 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
std::string(),
&map);
}
+ const TemplateURL* keyword_url = NULL;
if (!keyword_input_.text().empty()) {
- const TemplateURL* keyword_url = providers_.GetKeywordProviderURL();
+ keyword_url = providers_.GetKeywordProviderURL();
// We only create the verbatim search query match for a keyword
// if it's not an extension keyword. Extension keywords are handled
// in KeywordProvider::Start(). (Extensions are complicated...)
@@ -1293,6 +1294,17 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
matches_.push_back(*i);
}
+ if (keyword_url != NULL) {
+ // When in keyword mode, make sure all matches are not associated with the
Peter Kasting 2013/11/15 03:03:34 Nit: are -> that are
Mark P 2013/11/15 17:36:33 Done.
+ // keyword are not allowed to be the default match lest they cause the user
+ // to break out of keyword mode. For reference, non-keyword matches are
+ // queries to the default search engine and navsuggestions from any source.
+ for (ACMatches::iterator it = matches_.begin(); it != matches_.end();
Peter Kasting 2013/11/15 03:03:34 Is this truly the best place for this code? Perha
Mark P 2013/11/15 17:36:33 Yes, I think this is the right place. As you say,
+ ++it) {
+ if (it->keyword != keyword_url->keyword())
+ it->allowed_to_be_default_match = false;
Peter Kasting 2013/11/15 03:03:34 Thought experiment. Let's say the user types an e
Mark P 2013/11/15 17:36:33 What a dang tricky thought experiment. I'm going
+ }
+ }
UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.ConvertResultsTime",
base::TimeTicks::Now() - start_time);
}

Powered by Google App Engine
This is Rietveld 408576698