| 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..57d9f9cfe384d873b7cf4025eca64cdfd246a815 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;
|
| }
|
|
|
| + // When the user has typed an exact keyword, we want tab-to-search on the
|
| + // default match to select that keyword, even if the match
|
| + // inline-autocompletes to a different keyword. (This prevents inline
|
| + // autocompletions from blocking a user's attempts to use an explicitly-set
|
| + // keyword of their own creation.) So use |exact_keyword| if it's
|
| + // available.
|
| + 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, set a match's associated keyword based on the match's
|
| + // fill_into_edit, which should take inline autocompletions into account.
|
| + 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.
|
| - keyword = match->associated_keyword.get() ?
|
| - match->associated_keyword->keyword :
|
| - keyword_provider_->GetKeywordForText(match->fill_into_edit);
|
| if (!keyword.empty() && !keywords.count(keyword)) {
|
| keywords.insert(keyword);
|
| -
|
| - if (!match->associated_keyword.get())
|
| - 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();
|
| }
|
|
|