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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile Created 8 years, 8 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 7ab1285b12b8687d93255789426392c5223da976..1bc4deddca3dffe17c471bfd0dee3ffe5bac7b09 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/webdata/autofill_entry.h"
#include "chrome/browser/webdata/web_data_service.h"
+#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -170,10 +171,11 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
if (sync_service && (!sync_service->HasSyncSetupCompleted() ||
!profile_->GetPrefs()->GetBoolean(prefs::kSyncAutofill))) {
- WebDataService* wds =
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (wds)
- wds->RemoveExpiredFormElements();
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_,
+ Profile::EXPLICIT_ACCESS);
+ if (web_data_service)
+ web_data_service->RemoveExpiredFormElements();
}
}
}
@@ -198,9 +200,9 @@ void PersonalDataManager::OnStateChanged() {
if (!profile_ || profile_->IsOffTheRecord())
return;
- WebDataService* web_data_service =
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!web_data_service) {
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (!web_data_service.get()) {
NOTREACHED();
return;
}
@@ -226,12 +228,12 @@ void PersonalDataManager::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED);
- WebDataService* web_data_service =
+ scoped_refptr<WebDataService> web_data_service =
content::Source<WebDataService>(source).ptr();
- DCHECK(web_data_service &&
- web_data_service ==
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS));
+ DCHECK(web_data_service.get() &&
+ web_data_service.get() == WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS).get());
Refresh();
}
@@ -364,8 +366,9 @@ void PersonalDataManager::AddProfile(const AutofillProfile& profile) {
if (FindByGUID<AutofillProfile>(web_profiles_, profile.guid()))
return;
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Don't add a duplicate.
@@ -391,8 +394,9 @@ void PersonalDataManager::UpdateProfile(const AutofillProfile& profile) {
return;
}
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Make the update.
@@ -409,8 +413,9 @@ void PersonalDataManager::RemoveProfile(const std::string& guid) {
if (!FindByGUID<AutofillProfile>(web_profiles_, guid))
return;
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Remove the profile.
@@ -440,8 +445,9 @@ void PersonalDataManager::AddCreditCard(const CreditCard& credit_card) {
if (FindByGUID<CreditCard>(credit_cards_, credit_card.guid()))
return;
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Don't add a duplicate.
@@ -467,8 +473,9 @@ void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) {
return;
}
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Make the update.
@@ -485,8 +492,9 @@ void PersonalDataManager::RemoveCreditCard(const std::string& guid) {
if (!FindByGUID<CreditCard>(credit_cards_, guid))
return;
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Remove the credit card.
@@ -572,9 +580,9 @@ void PersonalDataManager::Init(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)
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (!web_data_service.get())
return;
LoadProfiles();
@@ -667,8 +675,9 @@ void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) {
address_of<AutofillProfile>);
AutofillProfile::AdjustInferredLabels(&profile_pointers);
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Any profiles that are not in the new profile list should be removed from
@@ -718,8 +727,9 @@ void PersonalDataManager::SetCreditCards(
std::mem_fun_ref(&CreditCard::IsEmpty)),
credit_cards->end());
- WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!wds)
+ scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
+ profile_, Profile::EXPLICIT_ACCESS);
+ if (!wds.get())
return;
// Any credit cards that are not in the new credit card list should be
@@ -757,9 +767,9 @@ void PersonalDataManager::SetCreditCards(
}
void PersonalDataManager::LoadProfiles() {
- WebDataService* web_data_service =
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!web_data_service) {
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (!web_data_service.get()) {
NOTREACHED();
return;
}
@@ -777,9 +787,9 @@ void PersonalDataManager::LoadAuxiliaryProfiles() const {
#endif
void PersonalDataManager::LoadCreditCards() {
- WebDataService* web_data_service =
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!web_data_service) {
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (!web_data_service.get()) {
NOTREACHED();
return;
}
@@ -828,9 +838,10 @@ void PersonalDataManager::ReceiveLoadedCreditCards(
void PersonalDataManager::CancelPendingQuery(WebDataService::Handle* handle) {
if (*handle) {
- WebDataService* web_data_service =
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!web_data_service) {
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_,
+ Profile::EXPLICIT_ACCESS);
+ if (!web_data_service.get()) {
NOTREACHED();
return;
}
@@ -898,9 +909,9 @@ void PersonalDataManager::EmptyMigrationTrash() {
if (!profile_ || profile_->IsOffTheRecord())
return;
- WebDataService* web_data_service =
- profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (!web_data_service) {
+ scoped_refptr<WebDataService> web_data_service =
+ WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
+ if (!web_data_service.get()) {
NOTREACHED();
return;
}
« no previous file with comments | « chrome/browser/autofill/autofill_metrics_unittest.cc ('k') | chrome/browser/autofill/personal_data_manager_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698