Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / managed_mode / supervised_user_pref_mapping_service_factory.cc
1 // Copyright 2014 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/supervised_user_pref_mapping_service_factory.h"
6
7 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
8 #include "chrome/browser/managed_mode/supervised_user_pref_mapping_service.h"
9 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
10 #include "components/user_prefs/user_prefs.h"
11 #include "content/public/browser/browser_context.h"
12
13 // static
14 SupervisedUserPrefMappingService*
15 SupervisedUserPrefMappingServiceFactory::GetForBrowserContext(
16     content::BrowserContext* profile) {
17   return static_cast<SupervisedUserPrefMappingService*>(
18       GetInstance()->GetServiceForBrowserContext(profile, true));
19 }
20
21 // static
22 SupervisedUserPrefMappingServiceFactory*
23 SupervisedUserPrefMappingServiceFactory::GetInstance() {
24   return Singleton<SupervisedUserPrefMappingServiceFactory>::get();
25 }
26
27 SupervisedUserPrefMappingServiceFactory::
28     SupervisedUserPrefMappingServiceFactory()
29     : BrowserContextKeyedServiceFactory(
30           "SupervisedUserPrefMappingService",
31           BrowserContextDependencyManager::GetInstance()) {
32   DependsOn(ManagedUserSharedSettingsServiceFactory::GetInstance());
33 }
34
35 SupervisedUserPrefMappingServiceFactory::
36     ~SupervisedUserPrefMappingServiceFactory() {}
37
38 BrowserContextKeyedService*
39 SupervisedUserPrefMappingServiceFactory::BuildServiceInstanceFor(
40     content::BrowserContext* profile) const {
41   return new SupervisedUserPrefMappingService(
42       user_prefs::UserPrefs::Get(profile),
43       ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(profile));
44 }