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 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); |
| 25 return static_cast<WebDataService*>( |
| 26 GetInstance()->GetServiceForProfile(profile, true).get()); |
| 27 } |
| 28 |
| 29 // static |
| 30 scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists( |
| 31 Profile* profile, Profile::ServiceAccessType access_type) { |
| 32 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); |
| 33 return static_cast<WebDataService*>( |
| 34 GetInstance()->GetServiceForProfile(profile, false).get()); |
| 35 } |
| 36 |
| 37 // static |
| 38 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { |
| 39 return Singleton<WebDataServiceFactory>::get(); |
| 40 } |
| 41 |
| 42 bool WebDataServiceFactory::ServiceRedirectedInIncognito() { |
| 43 return false; |
| 44 } |
| 45 |
| 46 scoped_refptr<RefcountedProfileKeyedService> |
| 47 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { |
| 48 DCHECK(profile); |
| 49 |
| 50 FilePath path = profile->GetPath(); |
| 51 path = path.Append(chrome::kWebDataFilename); |
| 52 |
| 53 scoped_refptr<WebDataService> wds(new WebDataService()); |
| 54 if (!wds->Init(profile->GetPath())) |
| 55 NOTREACHED(); |
| 56 return wds.get(); |
| 57 } |
| 58 |
| 59 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() { |
| 60 return true; |
| 61 } |
OLD | NEW |