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

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

Issue 9834056: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload rebase 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..f0e6d109680523f9c2403c21c601f196d4e24de2 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"
@@ -198,9 +199,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 +227,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 +365,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 +393,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 +412,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 +444,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 +472,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 +491,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 +579,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 +674,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 +726,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 +766,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 +786,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 +837,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 +908,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