| 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/macros.h" | 12 #include "base/macros.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 15 | 15 |
| 16 namespace user_manager { | 16 namespace user_manager { |
| 17 class User; | 17 class User; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace policy { | 20 namespace policy { |
| 21 | 21 |
| 22 class CloudPolicyManager; | 22 class CloudPolicyStore; |
| 23 class ConfigurationPolicyProvider; | 23 class ConfigurationPolicyProvider; |
| 24 class PolicyService; | 24 class PolicyService; |
| 25 class SchemaRegistry; | 25 class SchemaRegistry; |
| 26 | 26 |
| 27 // A KeyedService that creates and manages the per-Profile policy | 27 // A KeyedService that creates and manages the per-Profile policy components. |
| 28 // components. | |
| 29 class ProfilePolicyConnector : public KeyedService { | 28 class ProfilePolicyConnector : public KeyedService { |
| 30 public: | 29 public: |
| 31 ProfilePolicyConnector(); | 30 ProfilePolicyConnector(); |
| 32 ~ProfilePolicyConnector() override; | 31 ~ProfilePolicyConnector() override; |
| 33 | 32 |
| 34 void Init( | 33 // |user| is only used in Chrome OS builds and should be set to nullptr |
| 35 #if defined(OS_CHROMEOS) | 34 // otherwise. |configuration_policy_provider| and |policy_store| are nullptr |
| 36 const user_manager::User* user, | 35 // for non-regular users. |
| 37 #endif | 36 void Init(const user_manager::User* user, |
| 38 SchemaRegistry* schema_registry, | 37 SchemaRegistry* schema_registry, |
| 39 CloudPolicyManager* user_cloud_policy_manager); | 38 ConfigurationPolicyProvider* configuration_policy_provider, |
| 39 const CloudPolicyStore* policy_store); |
| 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 // Returns the cloud policy management domain or the Active Directory realm |
| 55 // cloud policy management. Otherwise returns an empty string. You must call | 55 // for managed Profiles or an empty string for unmanaged Profiles. You must |
| 56 // this method only when the policies system is fully initialized. | 56 // call this method only when the policies system is fully initialized. |
| 57 std::string GetManagementDomain() const; | 57 std::string GetManagementDomain() const; |
| 58 | 58 |
| 59 // Returns true if the |name| Chrome user policy is currently set via the | 59 // Returns true if the |policy_key| user policy is currently set via the |
| 60 // CloudPolicyManager and isn't being overridden by a higher-level provider. | 60 // |configuration_policy_provider_| and isn't being overridden by a |
| 61 bool IsPolicyFromCloudPolicy(const char* name) const; | 61 // higher-level provider. |
| 62 bool IsProfilePolicy(const char* policy_key) const; |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 // Find the policy provider that provides the |name| Chrome policy, if any. In | 65 // Find the policy provider that provides the |policy_key| policy, if any. In |
| 65 // case of multiple providers sharing the same policy, the one with the | 66 // case of multiple providers sharing the same policy, the one with the |
| 66 // highest priority will be returned. | 67 // highest priority will be returned. |
| 67 const ConfigurationPolicyProvider* DeterminePolicyProviderForPolicy( | 68 const ConfigurationPolicyProvider* DeterminePolicyProviderForPolicy( |
| 68 const char* name) const; | 69 const char* policy_key) const; |
| 69 | 70 |
| 70 #if defined(OS_CHROMEOS) | 71 #if defined(OS_CHROMEOS) |
| 71 // Some of the user policy configuration affects browser global state, and | 72 // 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 // 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 // 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 | 75 // Profile's policy is the one that affects global policy settings in |
| 75 // local state. | 76 // local state. |
| 76 bool is_primary_user_; | 77 bool is_primary_user_ = false; |
| 77 | 78 |
| 78 std::unique_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; | 79 std::unique_ptr<ConfigurationPolicyProvider> special_user_policy_provider_; |
| 79 #endif // defined(OS_CHROMEOS) | 80 #endif // defined(OS_CHROMEOS) |
| 80 | 81 |
| 81 std::unique_ptr<ConfigurationPolicyProvider> | 82 std::unique_ptr<ConfigurationPolicyProvider> |
| 82 wrapped_platform_policy_provider_; | 83 wrapped_platform_policy_provider_; |
| 83 CloudPolicyManager* user_cloud_policy_manager_; | 84 const ConfigurationPolicyProvider* configuration_policy_provider_ = nullptr; |
| 85 const CloudPolicyStore* policy_store_ = nullptr; |
| 84 | 86 |
| 85 // |policy_providers_| contains a list of the policy providers available for | 87 // |policy_providers_| contains a list of the policy providers available for |
| 86 // the PolicyService of this connector, in decreasing order of priority. | 88 // the PolicyService of this connector, in decreasing order of priority. |
| 87 // | 89 // |
| 88 // Note: All the providers appended to this vector must eventually become | 90 // Note: All the providers appended to this vector must eventually become |
| 89 // initialized for every policy domain, otherwise some subsystems will never | 91 // initialized for every policy domain, otherwise some subsystems will never |
| 90 // use the policies exposed by the PolicyService! | 92 // use the policies exposed by the PolicyService! |
| 91 // The default ConfigurationPolicyProvider::IsInitializationComplete() | 93 // The default ConfigurationPolicyProvider::IsInitializationComplete() |
| 92 // result is true, so take care if a provider overrides that. | 94 // result is true, so take care if a provider overrides that. |
| 93 std::vector<ConfigurationPolicyProvider*> policy_providers_; | 95 std::vector<ConfigurationPolicyProvider*> policy_providers_; |
| 94 | 96 |
| 95 std::unique_ptr<PolicyService> policy_service_; | 97 std::unique_ptr<PolicyService> policy_service_; |
| 96 std::unique_ptr<bool> is_managed_override_; | 98 std::unique_ptr<bool> is_managed_override_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); | 100 DISALLOW_COPY_AND_ASSIGN(ProfilePolicyConnector); |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 } // namespace policy | 103 } // namespace policy |
| 102 | 104 |
| 103 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ | 105 #endif // CHROME_BROWSER_POLICY_PROFILE_POLICY_CONNECTOR_H_ |
| OLD | NEW |