| 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/command_line.h" |
| 7 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/easy_unlock_service.h" | 11 #include "chrome/browser/signin/easy_unlock_service.h" |
| 11 #include "chrome/browser/signin/easy_unlock_service_regular.h" | 12 #include "chrome/browser/signin/easy_unlock_service_regular.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "extensions/browser/extension_system_provider.h" | 14 #include "extensions/browser/extension_system_provider.h" |
| 14 #include "extensions/browser/extensions_browser_client.h" | 15 #include "extensions/browser/extensions_browser_client.h" |
| 15 | 16 |
| 16 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 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" |
| 20 #include "chromeos/chromeos_switches.h" |
| 19 #endif | 21 #endif |
| 20 | 22 |
| 21 // static | 23 // static |
| 22 EasyUnlockServiceFactory* EasyUnlockServiceFactory::GetInstance() { | 24 EasyUnlockServiceFactory* EasyUnlockServiceFactory::GetInstance() { |
| 23 return Singleton<EasyUnlockServiceFactory>::get(); | 25 return Singleton<EasyUnlockServiceFactory>::get(); |
| 24 } | 26 } |
| 25 | 27 |
| 26 // static | 28 // static |
| 27 EasyUnlockService* EasyUnlockServiceFactory::GetForProfile(Profile* profile) { | 29 EasyUnlockService* EasyUnlockServiceFactory::GetForProfile(Profile* profile) { |
| 28 return static_cast<EasyUnlockService*>( | 30 return static_cast<EasyUnlockService*>( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 } | 41 } |
| 40 | 42 |
| 41 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { | 43 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { |
| 42 } | 44 } |
| 43 | 45 |
| 44 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( | 46 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( |
| 45 content::BrowserContext* context) const { | 47 content::BrowserContext* context) const { |
| 46 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 47 if (chromeos::ProfileHelper::IsSigninProfile( | 49 if (chromeos::ProfileHelper::IsSigninProfile( |
| 48 Profile::FromBrowserContext(context))) { | 50 Profile::FromBrowserContext(context))) { |
| 49 return new EasyUnlockServiceSignin(Profile::FromBrowserContext(context)); | 51 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 52 chromeos::switches::kEnableEasySignin)) { |
| 53 return new EasyUnlockServiceSignin(Profile::FromBrowserContext(context)); |
| 54 } else { |
| 55 return NULL; |
| 56 } |
| 50 } | 57 } |
| 51 #endif | 58 #endif |
| 52 return new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)); | 59 return new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)); |
| 53 } | 60 } |
| 54 | 61 |
| 55 content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse( | 62 content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse( |
| 56 content::BrowserContext* context) const { | 63 content::BrowserContext* context) const { |
| 57 return chrome::GetBrowserContextRedirectedInIncognito(context); | 64 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 58 } | 65 } |
| 59 | 66 |
| 60 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 67 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
| 61 return true; | 68 return true; |
| 62 } | 69 } |
| 63 | 70 |
| 64 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { | 71 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { |
| 65 // Don't create the service for TestingProfile used in unit_tests because | 72 // Don't create the service for TestingProfile used in unit_tests because |
| 66 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects | 73 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects |
| 67 // a MessageLoop that does not exit in many unit_tests cases. | 74 // a MessageLoop that does not exit in many unit_tests cases. |
| 68 return true; | 75 return true; |
| 69 } | 76 } |
| OLD | NEW |