summaryrefslogtreecommitdiffstats
path: root/components/autofill/browser/personal_data_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'components/autofill/browser/personal_data_manager.cc')
-rw-r--r--components/autofill/browser/personal_data_manager.cc34
1 files changed, 14 insertions, 20 deletions
diff --git a/components/autofill/browser/personal_data_manager.cc b/components/autofill/browser/personal_data_manager.cc
index 58b8e17..f05242f 100644
--- a/components/autofill/browser/personal_data_manager.cc
+++ b/components/autofill/browser/personal_data_manager.cc
@@ -9,6 +9,7 @@
#include <iterator>
#include "base/logging.h"
+#include "base/memory/ref_counted.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h"
@@ -131,15 +132,20 @@ void PersonalDataManager::Init(BrowserContext* browser_context) {
LoadProfiles();
LoadCreditCards();
- notification_registrar_.Add(
- this,
- chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
- autofill_data->GetNotificationSource());
+ autofill_data->AddObserver(this);
}
PersonalDataManager::~PersonalDataManager() {
CancelPendingQuery(&pending_profiles_query_);
CancelPendingQuery(&pending_creditcards_query_);
+
+ if (!browser_context_)
+ return;
+
+ scoped_refptr<AutofillWebDataService> autofill_data(
+ AutofillWebDataService::FromBrowserContext(browser_context_));
+ if (autofill_data.get())
+ autofill_data->RemoveObserver(this);
}
void PersonalDataManager::OnWebDataServiceRequestDone(
@@ -182,6 +188,10 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
}
}
+void PersonalDataManager::AutofillMultipleChanged() {
+ Refresh();
+}
+
void PersonalDataManager::AddObserver(PersonalDataManagerObserver* observer) {
observers_.AddObserver(observer);
}
@@ -191,22 +201,6 @@ void PersonalDataManager::RemoveObserver(
observers_.RemoveObserver(observer);
}
-void PersonalDataManager::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(type, chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED);
-
- if (DCHECK_IS_ON()) {
- scoped_refptr<AutofillWebDataService> autofill_data(
- AutofillWebDataService::FromBrowserContext(browser_context_));
-
- DCHECK(autofill_data.get() &&
- autofill_data->GetNotificationSource() == source);
- }
-
- Refresh();
-}
-
bool PersonalDataManager::ImportFormData(
const FormStructure& form,
const CreditCard** imported_credit_card) {