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