| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/protector/base_setting_change.h" | 10 #include "chrome/browser/protector/base_setting_change.h" |
| 11 #include "chrome/browser/protector/histograms.h" | 11 #include "chrome/browser/protector/histograms.h" |
| 12 #include "chrome/browser/protector/protector.h" | 12 #include "chrome/browser/protector/protector.h" |
| 13 #include "chrome/browser/search_engines/template_url.h" | 13 #include "chrome/browser/search_engines/template_url.h" |
| 14 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 14 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 15 #include "chrome/browser/search_engines/template_url_service.h" | 15 #include "chrome/browser/search_engines/template_url_service.h" |
| 16 #include "chrome/browser/search_engines/template_url_service_observer.h" | 16 #include "chrome/browser/search_engines/template_url_service_observer.h" |
| 17 #include "chrome/browser/webdata/keyword_table.h" | 17 #include "chrome/browser/webdata/keyword_table.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
| 21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "grit/theme_resources.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 23 | 24 |
| 24 namespace protector { | 25 namespace protector { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // Maximum length of the search engine name to be displayed. | 29 // Maximum length of the search engine name to be displayed. |
| 29 const size_t kMaxDisplayedNameLength = 10; | 30 const size_t kMaxDisplayedNameLength = 10; |
| 30 | 31 |
| 31 // Predicate that matches a TemplateURL with given ID. | 32 // Predicate that matches a TemplateURL with given ID. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 public: | 90 public: |
| 90 DefaultSearchProviderChange(const TemplateURL* old_url, | 91 DefaultSearchProviderChange(const TemplateURL* old_url, |
| 91 const TemplateURL* new_url); | 92 const TemplateURL* new_url); |
| 92 | 93 |
| 93 // BaseSettingChange overrides: | 94 // BaseSettingChange overrides: |
| 94 virtual bool Init(Protector* protector) OVERRIDE; | 95 virtual bool Init(Protector* protector) OVERRIDE; |
| 95 virtual void Apply() OVERRIDE; | 96 virtual void Apply() OVERRIDE; |
| 96 virtual void Discard() OVERRIDE; | 97 virtual void Discard() OVERRIDE; |
| 97 virtual void Timeout() OVERRIDE; | 98 virtual void Timeout() OVERRIDE; |
| 98 virtual void OnBeforeRemoved() OVERRIDE; | 99 virtual void OnBeforeRemoved() OVERRIDE; |
| 100 virtual int GetBadgeIconID() const OVERRIDE; |
| 101 virtual int GetMenuItemIconID() const OVERRIDE; |
| 102 virtual int GetBubbleIconID() const OVERRIDE; |
| 99 virtual string16 GetBubbleTitle() const OVERRIDE; | 103 virtual string16 GetBubbleTitle() const OVERRIDE; |
| 100 virtual string16 GetBubbleMessage() const OVERRIDE; | 104 virtual string16 GetBubbleMessage() const OVERRIDE; |
| 101 virtual string16 GetApplyButtonText() const OVERRIDE; | 105 virtual string16 GetApplyButtonText() const OVERRIDE; |
| 102 virtual string16 GetDiscardButtonText() const OVERRIDE; | 106 virtual string16 GetDiscardButtonText() const OVERRIDE; |
| 103 | 107 |
| 104 // TemplateURLServiceObserver overrides: | 108 // TemplateURLServiceObserver overrides: |
| 105 virtual void OnTemplateURLServiceChanged() OVERRIDE; | 109 virtual void OnTemplateURLServiceChanged() OVERRIDE; |
| 106 | 110 |
| 107 private: | 111 private: |
| 108 virtual ~DefaultSearchProviderChange(); | 112 virtual ~DefaultSearchProviderChange(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 UMA_HISTOGRAM_ENUMERATION( | 234 UMA_HISTOGRAM_ENUMERATION( |
| 231 kProtectorHistogramSearchProviderTimeout, | 235 kProtectorHistogramSearchProviderTimeout, |
| 232 new_histogram_id_, | 236 new_histogram_id_, |
| 233 kProtectorMaxSearchProviderID); | 237 kProtectorMaxSearchProviderID); |
| 234 } | 238 } |
| 235 | 239 |
| 236 void DefaultSearchProviderChange::OnBeforeRemoved() { | 240 void DefaultSearchProviderChange::OnBeforeRemoved() { |
| 237 protector()->GetTemplateURLService()->RemoveObserver(this); | 241 protector()->GetTemplateURLService()->RemoveObserver(this); |
| 238 } | 242 } |
| 239 | 243 |
| 244 int DefaultSearchProviderChange::GetBadgeIconID() const { |
| 245 return IDR_SEARCH_ENGINE_CHANGE_BADGE; |
| 246 } |
| 247 |
| 248 int DefaultSearchProviderChange::GetMenuItemIconID() const { |
| 249 return IDR_SEARCH_ENGINE_CHANGE_MENU; |
| 250 } |
| 251 |
| 252 int DefaultSearchProviderChange::GetBubbleIconID() const { |
| 253 return IDR_SEARCH_ENGINE_CHANGE_ALERT; |
| 254 } |
| 255 |
| 240 string16 DefaultSearchProviderChange::GetBubbleTitle() const { | 256 string16 DefaultSearchProviderChange::GetBubbleTitle() const { |
| 241 return l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_CHANGE_TITLE); | 257 return l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_CHANGE_TITLE); |
| 242 } | 258 } |
| 243 | 259 |
| 244 string16 DefaultSearchProviderChange::GetBubbleMessage() const { | 260 string16 DefaultSearchProviderChange::GetBubbleMessage() const { |
| 245 if (fallback_name_.empty()) | 261 if (fallback_name_.empty()) |
| 246 return l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_CHANGE_MESSAGE); | 262 return l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_CHANGE_MESSAGE); |
| 247 else | 263 else |
| 248 return l10n_util::GetStringFUTF16( | 264 return l10n_util::GetStringFUTF16( |
| 249 IDS_SEARCH_ENGINE_CHANGE_NO_BACKUP_MESSAGE, fallback_name_); | 265 IDS_SEARCH_ENGINE_CHANGE_NO_BACKUP_MESSAGE, fallback_name_); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 chrome::kSearchEnginesSubPage)); | 365 chrome::kSearchEnginesSubPage)); |
| 350 } | 366 } |
| 351 | 367 |
| 352 BaseSettingChange* CreateDefaultSearchProviderChange( | 368 BaseSettingChange* CreateDefaultSearchProviderChange( |
| 353 const TemplateURL* actual, | 369 const TemplateURL* actual, |
| 354 const TemplateURL* backup) { | 370 const TemplateURL* backup) { |
| 355 return new DefaultSearchProviderChange(backup, actual); | 371 return new DefaultSearchProviderChange(backup, actual); |
| 356 } | 372 } |
| 357 | 373 |
| 358 } // namespace protector | 374 } // namespace protector |
| OLD | NEW |