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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { | 45 EasyUnlockServiceFactory::~EasyUnlockServiceFactory() { |
46 } | 46 } |
47 | 47 |
48 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( | 48 KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( |
49 content::BrowserContext* context) const { | 49 content::BrowserContext* context) const { |
50 #if defined(OS_CHROMEOS) | 50 #if defined(OS_CHROMEOS) |
51 if (chromeos::ProfileHelper::IsSigninProfile( | 51 if (chromeos::ProfileHelper::IsSigninProfile( |
52 Profile::FromBrowserContext(context))) { | 52 Profile::FromBrowserContext(context))) { |
53 if (EasyUnlockService::IsSignInEnabled()) { | 53 if (EasyUnlockService::IsSignInEnabled() && context->IsOffTheRecord()) { |
54 return new EasyUnlockServiceSignin(Profile::FromBrowserContext(context)); | 54 return new EasyUnlockServiceSignin(Profile::FromBrowserContext(context)); |
55 } else { | 55 } else { |
56 return NULL; | 56 return NULL; |
57 } | 57 } |
58 } | 58 } |
59 #endif | 59 #endif |
60 return new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)); | 60 return new EasyUnlockServiceRegular(Profile::FromBrowserContext(context)); |
61 } | 61 } |
62 | 62 |
63 content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse( | 63 content::BrowserContext* EasyUnlockServiceFactory::GetBrowserContextToUse( |
64 content::BrowserContext* context) const { | 64 content::BrowserContext* context) const { |
| 65 #if defined(OS_CHROMEOS) |
| 66 if (chromeos::ProfileHelper::IsSigninProfile( |
| 67 Profile::FromBrowserContext(context))) { |
| 68 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 69 } |
| 70 #endif |
65 return chrome::GetBrowserContextRedirectedInIncognito(context); | 71 return chrome::GetBrowserContextRedirectedInIncognito(context); |
66 } | 72 } |
67 | 73 |
68 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 74 bool EasyUnlockServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
69 return true; | 75 return true; |
70 } | 76 } |
71 | 77 |
72 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { | 78 bool EasyUnlockServiceFactory::ServiceIsNULLWhileTesting() const { |
73 // Don't create the service for TestingProfile used in unit_tests because | 79 // Don't create the service for TestingProfile used in unit_tests because |
74 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects | 80 // EasyUnlockService uses ExtensionSystem::ready().Post, which expects |
75 // a MessageLoop that does not exit in many unit_tests cases. | 81 // a MessageLoop that does not exit in many unit_tests cases. |
76 return true; | 82 return true; |
77 } | 83 } |
OLD | NEW |