| 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/supervised_user/supervised_user_service_factory.h" | 5 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" | 7 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 10 #include "chrome/browser/supervised_user/supervised_user_service.h" | 10 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 11 #include "chrome/browser/sync/profile_sync_service_factory.h" | 11 #include "chrome/browser/sync/profile_sync_service_factory.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/features/features.h" |
| 13 | 14 |
| 14 #if defined(ENABLE_EXTENSIONS) | 15 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 15 #include "extensions/browser/extension_system_provider.h" | 16 #include "extensions/browser/extension_system_provider.h" |
| 16 #include "extensions/browser/extensions_browser_client.h" | 17 #include "extensions/browser/extensions_browser_client.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 SupervisedUserService* SupervisedUserServiceFactory::GetForProfile( | 21 SupervisedUserService* SupervisedUserServiceFactory::GetForProfile( |
| 21 Profile* profile) { | 22 Profile* profile) { |
| 22 return static_cast<SupervisedUserService*>( | 23 return static_cast<SupervisedUserService*>( |
| 23 GetInstance()->GetServiceForBrowserContext(profile, true)); | 24 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 24 } | 25 } |
| 25 | 26 |
| 26 // static | 27 // static |
| 27 SupervisedUserServiceFactory* SupervisedUserServiceFactory::GetInstance() { | 28 SupervisedUserServiceFactory* SupervisedUserServiceFactory::GetInstance() { |
| 28 return base::Singleton<SupervisedUserServiceFactory>::get(); | 29 return base::Singleton<SupervisedUserServiceFactory>::get(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 // static | 32 // static |
| 32 KeyedService* SupervisedUserServiceFactory::BuildInstanceFor(Profile* profile) { | 33 KeyedService* SupervisedUserServiceFactory::BuildInstanceFor(Profile* profile) { |
| 33 return new SupervisedUserService(profile); | 34 return new SupervisedUserService(profile); |
| 34 } | 35 } |
| 35 | 36 |
| 36 SupervisedUserServiceFactory::SupervisedUserServiceFactory() | 37 SupervisedUserServiceFactory::SupervisedUserServiceFactory() |
| 37 : BrowserContextKeyedServiceFactory( | 38 : BrowserContextKeyedServiceFactory( |
| 38 "SupervisedUserService", | 39 "SupervisedUserService", |
| 39 BrowserContextDependencyManager::GetInstance()) { | 40 BrowserContextDependencyManager::GetInstance()) { |
| 40 #if defined(ENABLE_EXTENSIONS) | 41 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 41 DependsOn( | 42 DependsOn( |
| 42 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 43 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 43 #endif | 44 #endif |
| 44 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 45 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 45 DependsOn(ProfileSyncServiceFactory::GetInstance()); | 46 DependsOn(ProfileSyncServiceFactory::GetInstance()); |
| 46 } | 47 } |
| 47 | 48 |
| 48 SupervisedUserServiceFactory::~SupervisedUserServiceFactory() {} | 49 SupervisedUserServiceFactory::~SupervisedUserServiceFactory() {} |
| 49 | 50 |
| 50 content::BrowserContext* SupervisedUserServiceFactory::GetBrowserContextToUse( | 51 content::BrowserContext* SupervisedUserServiceFactory::GetBrowserContextToUse( |
| 51 content::BrowserContext* context) const { | 52 content::BrowserContext* context) const { |
| 52 return chrome::GetBrowserContextRedirectedInIncognito(context); | 53 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 53 } | 54 } |
| 54 | 55 |
| 55 KeyedService* SupervisedUserServiceFactory::BuildServiceInstanceFor( | 56 KeyedService* SupervisedUserServiceFactory::BuildServiceInstanceFor( |
| 56 content::BrowserContext* profile) const { | 57 content::BrowserContext* profile) const { |
| 57 return BuildInstanceFor(static_cast<Profile*>(profile)); | 58 return BuildInstanceFor(static_cast<Profile*>(profile)); |
| 58 } | 59 } |
| OLD | NEW |