OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Default search engine change tracked by Protector. | 80 // Default search engine change tracked by Protector. |
81 class DefaultSearchProviderChange : public BaseSettingChange, | 81 class DefaultSearchProviderChange : public BaseSettingChange, |
82 public TemplateURLServiceObserver, | 82 public TemplateURLServiceObserver, |
83 public content::NotificationObserver { | 83 public content::NotificationObserver { |
84 public: | 84 public: |
85 DefaultSearchProviderChange(const TemplateURL* new_search_provider, | 85 DefaultSearchProviderChange(const TemplateURL* new_search_provider, |
86 TemplateURL* backup_search_provider); | 86 TemplateURL* backup_search_provider); |
87 | 87 |
88 // BaseSettingChange overrides: | 88 // BaseSettingChange overrides: |
89 virtual bool Init(Profile* profile) OVERRIDE; | 89 virtual bool Init(Profile* profile) OVERRIDE; |
| 90 virtual void InitWhenDisabled(Profile* profile) OVERRIDE; |
90 virtual void Apply(Browser* browser) OVERRIDE; | 91 virtual void Apply(Browser* browser) OVERRIDE; |
91 virtual void Discard(Browser* browser) OVERRIDE; | 92 virtual void Discard(Browser* browser) OVERRIDE; |
92 virtual void Timeout() OVERRIDE; | 93 virtual void Timeout() OVERRIDE; |
93 virtual int GetBadgeIconID() const OVERRIDE; | 94 virtual int GetBadgeIconID() const OVERRIDE; |
94 virtual int GetMenuItemIconID() const OVERRIDE; | 95 virtual int GetMenuItemIconID() const OVERRIDE; |
95 virtual int GetBubbleIconID() const OVERRIDE; | 96 virtual int GetBubbleIconID() const OVERRIDE; |
96 virtual string16 GetBubbleTitle() const OVERRIDE; | 97 virtual string16 GetBubbleTitle() const OVERRIDE; |
97 virtual string16 GetBubbleMessage() const OVERRIDE; | 98 virtual string16 GetBubbleMessage() const OVERRIDE; |
98 virtual string16 GetApplyButtonText() const OVERRIDE; | 99 virtual string16 GetApplyButtonText() const OVERRIDE; |
99 virtual string16 GetDiscardButtonText() const OVERRIDE; | 100 virtual string16 GetDiscardButtonText() const OVERRIDE; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // Listen for removal of |new_search_provider_|. | 226 // Listen for removal of |new_search_provider_|. |
226 new_id_ = new_search_provider_->id(); | 227 new_id_ = new_search_provider_->id(); |
227 registrar_.Add( | 228 registrar_.Add( |
228 this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED, | 229 this, chrome::NOTIFICATION_TEMPLATE_URL_REMOVED, |
229 content::Source<Profile>(profile->GetOriginalProfile())); | 230 content::Source<Profile>(profile->GetOriginalProfile())); |
230 } | 231 } |
231 | 232 |
232 return true; | 233 return true; |
233 } | 234 } |
234 | 235 |
| 236 void DefaultSearchProviderChange::InitWhenDisabled(Profile* profile) { |
| 237 // The --no-protector case is handled in TemplateURLService internals. |
| 238 // TODO(ivankr): move it here. |
| 239 NOTREACHED(); |
| 240 } |
| 241 |
235 void DefaultSearchProviderChange::Apply(Browser* browser) { | 242 void DefaultSearchProviderChange::Apply(Browser* browser) { |
236 UMA_HISTOGRAM_ENUMERATION( | 243 UMA_HISTOGRAM_ENUMERATION( |
237 kProtectorHistogramSearchProviderApplied, | 244 kProtectorHistogramSearchProviderApplied, |
238 new_histogram_id_, | 245 new_histogram_id_, |
239 kProtectorMaxSearchProviderID); | 246 kProtectorMaxSearchProviderID); |
240 | 247 |
241 GetTemplateURLService()->RemoveObserver(this); | 248 GetTemplateURLService()->RemoveObserver(this); |
242 if (new_search_provider_) { | 249 if (new_search_provider_) { |
243 GetTemplateURLService()->SetDefaultSearchProvider(new_search_provider_); | 250 GetTemplateURLService()->SetDefaultSearchProvider(new_search_provider_); |
244 } else { | 251 } else { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 DCHECK(url_service); | 422 DCHECK(url_service); |
416 return url_service; | 423 return url_service; |
417 } | 424 } |
418 | 425 |
419 BaseSettingChange* CreateDefaultSearchProviderChange(const TemplateURL* actual, | 426 BaseSettingChange* CreateDefaultSearchProviderChange(const TemplateURL* actual, |
420 TemplateURL* backup) { | 427 TemplateURL* backup) { |
421 return new DefaultSearchProviderChange(actual, backup); | 428 return new DefaultSearchProviderChange(actual, backup); |
422 } | 429 } |
423 | 430 |
424 } // namespace protector | 431 } // namespace protector |
OLD | NEW |