Chromium Code Reviews| Index: chrome/browser/sync/glue/search_engine_data_type_controller.cc |
| diff --git a/chrome/browser/sync/glue/search_engine_data_type_controller.cc b/chrome/browser/sync/glue/search_engine_data_type_controller.cc |
| index 9718b23ccdb54638e3e523f1cc4334e65e7772b0..ea5435a7ff841d440674da54a2535b648c8e8a32 100644 |
| --- a/chrome/browser/sync/glue/search_engine_data_type_controller.cc |
| +++ b/chrome/browser/sync/glue/search_engine_data_type_controller.cc |
| @@ -5,13 +5,10 @@ |
| #include "chrome/browser/sync/glue/search_engine_data_type_controller.h" |
| #include "base/metrics/histogram.h" |
| -#include "chrome/browser/chrome_notification_types.h" |
| #include "chrome/browser/profiles/profile.h" |
| -#include "chrome/browser/search_engines/template_url_service.h" |
| #include "chrome/browser/search_engines/template_url_service_factory.h" |
| #include "chrome/browser/sync/profile_sync_components_factory.h" |
| #include "chrome/browser/sync/profile_sync_service.h" |
| -#include "content/public/browser/notification_source.h" |
| #include "sync/api/syncable_service.h" |
| using content::BrowserThread; |
| @@ -28,17 +25,6 @@ SearchEngineDataTypeController::SearchEngineDataTypeController( |
| sync_service) { |
| } |
| -void SearchEngineDataTypeController::Observe( |
| - int type, |
| - const content::NotificationSource& source, |
| - const content::NotificationDetails& details) { |
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - DCHECK_EQ(chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, type); |
| - registrar_.RemoveAll(); |
| - DCHECK_EQ(state_, MODEL_STARTING); |
| - OnModelLoaded(); |
| -} |
| - |
| SearchEngineDataTypeController::~SearchEngineDataTypeController() {} |
| // We want to start the TemplateURLService before we begin associating. |
| @@ -54,15 +40,23 @@ bool SearchEngineDataTypeController::StartModels() { |
| return true; // Continue to Associate(). |
| } |
| - // Add an observer and continue when the TemplateURLService is loaded. |
| - registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
| - content::Source<TemplateURLService>(turl_service)); |
| + // Register a callback and continue when the TemplateURLService is loaded. |
| + template_url_subscription_ = turl_service->RegisterOnLoadedCallback( |
| + base::Bind(&SearchEngineDataTypeController::OnTemplateURLServiceLoaded, |
| + this)); |
| + |
| return false; // Don't continue Start. |
| } |
| // Cleanup for our extra registrar usage. |
|
Avi (use Gerrit)
2013/10/02 22:27:52
The comment is bogus; there is no registrar and th
Cait (Slow)
2013/10/03 15:36:45
Done.
|
| void SearchEngineDataTypeController::StopModels() { |
| - registrar_.RemoveAll(); |
| +} |
| + |
| +void SearchEngineDataTypeController::OnTemplateURLServiceLoaded() { |
| + template_url_subscription_.reset(); |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + DCHECK_EQ(state_, MODEL_STARTING); |
| + OnModelLoaded(); |
| } |
| } // namespace browser_sync |