| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CONFIGURATION_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "policy/configuration_policy_type.h" | |
| 17 | 16 |
| 18 namespace policy { | 17 namespace policy { |
| 19 | 18 |
| 20 struct PolicyDefinitionList; | 19 struct PolicyDefinitionList; |
| 21 class PolicyMap; | 20 class PolicyMap; |
| 22 | 21 |
| 23 // A mostly-abstract super class for platform-specific policy providers. | 22 // A mostly-abstract super class for platform-specific policy providers. |
| 24 // Platform-specific policy providers (Windows Group Policy, gconf, | 23 // Platform-specific policy providers (Windows Group Policy, gconf, |
| 25 // etc.) should implement a subclass of this class. | 24 // etc.) should implement a subclass of this class. |
| 26 class ConfigurationPolicyProvider { | 25 class ConfigurationPolicyProvider { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 54 void OverridePolicies(PolicyMap* policies); | 53 void OverridePolicies(PolicyMap* policies); |
| 55 #endif | 54 #endif |
| 56 | 55 |
| 57 // Asks the provider to refresh its policies. All the updates caused by this | 56 // Asks the provider to refresh its policies. All the updates caused by this |
| 58 // call will be visible on the next call of OnUpdatePolicy on the observers, | 57 // call will be visible on the next call of OnUpdatePolicy on the observers, |
| 59 // which are guaranteed to happen even if the refresh fails. | 58 // which are guaranteed to happen even if the refresh fails. |
| 60 // It is possible that OnProviderGoingAway is called first though, and | 59 // It is possible that OnProviderGoingAway is called first though, and |
| 61 // OnUpdatePolicy won't be called if that happens. | 60 // OnUpdatePolicy won't be called if that happens. |
| 62 virtual void RefreshPolicies() = 0; | 61 virtual void RefreshPolicies() = 0; |
| 63 | 62 |
| 63 // Utility method that converts deprecated policies into their corresponding |
| 64 // actual policies. Subclasses can use this to fix deprecated policies in |
| 65 // PolicyMaps that they obtained from elsewhere. |
| 66 static void FixDeprecatedPolicies(PolicyMap* policies); |
| 67 |
| 64 protected: | 68 protected: |
| 65 // Sends a policy update notification to observers. | 69 // Sends a policy update notification to observers. |
| 66 void NotifyPolicyUpdated(); | 70 void NotifyPolicyUpdated(); |
| 67 | 71 |
| 68 // Must be implemented by subclasses to provide their policy values. The | 72 // Must be implemented by subclasses to provide their policy values. The |
| 69 // values actually provided by |Provide| can be overridden using | 73 // values actually provided by |Provide| can be overridden using |
| 70 // |OverridePolicies|. | 74 // |OverridePolicies|. |
| 71 virtual bool ProvideInternal(PolicyMap* result) = 0; | 75 virtual bool ProvideInternal(PolicyMap* result) = 0; |
| 72 | 76 |
| 73 // Utility method that converts deprecated policies into their corresponding | |
| 74 // actual policies. Subclasses can use this to fix deprecated policies in | |
| 75 // PolicyMaps that they obtained from elsewhere. | |
| 76 static void FixDeprecatedPolicies(PolicyMap* policies); | |
| 77 | |
| 78 const PolicyDefinitionList* policy_definition_list() const { | 77 const PolicyDefinitionList* policy_definition_list() const { |
| 79 return policy_definition_list_; | 78 return policy_definition_list_; |
| 80 } | 79 } |
| 81 | 80 |
| 82 private: | 81 private: |
| 83 friend class ConfigurationPolicyObserverRegistrar; | 82 friend class ConfigurationPolicyObserverRegistrar; |
| 84 | 83 |
| 85 virtual void AddObserver(Observer* observer); | 84 virtual void AddObserver(Observer* observer); |
| 86 virtual void RemoveObserver(Observer* observer); | 85 virtual void RemoveObserver(Observer* observer); |
| 87 | 86 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 private: | 120 private: |
| 122 ConfigurationPolicyProvider* provider_; | 121 ConfigurationPolicyProvider* provider_; |
| 123 ConfigurationPolicyProvider::Observer* observer_; | 122 ConfigurationPolicyProvider::Observer* observer_; |
| 124 | 123 |
| 125 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); | 124 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 } // namespace policy | 127 } // namespace policy |
| 129 | 128 |
| 130 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ | 129 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ |
| OLD | NEW |