| Index: chrome/browser/importer/external_process_importer_host.cc
|
| diff --git a/chrome/browser/importer/external_process_importer_host.cc b/chrome/browser/importer/external_process_importer_host.cc
|
| index 28ccd3ffe3b9b0fc72221ae8f92417b7584d1900..c9adc5b1e02f8dce0df25a9ed98a66cc2ce4ceac 100644
|
| --- a/chrome/browser/importer/external_process_importer_host.cc
|
| +++ b/chrome/browser/importer/external_process_importer_host.cc
|
| @@ -16,13 +16,11 @@
|
| #include "chrome/browser/search_engines/template_url_service.h"
|
| #include "chrome/browser/search_engines/template_url_service_factory.h"
|
| #include "content/public/browser/browser_thread.h"
|
| -#include "content/public/browser/notification_source.h"
|
|
|
| using content::BrowserThread;
|
|
|
| ExternalProcessImporterHost::ExternalProcessImporterHost()
|
| - : weak_ptr_factory_(this),
|
| - headless_(false),
|
| + : headless_(false),
|
| parent_window_(NULL),
|
| observer_(NULL),
|
| profile_(NULL),
|
| @@ -32,7 +30,8 @@ ExternalProcessImporterHost::ExternalProcessImporterHost()
|
| client_(NULL),
|
| items_(0),
|
| cancelled_(false),
|
| - import_process_launched_(false) {
|
| + import_process_launched_(false),
|
| + weak_ptr_factory_(this) {
|
| }
|
|
|
| void ExternalProcessImporterHost::Cancel() {
|
| @@ -99,7 +98,7 @@ ExternalProcessImporterHost::~ExternalProcessImporterHost() {
|
| }
|
|
|
| void ExternalProcessImporterHost::LaunchImportIfReady() {
|
| - if (waiting_for_bookmarkbar_model_ || !registrar_.IsEmpty() ||
|
| + if (waiting_for_bookmarkbar_model_ || template_service_subscription_.get() ||
|
| !is_source_readable_ || cancelled_)
|
| return;
|
|
|
| @@ -135,11 +134,8 @@ void ExternalProcessImporterHost::BookmarkModelBeingDeleted(
|
| void ExternalProcessImporterHost::BookmarkModelChanged() {
|
| }
|
|
|
| -void ExternalProcessImporterHost::Observe(int type,
|
| - const content::NotificationSource& source,
|
| - const content::NotificationDetails& details) {
|
| - DCHECK_EQ(type, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED);
|
| - registrar_.RemoveAll();
|
| +void ExternalProcessImporterHost::OnTemplateURLServiceLoaded() {
|
| + template_service_subscription_.reset();
|
| LaunchImportIfReady();
|
| }
|
|
|
| @@ -208,8 +204,9 @@ void ExternalProcessImporterHost::CheckForLoadedModels(uint16 items) {
|
| if (!writer_->TemplateURLServiceIsLoaded()) {
|
| TemplateURLService* model =
|
| TemplateURLServiceFactory::GetForProfile(profile_);
|
| - registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
|
| - content::Source<TemplateURLService>(model));
|
| + template_service_subscription_ = model->RegisterOnLoadedCallback(
|
| + base::Bind(&ExternalProcessImporterHost::OnTemplateURLServiceLoaded,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| model->Load();
|
| }
|
| }
|
|
|