| Index: chrome/browser/policy/proxy_policy_provider.cc
|
| diff --git a/chrome/browser/policy/proxy_policy_provider.cc b/chrome/browser/policy/proxy_policy_provider.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a019b08856af7396ab578415bc74c34e459242bd
|
| --- /dev/null
|
| +++ b/chrome/browser/policy/proxy_policy_provider.cc
|
| @@ -0,0 +1,48 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/policy/proxy_policy_provider.h"
|
| +
|
| +#include "policy/policy_constants.h"
|
| +
|
| +namespace policy {
|
| +
|
| +ProxyPolicyProvider::ProxyPolicyProvider()
|
| + : ConfigurationPolicyProvider(GetChromePolicyDefinitionList()) {}
|
| +
|
| +ProxyPolicyProvider::~ProxyPolicyProvider() {}
|
| +
|
| +void ProxyPolicyProvider::SetDelegate(ConfigurationPolicyProvider* delegate) {
|
| + if (delegate) {
|
| + registrar_.reset(new ConfigurationPolicyObserverRegistrar());
|
| + registrar_->Init(delegate, this);
|
| + OnUpdatePolicy(delegate);
|
| + } else {
|
| + registrar_.reset();
|
| + UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
|
| + }
|
| +}
|
| +
|
| +void ProxyPolicyProvider::RefreshPolicies() {
|
| + if (registrar_.get())
|
| + registrar_->provider()->RefreshPolicies();
|
| + else
|
| + UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
|
| +}
|
| +
|
| +void ProxyPolicyProvider::OnUpdatePolicy(
|
| + ConfigurationPolicyProvider* provider) {
|
| + DCHECK_EQ(registrar_->provider(), provider);
|
| + scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
|
| + bundle->CopyFrom(registrar_->provider()->policies());
|
| + UpdatePolicy(bundle.Pass());
|
| +}
|
| +
|
| +void ProxyPolicyProvider::OnProviderGoingAway(
|
| + ConfigurationPolicyProvider* provider) {
|
| + registrar_.reset();
|
| + UpdatePolicy(scoped_ptr<PolicyBundle>(new PolicyBundle()));
|
| +}
|
| +
|
| +} // namespace policy
|
|
|