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()) { | |
25 NOTREACHED(); | |
Peter Kasting
2012/03/30 20:31:13
Don't use NOTREACHED() like this -- it violates ou
GeorgeY
2012/04/02 21:57:43
I think it is one of the few places where it makes
Peter Kasting
2012/04/02 22:09:06
Sorry, I don't agree that this qualifies for an ex
GeorgeY
2012/04/02 22:49:02
OK. Removed NOTREACHED in first two places - the t
| |
26 return NULL; | |
27 } | |
28 return static_cast<WebDataService*>( | |
29 GetInstance()->GetServiceForProfile(profile, true).get()); | |
30 } | |
31 | |
32 // static | |
33 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists( | |
34 Profile* profile, Profile::ServiceAccessType access_type) { | |
35 if (access_type == Profile::IMPLICIT_ACCESS && profile->IsOffTheRecord()) { | |
36 NOTREACHED(); | |
37 return NULL; | |
38 } | |
39 return static_cast<WebDataService*>( | |
40 GetInstance()->GetServiceForProfile(profile, false).get()); | |
41 } | |
42 | |
43 // static | |
44 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { | |
45 return Singleton<WebDataServiceFactory>::get(); | |
46 } | |
47 | |
48 bool WebDataServiceFactory::ServiceRedirectedInIncognito() { | |
49 return false; | |
50 } | |
51 | |
52 scoped_refptr<RefcountedProfileKeyedService> | |
53 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { | |
54 DCHECK(profile); | |
55 | |
56 FilePath path = profile->GetPath(); | |
57 path = path.Append(chrome::kWebDataFilename); | |
58 | |
59 scoped_refptr<WebDataService> wds(new WebDataService()); | |
60 if (!wds->Init(profile->GetPath())) { | |
61 NOTREACHED(); | |
62 } | |
63 return wds.get(); | |
64 } | |
OLD | NEW |