forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanaged_configuration_api_factory.cc
48 lines (39 loc) · 1.74 KB
/
managed_configuration_api_factory.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/device_api/managed_configuration_api_factory.h"
#include "base/memory/singleton.h"
#include "chrome/browser/device_api/managed_configuration_api.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service_factory.h"
// static
ManagedConfigurationAPIFactory* ManagedConfigurationAPIFactory::GetInstance() {
return base::Singleton<ManagedConfigurationAPIFactory>::get();
}
// static
ManagedConfigurationAPI* ManagedConfigurationAPIFactory::GetForProfile(
Profile* profile) {
return static_cast<ManagedConfigurationAPI*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
ManagedConfigurationAPIFactory::ManagedConfigurationAPIFactory()
: BrowserContextKeyedServiceFactory(
"ManagedConfigurationAPI",
BrowserContextDependencyManager::GetInstance()) {}
ManagedConfigurationAPIFactory::~ManagedConfigurationAPIFactory() = default;
KeyedService* ManagedConfigurationAPIFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile(Profile::FromBrowserContext(context));
ManagedConfigurationAPI* api = new ManagedConfigurationAPI(profile);
return api;
}
void ManagedConfigurationAPIFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
ManagedConfigurationAPI::RegisterProfilePrefs(registry);
}
bool ManagedConfigurationAPIFactory::ServiceIsCreatedWithBrowserContext()
const {
return true;
}