Chromium Code Reviews| Index: chrome/browser/profile_resetter/profile_resetter.cc |
| diff --git a/chrome/browser/profile_resetter/profile_resetter.cc b/chrome/browser/profile_resetter/profile_resetter.cc |
| index 3c797a70bcc682cb4e8efe3b9e8e13497f4145f8..b44e8a5ddae338d4506805dd625eabbfbea48ad9 100644 |
| --- a/chrome/browser/profile_resetter/profile_resetter.cc |
| +++ b/chrome/browser/profile_resetter/profile_resetter.cc |
| @@ -6,7 +6,6 @@ |
| #include "base/prefs/pref_service.h" |
| #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| -#include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/content_settings/host_content_settings_map.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_system.h" |
| @@ -22,7 +21,6 @@ |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/common/pref_names.h" |
| #include "content/public/browser/browser_thread.h" |
| -#include "content/public/browser/notification_source.h" |
| ProfileResetter::ProfileResetter(Profile* profile) |
| : profile_(profile), |
| @@ -31,8 +29,6 @@ ProfileResetter::ProfileResetter(Profile* profile) |
| cookies_remover_(NULL) { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(profile_); |
| - registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
| - content::Source<TemplateURLService>(template_url_service_)); |
| } |
| ProfileResetter::~ProfileResetter() { |
| @@ -102,13 +98,13 @@ void ProfileResetter::MarkAsDone(Resettable resettable) { |
| callback_); |
| callback_.Reset(); |
| master_settings_.reset(); |
| + template_url_service_sub_.reset(); |
| } |
| } |
| void ProfileResetter::ResetDefaultSearchEngine() { |
| DCHECK(CalledOnValidThread()); |
| DCHECK(template_url_service_); |
| - |
| // If TemplateURLServiceFactory is ready we can clean it right now. |
| // Otherwise, load it and continue from ProfileResetter::Observe. |
| if (template_url_service_->loaded()) { |
| @@ -136,6 +132,10 @@ void ProfileResetter::ResetDefaultSearchEngine() { |
| MarkAsDone(DEFAULT_SEARCH_ENGINE); |
| } else { |
| + template_url_service_sub_ = |
| + template_url_service_->RegisterOnLoadedCallback( |
| + base::Bind(&ProfileResetter::OnTemplateURLServiceLoaded, |
| + base::Unretained(this))); |
| template_url_service_->Load(); |
| } |
| } |
| @@ -247,12 +247,10 @@ void ProfileResetter::ResetPinnedTabs() { |
| MarkAsDone(PINNED_TABS); |
| } |
| -void ProfileResetter::Observe(int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) { |
| - DCHECK(CalledOnValidThread()); |
| +void ProfileResetter::OnTemplateURLServiceLoaded() { |
| // TemplateURLService has loaded. If we need to clean search engines, it's |
|
Avi (use Gerrit)
2013/10/02 22:27:52
Was the drop of the thread DCHECK intentional? Mig
Cait (Slow)
2013/10/03 15:36:45
Done.
|
| // time to go on. |
| + template_url_service_sub_.reset(); |
| if (pending_reset_flags_ & DEFAULT_SEARCH_ENGINE) |
| ResetDefaultSearchEngine(); |
| } |