OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 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/chromeos/policy/network_policy_service_factory.h" | |
6 | |
7 #include "base/memory/singleton.h" | |
8 #include "chrome/browser/chromeos/policy/network_policy_service.h" | |
9 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | |
10 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_fact ory.h" | |
11 #include "chrome/browser/profiles/profile.h" | |
12 #include "chrome/common/pref_names.h" | |
13 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" | |
14 #include "components/user_prefs/pref_registry_syncable.h" | |
15 | |
16 namespace policy { | |
17 | |
18 // static | |
19 NetworkPolicyService* NetworkPolicyServiceFactory::GetForProfile( | |
20 Profile* profile) { | |
21 return static_cast<NetworkPolicyService*>( | |
22 GetInstance()->GetServiceForBrowserContext(profile, false)); | |
23 } | |
24 | |
25 // static | |
26 scoped_ptr<PolicyCertVerifier> NetworkPolicyServiceFactory::CreateForProfile( | |
27 Profile* profile) { | |
28 DCHECK(!GetInstance()->GetServiceForBrowserContext(profile, false)); | |
29 NetworkPolicyService* service = static_cast<NetworkPolicyService*>( | |
30 GetInstance()->GetServiceForBrowserContext(profile, true)); | |
31 if (!service) | |
32 return scoped_ptr<PolicyCertVerifier>(); | |
33 return service->CreatePolicyCertVerifier(); | |
34 } | |
35 | |
36 // static | |
37 NetworkPolicyServiceFactory* NetworkPolicyServiceFactory::GetInstance() { | |
38 return Singleton<NetworkPolicyServiceFactory>::get(); | |
39 } | |
40 | |
41 NetworkPolicyServiceFactory::NetworkPolicyServiceFactory() | |
42 : BrowserContextKeyedServiceFactory( | |
43 "NetworkPolicyService", | |
44 BrowserContextDependencyManager::GetInstance()) { | |
45 DependsOn(UserNetworkConfigurationUpdaterFactory::GetInstance()); | |
46 } | |
47 | |
48 NetworkPolicyServiceFactory::~NetworkPolicyServiceFactory() {} | |
49 | |
50 BrowserContextKeyedService* | |
51 NetworkPolicyServiceFactory::BuildServiceInstanceFor( | |
52 content::BrowserContext* context) const { | |
53 Profile* profile = static_cast<Profile*>(context); | |
54 UserNetworkConfigurationUpdater* net_conf_updater = | |
55 UserNetworkConfigurationUpdaterFactory::GetForProfile(profile); | |
56 if (!net_conf_updater) | |
57 return NULL; | |
58 | |
59 // In case of usage of additional trust anchors from an incognito profile, the | |
60 // prefs of the original profile have to be marked. | |
61 return new NetworkPolicyService(net_conf_updater, | |
62 profile->GetOriginalProfile()->GetPrefs()); | |
Joao da Silva
2013/11/11 12:38:19
This factory must override GetBrowserContextToUse(
pneubeck (no reviews)
2013/11/12 10:07:53
ops.
Done.
| |
63 } | |
64 | |
65 void NetworkPolicyServiceFactory::RegisterProfilePrefs( | |
66 user_prefs::PrefRegistrySyncable* registry) { | |
67 registry->RegisterBooleanPref( | |
68 prefs::kUsedPolicyCertificatesOnce, | |
69 false, | |
70 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
71 } | |
72 | |
73 } // namespace policy | |
OLD | NEW |