Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_popup_model.cc |
| diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc |
| index ea8492fe942a66b2e4ec9a927a26a64518f8c98b..0b31ef532524f7f7b7010f4fcfd4a244e4732860 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_popup_model.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc |
| @@ -131,10 +131,29 @@ void AutocompletePopupModel::ResetToDefaultMatch() { |
| bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match, |
| string16* keyword) const { |
| - // If the current match is a keyword, return that as the selected keyword. |
| - if (TemplateURL::SupportsReplacement(match.template_url)) { |
| - keyword->assign(match.template_url->keyword()); |
| - return false; |
| + // Assume we have no keyword until we find otherwise. |
| + keyword->clear(); |
| + |
| + if (match.template_url) { |
| + TemplateURLService* url_service = |
| + TemplateURLServiceFactory::GetForProfile(profile_); |
| + if (!url_service) |
| + return false; |
| + |
| + // Only use the default provider if the user typed in the keyword. |
| + const TemplateURL* default_url = url_service->GetDefaultSearchProvider(); |
| + if (default_url && default_url->id() == match.template_url->id() && |
|
Peter Kasting
2011/07/07 01:16:07
Nit: Slightly simpler conditionals by using else t
|
| + autocomplete_controller()->input().text().compare( |
|
Peter Kasting
2011/07/07 01:16:07
Nit: base::StartsWith()?
Do we need to worry abou
sky
2011/07/07 15:34:01
As far as I can tell no. keywords are always lower
|
| + 0u, default_url->keyword().size(), default_url->keyword()) == 0) { |
| + keyword->assign(match.template_url->keyword()); |
| + return false; |
| + } |
| + // If the current match is a keyword, return that as the selected keyword. |
| + if ((!default_url || default_url->id() != match.template_url->id()) && |
| + TemplateURL::SupportsReplacement(match.template_url)) { |
| + keyword->assign(match.template_url->keyword()); |
| + return false; |
| + } |
| } |
| // See if the current match's fill_into_edit corresponds to a keyword. |