OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 6 #define CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
15 | 16 |
16 namespace user_manager { | 17 namespace user_manager { |
17 class User; | 18 class User; |
18 } | 19 } |
19 | 20 |
20 namespace policy { | 21 namespace policy { |
21 | 22 |
22 class CloudPolicyManager; | 23 class CloudPolicyStore; |
23 class ConfigurationPolicyProvider; | 24 class ConfigurationPolicyProvider; |
24 class PolicyService; | 25 class PolicyService; |
25 class SchemaRegistry; | 26 class SchemaRegistry; |
26 | 27 |
27 // A KeyedService that creates and manages the per-Profile policy | 28 // A KeyedService that creates and manages the per-Profile policy components. |
28 // components. | |
29 class ProfilePolicyConnector : public KeyedService { | 29 class ProfilePolicyConnector : public KeyedService { |
30 public: | 30 public: |
31 ProfilePolicyConnector(); | 31 ProfilePolicyConnector(); |
32 ~ProfilePolicyConnector() override; | 32 ~ProfilePolicyConnector() override; |
33 | 33 |
34 void Init( | 34 // |user| is only used in Chrome OS builds and should be set to nullptr |
35 #if defined(OS_CHROMEOS) | 35 // otherwise. |
36 const user_manager::User* user, | 36 void Init(const user_manager::User* user, |
37 #endif | 37 SchemaRegistry* schema_registry, |
38 SchemaRegistry* schema_registry, | 38 ConfigurationPolicyProvider* configuration_policy_provider, |
39 CloudPolicyManager* user_cloud_policy_manager); | 39 const CloudPolicyStore* policy_store); |
emaxx
2016/12/28 19:09:20
nit: Document that policy_store may be null? (and
Thiemo Nagel
2016/12/29 15:08:27
Done.
| |
40 | 40 |
41 void InitForTesting(std::unique_ptr<PolicyService> service); | 41 void InitForTesting(std::unique_ptr<PolicyService> service); |
42 void OverrideIsManagedForTesting(bool is_managed); | 42 void OverrideIsManagedForTesting(bool is_managed); |
43 | 43 |
44 // KeyedService: | 44 // KeyedService: |
45 void Shutdown() override; | 45 void Shutdown() override; |
46 | 46 |
47 // This is never NULL. | 47 // This is never NULL. |
48 PolicyService* policy_service() const { return policy_service_.get(); } | 48 PolicyService* policy_service() const { return policy_service_.get(); } |
49 | 49 |
50 // Returns true if this Profile is under cloud policy management. You must | 50 // Returns true if this Profile is under any kind of policy management. You |
51 // call this method only when the policies system is fully initialized. | 51 // must call this method only when the policies system is fully initialized. |
52 bool IsManaged() const; | 52 bool IsManaged() const; |
53 | 53 |
54 // Returns the cloud policy management domain, if this Profile is under | 54 // If |configuration_policy_provider_| contains kManagedBookmarks the cloud |
55 // cloud policy management. Otherwise returns an empty string. You must call | 55 // policy management domain or the Active Directory realm that this Profile is |
56 // this method only when the policies system is fully initialized. | 56 // managed by is returned. Otherwise and for unmanaged Profiles an empty |
57 // string is returned. You must call this method only when the policies system | |
58 // is fully initialized. | |
59 std::string GetDisplayDomainForManagedBookmarks() const; | |
emaxx
2016/12/28 19:09:20
This method looks alien to this class.
I don't fee
Thiemo Nagel
2016/12/29 15:08:27
OK, reverting this part. (I don't understand the
| |
60 | |
61 private: | |
62 FRIEND_TEST_ALL_PREFIXES(ProfilePolicyConnectorTest, | |
63 IsManagedForManagedUsers); | |
64 FRIEND_TEST_ALL_PREFIXES(ProfilePolicyConnectorTest, IsProfilePolicy); | |
65 | |
66 // Returns the cloud policy management domain or the Active Directory realm | |
67 // for managed Profiles or an empty string for unmanaged Profiles. You must | |
68 // call this method only when the policies system is fully initialized. | |
57 std::string GetManagementDomain() const; | 69 std::string GetManagementDomain() const; |
58 | 70 |
59 // Returns true if the |name| Chrome user policy is currently set via the | 71 // Returns true if this Profile is under policy management. You must call this |
60 // CloudPolicyManager and isn't being overridden by a higher-level provider. | 72 // method only when the policies system is fully initialized. |
61 bool IsPolicyFromCloudPolicy(const char* name) const; | 73 bool IsProfilePolicy(const char* name) const; |
62 | 74 |
63 private: | |
64 // Find the policy provider that provides the |name| Chrome policy, if any. In | 75 // Find the policy provider that provides the |name| Chrome policy, if any. In |
65 // case of multiple providers sharing the same policy, the one with the | 76 // case of multiple providers sharing the same policy, the one with the |
66 // highest priority will be returned. | 77 // highest priority will be returned. |
67 const ConfigurationPolicyProvider* DeterminePolicyProviderForPolicy( | 78 const ConfigurationPolicyProvider* DeterminePolicyProviderForPolicy( |
68 const char* name) const; | 79 const char* name) const; |
69 | 80 |
70 #if defined(OS_CHROMEOS) | 81 #if defined(OS_CHROMEOS) |
71 // Some of the user policy configuration affects browser global state, and | 82 // 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 | 83 // 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 | 84 // 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 | 85 // Profile's policy is the one that affects global policy settings in |
75 // local state. | 86 // local state. |
76 bool is_primary_user_; | 87 bool is_primary_user_ = false; |
77 | 88 |
78 std::unique_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; | 89 std::unique_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; |
79 #endif // defined(OS_CHROMEOS) | 90 #endif // defined(OS_CHROMEOS) |
80 | 91 |
81 std::unique_ptr<ConfigurationPolicyProvider> | 92 std::unique_ptr<ConfigurationPolicyProvider> |
82 wrapped_platform_policy_provider_; | 93 wrapped_platform_policy_provider_; |
83 CloudPolicyManager* user_cloud_policy_manager_; | 94 const ConfigurationPolicyProvider* configuration_policy_provider_ = nullptr; |
95 const CloudPolicyStore* policy_store_ = nullptr; | |
84 | 96 |
85 // |policy_providers_| contains a list of the policy providers available for | 97 // |policy_providers_| contains a list of the policy providers available for |
86 // the PolicyService of this connector, in decreasing order of priority. | 98 // the PolicyService of this connector, in decreasing order of priority. |
87 // | 99 // |
88 // Note: All the providers appended to this vector must eventually become | 100 // Note: All the providers appended to this vector must eventually become |
89 // initialized for every policy domain, otherwise some subsystems will never | 101 // initialized for every policy domain, otherwise some subsystems will never |
90 // use the policies exposed by the PolicyService! | 102 // use the policies exposed by the PolicyService! |
91 // The default ConfigurationPolicyProvider::IsInitializationComplete() | 103 // The default ConfigurationPolicyProvider::IsInitializationComplete() |
92 // result is true, so take care if a provider overrides that. | 104 // result is true, so take care if a provider overrides that. |
93 std::vector<ConfigurationPolicyProvider*> policy_providers_; | 105 std::vector<ConfigurationPolicyProvider*> policy_providers_; |
94 | 106 |
95 std::unique_ptr<PolicyService> policy_service_; | 107 std::unique_ptr<PolicyService> policy_service_; |
96 std::unique_ptr<bool> is_managed_override_; | 108 std::unique_ptr<bool> is_managed_override_; |
97 | 109 |
98 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); | 110 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); |
99 }; | 111 }; |
100 | 112 |
101 } // namespace policy | 113 } // namespace policy |
102 | 114 |
103 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 115 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
OLD | NEW |