- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / managed_mode / managed_user_service_factory.cc
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
14 ManagedUserService* ManagedUserServiceFactory::GetForProfile(Profile* profile) {
15   return static_cast<ManagedUserService*>(
16       GetInstance()->GetServiceForBrowserContext(profile, true));
17 }
18
19 // static
20 ManagedUserServiceFactory* ManagedUserServiceFactory::GetInstance() {
21   return Singleton<ManagedUserServiceFactory>::get();
22 }
23
24 // static
25 BrowserContextKeyedService* ManagedUserServiceFactory::BuildInstanceFor(
26     Profile* profile) {
27   return new ManagedUserService(profile);
28 }
29
30 ManagedUserServiceFactory::ManagedUserServiceFactory()
31     : BrowserContextKeyedServiceFactory(
32         "ManagedUserService",
33         BrowserContextDependencyManager::GetInstance()) {
34   DependsOn(extensions::ExtensionSystemFactory::GetInstance());
35 }
36
37 ManagedUserServiceFactory::~ManagedUserServiceFactory() {}
38
39 content::BrowserContext* ManagedUserServiceFactory::GetBrowserContextToUse(
40     content::BrowserContext* context) const {
41   return chrome::GetBrowserContextRedirectedInIncognito(context);
42 }
43
44 BrowserContextKeyedService* ManagedUserServiceFactory::BuildServiceInstanceFor(
45     content::BrowserContext* profile) const {
46   return BuildInstanceFor(static_cast<Profile*>(profile));
47 }