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 "components/keyed_service/content/browser_context_dependency_manager.h" | 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
12 #include "extensions/browser/extension_system_provider.h" | 13 #include "extensions/browser/extension_system_provider.h" |
13 #include "extensions/browser/extensions_browser_client.h" | 14 #include "extensions/browser/extensions_browser_client.h" |
14 | 15 |
15 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 18 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
17 #endif | 19 #endif |
18 | 20 |
19 // static | 21 // static |
20 EasyUnlockServiceFactory* EasyUnlockServiceFactory::GetInstance() { | 22 EasyUnlockServiceFactory* EasyUnlockServiceFactory::GetInstance() { |
21 return Singleton<EasyUnlockServiceFactory>::get(); | 23 return Singleton<EasyUnlockServiceFactory>::get(); |
22 } | 24 } |
23 | 25 |
24 // static | 26 // static |
25 EasyUnlockService* EasyUnlockServiceFactory::GetForProfile(Profile* profile) { | 27 EasyUnlockService* EasyUnlockServiceFactory::GetForProfile(Profile* profile) { |
26 return static_cast<EasyUnlockService*>( | 28 return static_cast<EasyUnlockService*>( |
27 EasyUnlockServiceFactory::GetInstance()->GetServiceForBrowserContext( | 29 EasyUnlockServiceFactory::GetInstance()->GetServiceForBrowserContext( |
28 profile, true)); | 30 profile, true)); |
29 } | 31 } |
30 | 32 |
31 EasyUnlockServiceFactory::EasyUnlockServiceFactory() | 33 EasyUnlockServiceFactory::EasyUnlockServiceFactory() |
32 : BrowserContextKeyedServiceFactory( | 34 : BrowserContextKeyedServiceFactory( |
33 "EasyUnlockService", | 35 "EasyUnlockService", |
34 BrowserContextDependencyManager::GetInstance()) { | 36 BrowserContextDependencyManager::GetInstance()) { |
35 DependsOn( | 37 DependsOn( |
36 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 38 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
37 } | 39 } |
38 | 40 |
39 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { | 41 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { |
40 } | 42 } |
41 | 43 |
42 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( | 44 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( |
43 content::BrowserContext* context) const { | 45 content::BrowserContext* context) const { |
44 return new EasyUnlockService(Profile::FromBrowserContext(context)); | 46 #if defined(OS_CHROMEOS) |
| 47 if (chromeos::ProfileHelper::IsSigninProfile( |
| 48 Profile::FromBrowserContext(context))) { |
| 49 return new EasyUnlockServiceSignin(Profile::FromBrowserContext(context)); |
| 50 } |
| 51 #endif |
| 52 return new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)); |
45 } | 53 } |
46 | 54 |
47 content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse( | 55 content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse( |
48 content::BrowserContext* context) const { | 56 content::BrowserContext* context) const { |
49 #if defined(OS_CHROMEOS) | |
50 if (chromeos::ProfileHelper::IsSigninProfile( | |
51 Profile::FromBrowserContext(context))) { | |
52 return NULL; | |
53 } | |
54 #endif | |
55 return chrome::GetBrowserContextRedirectedInIncognito(context); | 57 return chrome::GetBrowserContextRedirectedInIncognito(context); |
56 } | 58 } |
57 | 59 |
58 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 60 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
59 return true; | 61 return true; |
60 } | 62 } |
61 | 63 |
62 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { | 64 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { |
63 // Don't create the service for TestingProfile used in unit_tests because | 65 // Don't create the service for TestingProfile used in unit_tests because |
64 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects | 66 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects |
65 // a MessageLoop that does not exit in many unit_tests cases. | 67 // a MessageLoop that does not exit in many unit_tests cases. |
66 return true; | 68 return true; |
67 } | 69 } |
OLD | NEW |