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

Unified Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 13928035: WIP Component build of autofill Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make windows compiling Created 7 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/webdata/web_data_service_factory.cc
diff --git a/chrome/browser/webdata/web_data_service_factory.cc b/chrome/browser/webdata/web_data_service_factory.cc
index c07d5fb9ca1cbfc8f3549f4218bccf1551427dcf..e25d0d9bf1c81e57935444cbb3573bf6acf9588e 100644
--- a/chrome/browser/webdata/web_data_service_factory.cc
+++ b/chrome/browser/webdata/web_data_service_factory.cc
@@ -118,33 +118,46 @@ scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
}
// static
-scoped_refptr<AutofillWebDataService>
-AutofillWebDataService::FromBrowserContext(content::BrowserContext* context) {
+scoped_refptr<WebDataService>
+WebDataServiceFactory::GetWebDataServiceForProfile(
+ Profile* profile) {
+ // For this service, the implicit/explicit distinction doesn't
+ // really matter; it's just used for a DCHECK. So we currently
+ // cheat and always say EXPLICIT_ACCESS.
+ WebDataServiceWrapper* wds_wrapper =
+ WebDataServiceFactory::GetForProfile(
+ profile, Profile::EXPLICIT_ACCESS, true);
+ if (wds_wrapper)
+ return wds_wrapper->GetWebData();
+ return NULL;
+}
+
+// static
+scoped_refptr<WebDataService>
+WebDataServiceFactory::GetWebDataServiceForProfileIfExists(Profile* profile) {
// For this service, the implicit/explicit distinction doesn't
// really matter; it's just used for a DCHECK. So we currently
// cheat and always say EXPLICIT_ACCESS.
- WebDataServiceWrapper* wrapper =
+ WebDataServiceWrapper* wds_wrapper =
WebDataServiceFactory::GetForProfile(
- static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
- if (wrapper)
- return wrapper->GetAutofillWebData();
- // |wrapper| can be NULL in Incognito mode.
- return scoped_refptr<AutofillWebDataService>(NULL);
+ profile, Profile::EXPLICIT_ACCESS, false);
+ if (wds_wrapper)
+ return wds_wrapper->GetWebData();
+ return NULL;
}
// static
-scoped_refptr<WebDataService> WebDataService::FromBrowserContext(
- content::BrowserContext* context) {
+scoped_refptr<AutofillWebDataService>
+WebDataServiceFactory::GetAutofillWebDataServiceForProfile(Profile* profile) {
// For this service, the implicit/explicit distinction doesn't
// really matter; it's just used for a DCHECK. So we currently
// cheat and always say EXPLICIT_ACCESS.
- WebDataServiceWrapper* wrapper =
+ WebDataServiceWrapper* wds_wrapper =
WebDataServiceFactory::GetForProfile(
- static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
- if (wrapper)
- return wrapper->GetWebData();
- // |wrapper| can be NULL in Incognito mode.
- return scoped_refptr<WebDataService>(NULL);
+ profile, Profile::EXPLICIT_ACCESS, true);
+ if (wds_wrapper)
+ return wds_wrapper->GetAutofillWebData();
+ return NULL;
}
WebDataServiceFactory::WebDataServiceFactory()
@@ -156,30 +169,21 @@ WebDataServiceFactory::WebDataServiceFactory()
WebDataServiceFactory::~WebDataServiceFactory() {}
// static
-WebDataServiceWrapper* WebDataServiceFactory::GetForProfile(
- Profile* profile, Profile::ServiceAccessType access_type) {
- // If |access_type| starts being used for anything other than this
- // DCHECK, we need to start taking it as a parameter to
- // AutofillWebDataService::FromBrowserContext (see above).
- DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
- return static_cast<WebDataServiceWrapper*>(
- GetInstance()->GetServiceForProfile(profile, true));
+WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
+ return Singleton<WebDataServiceFactory>::get();
}
// static
-WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists(
- Profile* profile, Profile::ServiceAccessType access_type) {
- // If |access_type| starts being used for anything other than this
- // DCHECK, we need to start taking it as a parameter to
- // AutofillWebDataService::FromBrowserContext (see above).
+WebDataServiceWrapper* WebDataServiceFactory::GetForProfile(
+ Profile* profile,
+ Profile::ServiceAccessType access_type,
+ bool create_if_not_exist) {
+ // If |access_type| starts being used for anything other than this DCHECK, we
+ // need to start taking it as a parameter to GetXXXForProfile functions (see
+ // above).
DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
return static_cast<WebDataServiceWrapper*>(
- GetInstance()->GetServiceForProfile(profile, false));
-}
-
-// static
-WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
- return Singleton<WebDataServiceFactory>::get();
+ GetInstance()->GetServiceForProfile(profile, create_if_not_exist));
}
bool WebDataServiceFactory::ServiceRedirectedInIncognito() const {

Powered by Google App Engine
This is Rietveld 408576698