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.
5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_
6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/keyed_service/core/keyed_service.h"
15 namespace user_manager
{
21 class CloudPolicyManager
;
22 class ConfigurationPolicyProvider
;
26 // A KeyedService that creates and manages the per-Profile policy
28 class ProfilePolicyConnector
: public KeyedService
{
30 ProfilePolicyConnector();
31 ~ProfilePolicyConnector() override
;
34 #if defined(OS_CHROMEOS)
35 const user_manager::User
* user
,
37 SchemaRegistry
* schema_registry
,
38 CloudPolicyManager
* user_cloud_policy_manager
);
40 void InitForTesting(scoped_ptr
<PolicyService
> service
);
41 void OverrideIsManagedForTesting(bool is_managed
);
44 void Shutdown() override
;
46 // This is never NULL.
47 PolicyService
* policy_service() const { return policy_service_
.get(); }
49 // Returns true if this Profile is under cloud policy management. You must
50 // call this method only when the policies system is fully initialized.
51 bool IsManaged() const;
53 // Returns the cloud policy management domain, if this Profile is under
54 // cloud policy management. Otherwise returns an empty string. You must call
55 // this method only when the policies system is fully initialized.
56 std::string
GetManagementDomain() const;
58 // Returns true if the |name| Chrome user policy is currently set via the
59 // CloudPolicyManager and isn't being overridden by a higher-level provider.
60 bool IsPolicyFromCloudPolicy(const char* name
) const;
63 // Find the policy provider that provides the |name| Chrome policy, if any. In
64 // case of multiple providers sharing the same policy, the one with the
65 // highest priority will be returned.
66 const ConfigurationPolicyProvider
* DeterminePolicyProviderForPolicy(
67 const char* name
) const;
69 #if defined(ENABLE_CONFIGURATION_POLICY)
70 #if defined(OS_CHROMEOS)
71 // Some of the user policy configuration affects browser global state, and
72 // can only come from one Profile. |is_primary_user_| is true if this
73 // connector belongs to the first signed-in Profile, and in that case that
74 // Profile's policy is the one that affects global policy settings in
76 bool is_primary_user_
;
78 scoped_ptr
<ConfigurationPolicyProvider
> special_user_policy_provider_
;
79 #endif // defined(OS_CHROMEOS)
81 scoped_ptr
<ConfigurationPolicyProvider
> wrapped_platform_policy_provider_
;
82 CloudPolicyManager
* user_cloud_policy_manager_
;
83 #endif // defined(ENABLE_CONFIGURATION_POLICY)
85 // |policy_providers_| contains a list of the policy providers available for
86 // the PolicyService of this connector, in decreasing order of priority.
88 // Note: All the providers appended to this vector must eventually become
89 // initialized for every policy domain, otherwise some subsystems will never
90 // use the policies exposed by the PolicyService!
91 // The default ConfigurationPolicyProvider::IsInitializationComplete()
92 // result is true, so take care if a provider overrides that.
93 std::vector
<ConfigurationPolicyProvider
*> policy_providers_
;
95 scoped_ptr
<PolicyService
> policy_service_
;
96 scoped_ptr
<bool> is_managed_override_
;
98 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector
);
101 } // namespace policy
103 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_