| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/easy_unlock_service_factory.h" | 5 #include "chrome/browser/signin/easy_unlock_service_factory.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/easy_unlock_service.h" | 10 #include "chrome/browser/signin/easy_unlock_service.h" |
| 11 #include "chrome/browser/signin/easy_unlock_service_regular.h" | 11 #include "chrome/browser/signin/easy_unlock_service_regular.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "extensions/browser/extension_system_provider.h" | 13 #include "extensions/browser/extension_system_provider.h" |
| 14 #include "extensions/browser/extensions_browser_client.h" | 14 #include "extensions/browser/extensions_browser_client.h" |
| 15 | 15 |
| 16 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
| 17 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" | 19 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
| 19 #endif | 20 #endif |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 EasyUnlockServiceFactory* EasyUnlockServiceFactory::GetInstance() { | 23 EasyUnlockServiceFactory* EasyUnlockServiceFactory::GetInstance() { |
| 23 return Singleton<EasyUnlockServiceFactory>::get(); | 24 return Singleton<EasyUnlockServiceFactory>::get(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 // static | 27 // static |
| 27 EasyUnlockService* EasyUnlockServiceFactory::GetForProfile(Profile* profile) { | 28 EasyUnlockService* EasyUnlockServiceFactory::GetForProfile(Profile* profile) { |
| 28 return static_cast<EasyUnlockService*>( | 29 return static_cast<EasyUnlockService*>( |
| 29 EasyUnlockServiceFactory::GetInstance()->GetServiceForBrowserContext( | 30 EasyUnlockServiceFactory::GetInstance()->GetServiceForBrowserContext( |
| 30 profile, true)); | 31 profile, true)); |
| 31 } | 32 } |
| 32 | 33 |
| 33 EasyUnlockServiceFactory::EasyUnlockServiceFactory() | 34 EasyUnlockServiceFactory::EasyUnlockServiceFactory() |
| 34 : BrowserContextKeyedServiceFactory( | 35 : BrowserContextKeyedServiceFactory( |
| 35 "EasyUnlockService", | 36 "EasyUnlockService", |
| 36 BrowserContextDependencyManager::GetInstance()) { | 37 BrowserContextDependencyManager::GetInstance()) { |
| 37 DependsOn( | 38 DependsOn( |
| 38 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 39 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 40 #if defined(OS_CHROMEOS) |
| 41 DependsOn(EasyUnlockTpmKeyManagerFactory::GetInstance()); |
| 42 #endif |
| 39 } | 43 } |
| 40 | 44 |
| 41 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { | 45 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { |
| 42 } | 46 } |
| 43 | 47 |
| 44 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( | 48 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( |
| 45 content::BrowserContext* context) const { | 49 content::BrowserContext* context) const { |
| 46 #if defined(OS_CHROMEOS) | 50 #if defined(OS_CHROMEOS) |
| 47 if (chromeos::ProfileHelper::IsSigninProfile( | 51 if (chromeos::ProfileHelper::IsSigninProfile( |
| 48 Profile::FromBrowserContext(context))) { | 52 Profile::FromBrowserContext(context))) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 64 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 68 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
| 65 return true; | 69 return true; |
| 66 } | 70 } |
| 67 | 71 |
| 68 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { | 72 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { |
| 69 // Don't create the service for TestingProfile used in unit_tests because | 73 // Don't create the service for TestingProfile used in unit_tests because |
| 70 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects | 74 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects |
| 71 // a MessageLoop that does not exit in many unit_tests cases. | 75 // a MessageLoop that does not exit in many unit_tests cases. |
| 72 return true; | 76 return true; |
| 73 } | 77 } |
| OLD | NEW |