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

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

Issue 7967024: Profile shouldn't own PersonalDataManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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: chrome/browser/autofill/personal_data_manager.cc
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index dd8ee30e9f7c88cf7465c3ccf47a50a1fed76cba..b063b3a6464ef64c5a1f83a6929099a7c389a022 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -23,8 +23,10 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/browser/browser_thread.h"
+#include "content/common/notification_source.h"
namespace {
@@ -198,6 +200,24 @@ void PersonalDataManager::OnStateChanged() {
}
}
+void PersonalDataManager::Shutdown() {
+ CancelPendingQuery(&pending_profiles_query_);
+ CancelPendingQuery(&pending_creditcards_query_);
+ notification_registrar_.RemoveAll();
+}
+
+void PersonalDataManager::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK_EQ(type, chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED);
+ WebDataService* web_data_service = Source<WebDataService>(source).ptr();
+
+ DCHECK(web_data_service &&
+ web_data_service ==
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS));
+ Refresh();
Ilya Sherman 2011/09/23 03:56:34 Why does sync need to inform the PDM to refresh, b
dhollowa 2011/09/23 16:30:03 The WDS notifications are not seen by the UI threa
+}
+
bool PersonalDataManager::ImportFormData(
const FormStructure& form,
const CreditCard** imported_credit_card) {
@@ -531,8 +551,18 @@ void PersonalDataManager::Init(Profile* profile) {
profile_ = profile;
metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
+ // WebDataService may not be available in tests.
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service)
+ return;
+
LoadProfiles();
LoadCreditCards();
+
+ notification_registrar_.Add(this,
+ chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED,
+ Source<WebDataService>(web_data_service));
}
bool PersonalDataManager::IsAutofillEnabled() const {

Powered by Google App Engine
This is Rietveld 408576698