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 f291cf9f3a31ae70980284da0875bf289bc44fa5..221ffd69d36863e32b1d40623700cd7ced72d761 100644 |
--- a/chrome/browser/autofill/personal_data_manager.cc |
+++ b/chrome/browser/autofill/personal_data_manager.cc |
@@ -24,6 +24,7 @@ |
#include "chrome/browser/sync/profile_sync_service.h" |
#include "chrome/browser/sync/profile_sync_service_factory.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" |
@@ -184,9 +185,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; |
} |
@@ -212,12 +213,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(); |
} |
@@ -350,8 +351,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. |
@@ -377,8 +379,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. |
@@ -395,8 +398,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. |
@@ -426,8 +430,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. |
@@ -453,8 +458,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. |
@@ -471,8 +477,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. |
@@ -558,9 +565,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(); |
@@ -653,8 +660,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 |
@@ -704,8 +712,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 |
@@ -743,9 +752,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; |
} |
@@ -763,9 +772,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; |
} |
@@ -814,9 +823,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; |
} |
@@ -884,9 +894,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; |
} |