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

Side by Side Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 10908065: Introduce a couple of abstract bases for WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to comments Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/web_data_service_factory.h" 5 #include "chrome/browser/webdata/web_data_service_factory.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "chrome/browser/profiles/profile_dependency_manager.h" 8 #include "chrome/browser/profiles/profile_dependency_manager.h"
9 #include "chrome/browser/webdata/autofill_web_data_service_impl.h"
9 #include "chrome/browser/webdata/web_data_service.h" 10 #include "chrome/browser/webdata/web_data_service.h"
10 #include "chrome/common/chrome_constants.h" 11 #include "chrome/common/chrome_constants.h"
11 12
13 // static
14 scoped_ptr<AutofillWebDataService> AutofillWebDataService::ForContext(
15 content::BrowserContext* context) {
16 // For this service, the implicit/explicit distinction doesn't
17 // really matter; it's just used for a DCHECK. So we currently
18 // cheat and always say EXPLICIT_ACCESS.
19 scoped_refptr<WebDataService> service = WebDataServiceFactory::GetForProfile(
20 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
21
22 if (service.get()) {
23 return scoped_ptr<AutofillWebDataService>(
24 new AutofillWebDataServiceImpl(service));
25 } else {
26 return scoped_ptr<AutofillWebDataService>(NULL);
27 }
28 }
29
12 WebDataServiceFactory::WebDataServiceFactory() 30 WebDataServiceFactory::WebDataServiceFactory()
13 : RefcountedProfileKeyedServiceFactory( 31 : RefcountedProfileKeyedServiceFactory(
14 "WebDataService", 32 "WebDataService",
15 ProfileDependencyManager::GetInstance()) { 33 ProfileDependencyManager::GetInstance()) {
16 // WebDataServiceFactory has no dependecies. 34 // WebDataServiceFactory has no dependecies.
17 } 35 }
18 36
19 WebDataServiceFactory::~WebDataServiceFactory() {} 37 WebDataServiceFactory::~WebDataServiceFactory() {}
20 38
21 // static 39 // static
22 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile( 40 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile(
23 Profile* profile, Profile::ServiceAccessType access_type) { 41 Profile* profile, Profile::ServiceAccessType access_type) {
42 // If |access_type| starts being used for anything other than this
43 // DCHECK, we need to start taking it as a parameter to
44 // AutofillWebDataServiceImpl::ForContext (see above).
24 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); 45 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
25 return static_cast<WebDataService*>( 46 return static_cast<WebDataService*>(
26 GetInstance()->GetServiceForProfile(profile, true).get()); 47 GetInstance()->GetServiceForProfile(profile, true).get());
27 } 48 }
28 49
29 // static 50 // static
30 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists( 51 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists(
31 Profile* profile, Profile::ServiceAccessType access_type) { 52 Profile* profile, Profile::ServiceAccessType access_type) {
32 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); 53 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
33 return static_cast<WebDataService*>( 54 return static_cast<WebDataService*>(
(...skipping 18 matching lines...) Expand all
52 73
53 scoped_refptr<WebDataService> wds(new WebDataService()); 74 scoped_refptr<WebDataService> wds(new WebDataService());
54 if (!wds->Init(profile->GetPath())) 75 if (!wds->Init(profile->GetPath()))
55 NOTREACHED(); 76 NOTREACHED();
56 return wds.get(); 77 return wds.get();
57 } 78 }
58 79
59 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 80 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
60 return true; 81 return true;
61 } 82 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698