OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/webdata/web_data_service_factory.h" | |
6 | |
7 #include "base/file_path.h" | |
8 #include "chrome/browser/profiles/profile_dependency_manager.h" | |
9 #include "chrome/browser/webdata/web_data_service.h" | |
10 #include "chrome/common/chrome_constants.h" | |
11 | |
12 WebDataServiceFactory::WebDataServiceFactory() | |
13 : RefcountedProfileKeyedServiceFactory( | |
14 "WebDataService", | |
15 ProfileDependencyManager::GetInstance()) { | |
16 // WebDataServiceFactory has no dependecies. | |
17 } | |
18 | |
19 WebDataServiceFactory::~WebDataServiceFactory() {} | |
20 | |
21 // static | |
22 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile( | |
23 Profile* profile, Profile::ServiceAccessType access_type) { | |
24 if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { | |
Peter Kasting
2012/04/02 23:21:13
Nit: Use DCHECK() as requested previously:
DCH
GeorgeY
2012/04/03 20:13:29
Done.
| |
25 NOTREACHED(); | |
26 } | |
27 return static_cast<WebDataService*>( | |
28 GetInstance()->GetServiceForProfile(profile, true).get()); | |
29 } | |
30 | |
31 // static | |
32 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists( | |
33 Profile* profile, Profile::ServiceAccessType access_type) { | |
34 if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { | |
35 NOTREACHED(); | |
36 } | |
37 return static_cast<WebDataService*>( | |
38 GetInstance()->GetServiceForProfile(profile, false).get()); | |
39 } | |
40 | |
41 // static | |
42 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { | |
43 return Singleton<WebDataServiceFactory>::get(); | |
44 } | |
45 | |
46 bool WebDataServiceFactory::ServiceRedirectedInIncognito() { | |
47 return false; | |
48 } | |
49 | |
50 scoped_refptr<RefcountedProfileKeyedService> | |
51 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { | |
52 DCHECK(profile); | |
53 | |
54 FilePath path = profile->GetPath(); | |
55 path = path.Append(chrome::kWebDataFilename); | |
56 | |
57 scoped_refptr<WebDataService> wds(new WebDataService()); | |
58 if (!wds->Init(profile->GetPath())) { | |
Peter Kasting
2012/04/02 23:21:13
Nit: {} unnecessary
GeorgeY
2012/04/03 20:13:29
Done.
| |
59 NOTREACHED(); | |
60 } | |
61 return wds.get(); | |
62 } | |
OLD | NEW |