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

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

Issue 440753003: Omnibox: Make Exact Match Tab-to-Search Work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | chrome/browser/autocomplete/autocomplete_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_controller.cc
diff --git a/chrome/browser/autocomplete/autocomplete_controller.cc b/chrome/browser/autocomplete/autocomplete_controller.cc
index f7771443dc70cf78a6874adce3062993c76f767c..19a87259bc37f91b440874fac01e847c1788f112 100644
--- a/chrome/browser/autocomplete/autocomplete_controller.cc
+++ b/chrome/browser/autocomplete/autocomplete_controller.cc
@@ -504,6 +504,10 @@ void AutocompleteController::UpdateAssociatedKeywords(
if (!keyword_provider_)
return;
+ // Determine if the user's input is an exact keyword match.
+ base::string16 exact_keyword = keyword_provider_->GetKeywordForText(
+ TemplateURLService::CleanUserInputKeyword(input_.text()));
+
std::set<base::string16> keywords;
for (ACMatches::iterator match(result->begin()); match != result->end();
++match) {
@@ -514,18 +518,31 @@ void AutocompleteController::UpdateAssociatedKeywords(
continue;
}
- // Only add the keyword if the match does not have a duplicate keyword with
- // a more relevant match.
+ // If the user has typed an exact keyword and we haven't yet associated
+ // this keyword with some match, ignore whatever keyword (if any) is
+ // already associated with this particular match and let tab-to-search
+ // work for this exact keyword.
Peter Kasting 2014/08/04 21:54:22 Nit: This comment is a bit confusing. How about t
Mark P 2014/08/04 22:05:38 Done.
+ if (!exact_keyword.empty() && !keywords.count(exact_keyword)) {
+ keywords.insert(exact_keyword);
+ match->associated_keyword.reset(new AutocompleteMatch(
+ keyword_provider_->CreateVerbatimMatch(exact_keyword,
+ exact_keyword, input_)));
+ continue;
+ }
+
+ // Otherwise use the particular match's associated keyword, looking it up
+ // if necessary.
keyword = match->associated_keyword.get() ?
match->associated_keyword->keyword :
keyword_provider_->GetKeywordForText(match->fill_into_edit);
+
+ // Only add the keyword if the match does not have a duplicate keyword with
+ // a more relevant match.
if (!keyword.empty() && !keywords.count(keyword)) {
keywords.insert(keyword);
-
- if (!match->associated_keyword.get())
Peter Kasting 2014/08/04 21:54:22 What does removing this conditional do?
Mark P 2014/08/04 22:05:38 I was worried that the copy-old-match code will ke
- match->associated_keyword.reset(new AutocompleteMatch(
- keyword_provider_->CreateVerbatimMatch(match->fill_into_edit,
- keyword, input_)));
+ match->associated_keyword.reset(new AutocompleteMatch(
+ keyword_provider_->CreateVerbatimMatch(match->fill_into_edit,
+ keyword, input_)));
} else {
match->associated_keyword.reset();
}
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698