This source file includes following definitions.
- SetDelegate
- Shutdown
- RefreshPolicies
- OnUpdatePolicy
#include "components/policy/core/common/proxy_policy_provider.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "components/policy/core/common/policy_bundle.h"
namespace policy {
ProxyPolicyProvider::ProxyPolicyProvider() : delegate_(NULL) {}
ProxyPolicyProvider::~ProxyPolicyProvider() {
DCHECK(!delegate_);
}
void ProxyPolicyProvider::SetDelegate(ConfigurationPolicyProvider* delegate) {
if (delegate_)
delegate_->RemoveObserver(this);
delegate_ = delegate;
if (delegate_) {
delegate_->AddObserver(this);
OnUpdatePolicy(delegate_);
} else {
UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
}
}
void ProxyPolicyProvider::Shutdown() {
if (delegate_) {
delegate_->RemoveObserver(this);
delegate_ = NULL;
}
ConfigurationPolicyProvider::Shutdown();
}
void ProxyPolicyProvider::RefreshPolicies() {
if (delegate_) {
delegate_->RefreshPolicies();
} else {
scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
bundle->CopyFrom(policies());
UpdatePolicy(bundle.Pass());
}
}
void ProxyPolicyProvider::OnUpdatePolicy(
ConfigurationPolicyProvider* provider) {
DCHECK_EQ(delegate_, provider);
scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
bundle->CopyFrom(delegate_->policies());
UpdatePolicy(bundle.Pass());
}
}