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

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: Rebase 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
« no previous file with comments | « components/autofill/browser/personal_data_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 58b8e17b726eaa514331f968ad408de55081e332..f05242f58b1659124ad26c6fa6d329b548335f2d 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) {
« no previous file with comments | « components/autofill/browser/personal_data_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698