Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1811)

Unified Diff: chrome/browser/policy/cloud_policy_cache_base.cc

Issue 6979011: Move user cloud policy to BrowserProcess. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments by mnissler. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..bd1e715d00a0894bbfa843cd13c6a0a0f8e57641 100644
--- a/chrome/browser/policy/cloud_policy_cache_base.cc
+++ b/chrome/browser/policy/cloud_policy_cache_base.cc
@@ -8,72 +8,39 @@
#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_;
+ default:
+ NOTREACHED();
+ }
+ return NULL;
}
bool CloudPolicyCacheBase::GetPublicKeyVersion(int* version) {
@@ -119,8 +86,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 +101,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(
« no previous file with comments | « chrome/browser/policy/cloud_policy_cache_base.h ('k') | chrome/browser/policy/cloud_policy_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698