Index: chrome/browser/policy/cloud_policy_cache_base.cc |
diff --git a/chrome/browser/policy/cloud_policy_cache_base.cc b/chrome/browser/policy/cloud_policy_cache_base.cc |
index 5fdf08ed3fa60c3ac5e8efd23457681e151f8e03..1bf5c04fc7c68d17cb970ace0d63fe359cf08ad2 100644 |
--- a/chrome/browser/policy/cloud_policy_cache_base.cc |
+++ b/chrome/browser/policy/cloud_policy_cache_base.cc |
@@ -8,72 +8,38 @@ |
#include "base/logging.h" |
#include "base/values.h" |
-#include "chrome/browser/policy/configuration_policy_pref_store.h" |
#include "chrome/browser/policy/policy_notifier.h" |
namespace policy { |
-// A thin ConfigurationPolicyProvider implementation sitting on top of |
-// CloudPolicyCacheBase for hooking up with ConfigurationPolicyPrefStore. |
-class CloudPolicyCacheBase::CloudPolicyProvider |
- : public ConfigurationPolicyProvider { |
- public: |
- CloudPolicyProvider(const PolicyDefinitionList* policy_list, |
- CloudPolicyCacheBase* cache, |
- CloudPolicyCacheBase::PolicyLevel level) |
- : ConfigurationPolicyProvider(policy_list), |
- cache_(cache), |
- level_(level) {} |
- virtual ~CloudPolicyProvider() {} |
- |
- virtual bool Provide(ConfigurationPolicyStoreInterface* store) { |
- if (level_ == POLICY_LEVEL_MANDATORY) |
- ApplyPolicyMap(&cache_->mandatory_policy_, store); |
- else if (level_ == POLICY_LEVEL_RECOMMENDED) |
- ApplyPolicyMap(&cache_->recommended_policy_, store); |
- return true; |
- } |
- |
- virtual bool IsInitializationComplete() const { |
- return cache_->initialization_complete_; |
- } |
- |
- virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer) { |
- cache_->observer_list_.AddObserver(observer); |
- } |
- virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer) { |
- cache_->observer_list_.RemoveObserver(observer); |
- } |
- |
- private: |
- // The underlying policy cache. |
- CloudPolicyCacheBase* cache_; |
- // Policy level this provider will handle. |
- CloudPolicyCacheBase::PolicyLevel level_; |
- |
- DISALLOW_COPY_AND_ASSIGN(CloudPolicyProvider); |
-}; |
- |
CloudPolicyCacheBase::CloudPolicyCacheBase() |
: notifier_(NULL), |
initialization_complete_(false), |
is_unmanaged_(false) { |
public_key_version_.valid = false; |
- managed_policy_provider_.reset( |
- new CloudPolicyProvider( |
- ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
- this, |
- POLICY_LEVEL_MANDATORY)); |
- recommended_policy_provider_.reset( |
- new CloudPolicyProvider( |
- ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(), |
- this, |
- POLICY_LEVEL_RECOMMENDED)); |
} |
CloudPolicyCacheBase::~CloudPolicyCacheBase() { |
- FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
- observer_list_, OnProviderGoingAway()); |
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheGoingAway(this)); |
+} |
+ |
+void CloudPolicyCacheBase::AddObserver(Observer* observer) { |
+ observer_list_.AddObserver(observer); |
+} |
+ |
+void CloudPolicyCacheBase::RemoveObserver(Observer* observer) { |
+ observer_list_.RemoveObserver(observer); |
+} |
+ |
+const PolicyMap* CloudPolicyCacheBase::policy(PolicyLevel level) { |
+ switch (level) { |
+ case POLICY_LEVEL_MANDATORY: |
+ return &mandatory_policy_; |
+ case POLICY_LEVEL_RECOMMENDED: |
+ return &recommended_policy_; |
+ } |
+ NOTREACHED(); |
+ return NULL; |
} |
bool CloudPolicyCacheBase::GetPublicKeyVersion(int* version) { |
@@ -119,8 +85,7 @@ bool CloudPolicyCacheBase::SetPolicyInternal( |
initialization_complete_ = true; |
if (new_policy_differs || initialization_was_not_complete) { |
- FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
- observer_list_, OnUpdatePolicy()); |
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheUpdate(this)); |
} |
InformNotifier(CloudPolicySubsystem::SUCCESS, |
CloudPolicySubsystem::NO_DETAILS); |
@@ -135,19 +100,7 @@ void CloudPolicyCacheBase::SetUnmanagedInternal(const base::Time& timestamp) { |
recommended_policy_.Clear(); |
last_policy_refresh_time_ = timestamp; |
- FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer, |
- observer_list_, OnUpdatePolicy()); |
-} |
- |
-ConfigurationPolicyProvider* CloudPolicyCacheBase::GetManagedPolicyProvider() { |
- DCHECK(CalledOnValidThread()); |
- return managed_policy_provider_.get(); |
-} |
- |
-ConfigurationPolicyProvider* |
- CloudPolicyCacheBase::GetRecommendedPolicyProvider() { |
- DCHECK(CalledOnValidThread()); |
- return recommended_policy_provider_.get(); |
+ FOR_EACH_OBSERVER(Observer, observer_list_, OnCacheUpdate(this)); |
} |
bool CloudPolicyCacheBase::DecodePolicyResponse( |