Chromium Code Reviews| 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(); |
| } |