Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: components/autofill/browser/personal_data_manager.cc

Issue 12476031: Refactor notifications of chrome/browser/webdata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/personal_data_manager.cc
diff --git a/components/autofill/browser/personal_data_manager.cc b/components/autofill/browser/personal_data_manager.cc
index 7317a6b8998305247638f9c842cbe7c3874d68ed..ec4e93715940519791e5a833a94c4f680aaf540f 100644
--- a/components/autofill/browser/personal_data_manager.cc
+++ b/components/autofill/browser/personal_data_manager.cc
@@ -131,15 +131,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_ptr<AutofillWebDataService> autofill_data(
+ AutofillWebDataService::FromBrowserContext(browser_context_));
+ if (autofill_data.get())
+ autofill_data->RemoveObserver(this);
}
void PersonalDataManager::OnWebDataServiceRequestDone(
@@ -182,6 +187,10 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
}
}
+void PersonalDataManager::AutofillMultipleChanged() {
+ Refresh();
+}
+
void PersonalDataManager::AddObserver(PersonalDataManagerObserver* observer) {
observers_.AddObserver(observer);
}
@@ -191,22 +200,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_ptr<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) {

Powered by Google App Engine
This is Rietveld 408576698