Chromium Code Reviews| 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() << "This profile is OffTheRecord"; | |
|
Ilya Sherman
2012/03/27 01:01:17
nit: Please remove the logged comment, as it is cl
GeorgeY
2012/03/30 19:20:12
Done.
| |
| 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() << "This profile is OffTheRecord"; | |
|
Ilya Sherman
2012/03/27 01:01:17
nit: Ditto.
GeorgeY
2012/03/30 19:20:12
Done.
| |
| 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() << "failed to initialize WebService"; | |
|
Ilya Sherman
2012/03/27 01:01:17
nit: Ditto.
GeorgeY
2012/03/30 19:20:12
Done.
| |
| 62 } | |
| 63 return wds.get(); | |
| 64 } | |
| OLD | NEW |