1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
7 #include "chrome/browser/extensions/extension_system_factory.h"
8 #include "chrome/browser/managed_mode/managed_user_service.h"
9 #include "chrome/browser/profiles/incognito_helpers.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
12 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
15 ManagedUserService
* ManagedUserServiceFactory::GetForProfile(Profile
* profile
) {
16 return static_cast<ManagedUserService
*>(
17 GetInstance()->GetServiceForBrowserContext(profile
, true));
21 ManagedUserServiceFactory
* ManagedUserServiceFactory::GetInstance() {
22 return Singleton
<ManagedUserServiceFactory
>::get();
26 BrowserContextKeyedService
* ManagedUserServiceFactory::BuildInstanceFor(
28 return new ManagedUserService(profile
);
31 ManagedUserServiceFactory::ManagedUserServiceFactory()
32 : BrowserContextKeyedServiceFactory(
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(extensions::ExtensionSystemFactory::GetInstance());
36 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
39 ManagedUserServiceFactory::~ManagedUserServiceFactory() {}
41 content::BrowserContext
* ManagedUserServiceFactory::GetBrowserContextToUse(
42 content::BrowserContext
* context
) const {
43 return chrome::GetBrowserContextRedirectedInIncognito(context
);
46 BrowserContextKeyedService
* ManagedUserServiceFactory::BuildServiceInstanceFor(
47 content::BrowserContext
* profile
) const {
48 return BuildInstanceFor(static_cast<Profile
*>(profile
));