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. 4 5#include "chrome/browser/managed_mode/managed_user_service_factory.h" 6 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" 13 14// static 15ManagedUserService* ManagedUserServiceFactory::GetForProfile(Profile* profile) { 16 return static_cast<ManagedUserService*>( 17 GetInstance()->GetServiceForBrowserContext(profile, true)); 18} 19 20// static 21ManagedUserServiceFactory* ManagedUserServiceFactory::GetInstance() { 22 return Singleton<ManagedUserServiceFactory>::get(); 23} 24 25// static 26BrowserContextKeyedService* ManagedUserServiceFactory::BuildInstanceFor( 27 Profile* profile) { 28 return new ManagedUserService(profile); 29} 30 31ManagedUserServiceFactory::ManagedUserServiceFactory() 32 : BrowserContextKeyedServiceFactory( 33 "ManagedUserService", 34 BrowserContextDependencyManager::GetInstance()) { 35 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); 36 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); 37} 38 39ManagedUserServiceFactory::~ManagedUserServiceFactory() {} 40 41content::BrowserContext* ManagedUserServiceFactory::GetBrowserContextToUse( 42 content::BrowserContext* context) const { 43 return chrome::GetBrowserContextRedirectedInIncognito(context); 44} 45 46BrowserContextKeyedService* ManagedUserServiceFactory::BuildServiceInstanceFor( 47 content::BrowserContext* profile) const { 48 return BuildInstanceFor(static_cast<Profile*>(profile)); 49} 50