Upstream version 5.34.104.0
[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/managed_mode/managed_user_service.h"
8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
11 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
12 #include "extensions/browser/extension_system_provider.h"
13 #include "extensions/browser/extensions_browser_client.h"
14
15 // static
16 ManagedUserService* ManagedUserServiceFactory::GetForProfile(Profile* profile) {
17   return static_cast<ManagedUserService*>(
18       GetInstance()->GetServiceForBrowserContext(profile, true));
19 }
20
21 // static
22 ManagedUserServiceFactory* ManagedUserServiceFactory::GetInstance() {
23   return Singleton<ManagedUserServiceFactory>::get();
24 }
25
26 // static
27 BrowserContextKeyedService* ManagedUserServiceFactory::BuildInstanceFor(
28     Profile* profile) {
29   return new ManagedUserService(profile);
30 }
31
32 ManagedUserServiceFactory::ManagedUserServiceFactory()
33     : BrowserContextKeyedServiceFactory(
34         "ManagedUserService",
35         BrowserContextDependencyManager::GetInstance()) {
36   DependsOn(
37       extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
38   DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
39 }
40
41 ManagedUserServiceFactory::~ManagedUserServiceFactory() {}
42
43 content::BrowserContext* ManagedUserServiceFactory::GetBrowserContextToUse(
44     content::BrowserContext* context) const {
45   return chrome::GetBrowserContextRedirectedInIncognito(context);
46 }
47
48 BrowserContextKeyedService* ManagedUserServiceFactory::BuildServiceInstanceFor(
49     content::BrowserContext* profile) const {
50   return BuildInstanceFor(static_cast<Profile*>(profile));
51 }