Chromium Code Reviews| Index: chrome/browser/policy/forwarding_policy_provider.h |
| diff --git a/chrome/browser/policy/forwarding_policy_provider.h b/chrome/browser/policy/forwarding_policy_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cf5b236749879004903a1480f631f3daec14eeb5 |
| --- /dev/null |
| +++ b/chrome/browser/policy/forwarding_policy_provider.h |
| @@ -0,0 +1,54 @@ |
| +// Copyright (c) 2013 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. |
| + |
| +#ifndef CHROME_BROWSER_POLICY_FORWARDING_POLICY_PROVIDER_H_ |
| +#define CHROME_BROWSER_POLICY_FORWARDING_POLICY_PROVIDER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| +#include "chrome/browser/policy/configuration_policy_provider.h" |
| +#include "components/policy/core/common/policy_namespace.h" |
| + |
| +namespace policy { |
| + |
| +// A policy provider that forwards calls to another provider. |
| +// This provider also tracks the SchemaRegistry, and becomes ready after making |
| +// sure the delegate provider has refreshed its policies with an updated view |
| +// of the complete schema. It is expected that the delegate's SchemaRegistry |
| +// is a CombinedSchemaRegistry tracking the forwarding provider's registry. |
| +class ForwardingPolicyProvider : public ConfigurationPolicyProvider, |
| + public ConfigurationPolicyProvider::Observer { |
| + public: |
| + // The |delegate| must outlive this provider. |
| + explicit ForwardingPolicyProvider(ConfigurationPolicyProvider* delegate); |
| + virtual ~ForwardingPolicyProvider(); |
| + |
| + // ConfigurationPolicyProvider: |
| + // Note that Init(), Shutdown(), OnSchemaRegistryUpdated() and |
|
bartfab (slow)
2013/11/11 14:40:08
I think it would be clearer to list the calls that
Joao da Silva
2013/11/12 15:26:33
Done.
|
| + // OnSchemaRegistryReady() are not forwarded to the |delegate_|. |
| + virtual void Init(SchemaRegistry* registry) OVERRIDE; |
| + virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; |
| + virtual void RefreshPolicies() OVERRIDE; |
| + virtual void OnSchemaRegistryReady() OVERRIDE; |
| + virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE; |
| + |
| + // ConfigurationPolicyProvider::Observer: |
| + virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; |
| + |
| + private: |
| + enum InitializationState { |
| + WAITING_FOR_REGISTRY_READY, |
| + WAITING_FOR_REFRESH, |
| + READY, |
| + }; |
| + |
| + ConfigurationPolicyProvider* delegate_; |
| + InitializationState state_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ForwardingPolicyProvider); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_FORWARDING_POLICY_PROVIDER_H_ |