summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_popup_model.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-07 19:36:17 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-07 19:36:17 +0000
commit0385fc680515fe21df6fc1cbb091e7a041230368 (patch)
tree3b62d2f3ee8e5af5870eededc72482996b92db98 /chrome/browser/autocomplete/autocomplete_popup_model.cc
parent075fb0ffcb8de17e3fc48a27f19d3f7416e10ce4 (diff)
downloadchromium_src-0385fc680515fe21df6fc1cbb091e7a041230368.zip
chromium_src-0385fc680515fe21df6fc1cbb091e7a041230368.tar.gz
chromium_src-0385fc680515fe21df6fc1cbb091e7a041230368.tar.bz2
Changes SearchProvider to set the description of the first consecutive
match sharing the same template url. For example, if the results were 'A B C D' with 'A' and 'B' sharing the same provider and 'C' and 'D' sharing the same provider, then 'A' and 'C' would get descriptions. As part of this I'm always setting AutocompleteMatch::template_url (previously we only set it for keywords). BUG=88322 TEST=see bug, also covered by unit tests. R=pkasting@chromium.org Review URL: http://codereview.chromium.org/7321001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91741 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_popup_model.cc')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index ea8492f..459560f 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -131,10 +131,30 @@ 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 show the keyword for the default provider if the user typed in
+ // the keyword and it isn't SEARCH_WHAT_YOU_TYPED.
+ const TemplateURL* default_url = url_service->GetDefaultSearchProvider();
+ if (default_url && (default_url->id() == match.template_url->id())) {
+ if (StartsWith(autocomplete_controller()->input().text(),
+ default_url->keyword(), false) &&
+ (match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED)) {
+ keyword->assign(match.template_url->keyword());
+ return false;
+ }
+ } else if (TemplateURL::SupportsReplacement(match.template_url)) {
+ // The current match is a keyword, return that as the selected keyword.
+ keyword->assign(match.template_url->keyword());
+ return false;
+ }
}
// See if the current match's fill_into_edit corresponds to a keyword.