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

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

Issue 7321001: Changes SearchProvider to set the description of the first consecutive (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK Created 9 years, 5 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 | « chrome/browser/autocomplete/autocomplete_match.h ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..459560fe83584d6fe8ff841dbdb8bbd6d84e6c2a 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.
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.h ('k') | chrome/browser/autocomplete/search_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698