Chromium Code Reviews| Index: chrome/browser/protector/default_search_provider_change.cc |
| diff --git a/chrome/browser/protector/default_search_provider_change.cc b/chrome/browser/protector/default_search_provider_change.cc |
| index 28df6ed671bb5cd055402ef0927a984a5bb3c2e7..11d7938da97747e11c3cfb4dd6f2547ed72c0c63 100644 |
| --- a/chrome/browser/protector/default_search_provider_change.cc |
| +++ b/chrome/browser/protector/default_search_provider_change.cc |
| @@ -38,6 +38,9 @@ namespace { |
| // Maximum length of the search engine name to be displayed. |
| const size_t kMaxDisplayedNameLength = 16; |
| +// Priority for the display name. |
| +const size_t kNamePriority = 100U; |
| + |
| // Matches TemplateURL with all fields set from the prepopulated data equal |
| // to fields in another TemplateURL. |
| class TemplateURLIsSame { |
| @@ -97,6 +100,8 @@ class DefaultSearchProviderChange : public BaseSettingChange, |
| virtual string16 GetBubbleMessage() const OVERRIDE; |
| virtual string16 GetApplyButtonText() const OVERRIDE; |
| virtual string16 GetDiscardButtonText() const OVERRIDE; |
| + virtual DisplayName GetApplyDisplayName() const OVERRIDE; |
| + virtual std::string GetApplyKeyword() const OVERRIDE; |
| private: |
| virtual ~DefaultSearchProviderChange(); |
| @@ -148,7 +153,6 @@ class DefaultSearchProviderChange : public BaseSettingChange, |
| // TemplateURLService or deleted. |
| scoped_ptr<TemplateURL> backup_search_provider_; |
| content::NotificationRegistrar registrar_; |
| - |
|
whywhat
2012/04/06 16:28:32
Could you, please, leave the blank line?
Ivan Korotkov
2012/04/09 14:46:47
Done.
|
| DISALLOW_COPY_AND_ASSIGN(DefaultSearchProviderChange); |
| }; |
| @@ -322,6 +326,32 @@ string16 DefaultSearchProviderChange::GetDiscardButtonText() const { |
| return l10n_util::GetStringUTF16(IDS_SELECT_SEARCH_ENGINE); |
| } |
| +BaseSettingChange::DisplayName |
| +DefaultSearchProviderChange::GetApplyDisplayName() const { |
| + if (new_search_provider_ && |
| + new_search_provider_->short_name().length() <= kMaxDisplayedNameLength) { |
| + return DisplayName(kNamePriority, new_search_provider_->short_name()); |
| + } |
| + return DisplayName(kDefaultNamePriority, string16()); |
| +} |
| + |
| +std::string DefaultSearchProviderChange::GetApplyKeyword() const { |
| + std::string host; |
| + if (is_fallback_) { |
| + // Do not collide this change when fallback was made, since the message |
| + // and Discard behaviour is pretty different. |
| + return host; |
| + } |
| + if (!new_search_provider_) |
| + return host; |
| + // TODO(ivankr): may need to check for google base URL and return something |
| + // like "google.com" in that case (same in other changes), so that all google |
|
whywhat
2012/04/06 16:28:32
using .com in this case could be confusing ("I tho
Ivan Korotkov
2012/04/09 14:46:47
This "keyword" is only used for comparing changes
|
| + // domains are treated as equal. |
| + host = new_search_provider_->url_ref().GetHost(); |
| + DCHECK(!host.empty()); |
| + return host; |
| +} |
| + |
| void DefaultSearchProviderChange::OnTemplateURLServiceChanged() { |
| TemplateURLService* url_service = GetTemplateURLService(); |
| if (url_service->GetDefaultSearchProvider() != default_search_provider_) { |