Chromium Code Reviews| Index: chrome/browser/policy/cloud_policy_cache.h |
| diff --git a/chrome/browser/policy/device_management_policy_cache.h b/chrome/browser/policy/cloud_policy_cache.h |
| similarity index 61% |
| rename from chrome/browser/policy/device_management_policy_cache.h |
| rename to chrome/browser/policy/cloud_policy_cache.h |
| index 50441eb27ff37cbc59e3221e7d7c3fc96e017a2b..bca9446b4d142546db5f43bb7f51e0595db5d2c5 100644 |
| --- a/chrome/browser/policy/device_management_policy_cache.h |
| +++ b/chrome/browser/policy/cloud_policy_cache.h |
| @@ -2,15 +2,16 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_CACHE_H_ |
| -#define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_CACHE_H_ |
| +#ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ |
| +#define CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ |
| #include "base/file_path.h" |
| #include "base/gtest_prod_util.h" |
| +#include "base/observer_list.h" |
| #include "base/ref_counted.h" |
| #include "base/scoped_ptr.h" |
| -#include "base/synchronization/lock.h" |
| #include "base/time.h" |
| +#include "chrome/browser/policy/configuration_policy_provider.h" |
| #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| class DictionaryValue; |
| @@ -25,22 +26,29 @@ namespace em = enterprise_management; |
| // to the service directly, but receives updated policy information through |
| // SetPolicy() calls, which is then persisted and decoded into the internal |
| // Value representation chrome uses. |
| -class DeviceManagementPolicyCache { |
| +class CloudPolicyCache { |
|
danno
2011/02/04 16:01:33
CloudPolicyOracle? :-)
Jakob Kummerow
2011/02/14 13:50:34
Nope.
|
| public: |
| - explicit DeviceManagementPolicyCache(const FilePath& backing_file_path); |
| - ~DeviceManagementPolicyCache(); |
| + // Used to distinguish mandatory from recommended policies. |
| + enum PolicyLevel { |
| + // Policy is forced upon the user and should always take effect. |
| + POLICY_LEVEL_MANDATORY, |
| + // The value is just a recommendation that the user may override. |
| + POLICY_LEVEL_RECOMMENDED, |
| + }; |
| + |
| + explicit CloudPolicyCache(const FilePath& backing_file_path); |
| + ~CloudPolicyCache(); |
| // Loads policy information from the backing file. Non-existing or erroneous |
| // cache files are ignored. |
| - void LoadPolicyFromFile(); |
| + void LoadFromFile(); |
| // Resets the policy information. Returns true if the new policy is different |
| // from the previously stored policy. |
| bool SetPolicy(const em::DevicePolicyResponse& policy); |
| - // Gets the policy information. Ownership of the return value is transferred |
| - // to the caller. |
| - DictionaryValue* GetPolicy(); |
| + ConfigurationPolicyProvider* GetManagedPolicyProvider(); |
| + ConfigurationPolicyProvider* GetRecommendedPolicyProvider(); |
| void SetDeviceUnmanaged(); |
| bool is_device_unmanaged() const { |
| @@ -53,8 +61,10 @@ class DeviceManagementPolicyCache { |
| } |
| private: |
| - friend class DeviceManagementPolicyCacheDecodeTest; |
| - FRIEND_TEST_ALL_PREFIXES(DeviceManagementPolicyCacheDecodeTest, DecodePolicy); |
| + class CloudPolicyProvider; |
| + |
| + friend class CloudPolicyCacheDecodeTest; |
| + FRIEND_TEST_ALL_PREFIXES(CloudPolicyCacheDecodeTest, DecodePolicy); |
| // Decodes an int64 value. Checks whether the passed value fits the numeric |
| // limits of the value representation. Returns a value (ownership is |
| @@ -73,22 +83,28 @@ class DeviceManagementPolicyCache { |
| // The file in which we store a cached version of the policy information. |
| const FilePath backing_file_path_; |
| - // Protects |policy_|. |
| - base::Lock lock_; |
| - |
| // Policy key-value information. |
| scoped_ptr<DictionaryValue> policy_; |
| - // Tracks whether the store received a SetPolicy() call, which overrides any |
| - // information loaded from the file. |
| - bool fresh_policy_; |
| + // Whether initialization has been completed. This is the case when we have |
| + // valid policy, learned that the device is unmanaged or ran into |
| + // unrecoverrable errors. |
| + bool initialization_complete_; |
| + // Whether the the server has indicated this device is unmanaged. |
| bool is_device_unmanaged_; |
| // The time at which the policy was last refreshed. |
| base::Time last_policy_refresh_time_; |
| + |
| + // Policy providers. |
| + scoped_ptr<ConfigurationPolicyProvider> managed_policy_provider_; |
| + scoped_ptr<ConfigurationPolicyProvider> recommended_policy_provider_; |
| + |
| + // Provider observers that are registered with this cache's providers. |
| + ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; |
| }; |
| } // namespace policy |
| -#endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_CACHE_H_ |
| +#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CACHE_H_ |