| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_FORWARDING_POLICY_PROVIDER_H_ | |
| 6 #define CHROME_BROWSER_POLICY_FORWARDING_POLICY_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/compiler_specific.h" | |
| 10 #include "components/policy/core/common/configuration_policy_provider.h" | |
| 11 #include "components/policy/core/common/policy_namespace.h" | |
| 12 | |
| 13 namespace policy { | |
| 14 | |
| 15 // A policy provider that forwards calls to another provider. | |
| 16 // This provider also tracks the SchemaRegistry, and becomes ready after making | |
| 17 // sure the delegate provider has refreshed its policies with an updated view | |
| 18 // of the complete schema. It is expected that the delegate's SchemaRegistry | |
| 19 // is a CombinedSchemaRegistry tracking the forwarding provider's registry. | |
| 20 class ForwardingPolicyProvider : public ConfigurationPolicyProvider, | |
| 21 public ConfigurationPolicyProvider::Observer { | |
| 22 public: | |
| 23 // The |delegate| must outlive this provider. | |
| 24 explicit ForwardingPolicyProvider(ConfigurationPolicyProvider* delegate); | |
| 25 virtual ~ForwardingPolicyProvider(); | |
| 26 | |
| 27 // ConfigurationPolicyProvider: | |
| 28 // | |
| 29 // Note that Init() and Shutdown() are not forwarded to the |delegate_|, since | |
| 30 // this provider does not own it and its up to the |delegate_|'s owner to | |
| 31 // initialize it and shut it down. | |
| 32 // | |
| 33 // Note also that this provider may have a SchemaRegistry passed in Init() | |
| 34 // that doesn't match the |delegate_|'s; therefore OnSchemaRegistryUpdated() | |
| 35 // and OnSchemaRegistryReady() are not forwarded either. It is assumed that | |
| 36 // the |delegate_|'s SchemaRegistry contains a superset of this provider's | |
| 37 // SchemaRegistry though (i.e. it's a CombinedSchemaRegistry that contains | |
| 38 // this provider's SchemaRegistry). | |
| 39 // | |
| 40 // This provider manages its own initialization state for all policy domains | |
| 41 // except POLICY_DOMAIN_CHROME, whose status is always queried from the | |
| 42 // |delegate_|. RefreshPolicies() calls are also forwarded, since this | |
| 43 // provider doesn't have a "real" policy source of its own. | |
| 44 virtual void Init(SchemaRegistry* registry) OVERRIDE; | |
| 45 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; | |
| 46 virtual void RefreshPolicies() OVERRIDE; | |
| 47 virtual void OnSchemaRegistryReady() OVERRIDE; | |
| 48 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE; | |
| 49 | |
| 50 // ConfigurationPolicyProvider::Observer: | |
| 51 virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE; | |
| 52 | |
| 53 private: | |
| 54 enum InitializationState { | |
| 55 WAITING_FOR_REGISTRY_READY, | |
| 56 WAITING_FOR_REFRESH, | |
| 57 READY, | |
| 58 }; | |
| 59 | |
| 60 ConfigurationPolicyProvider* delegate_; | |
| 61 InitializationState state_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ForwardingPolicyProvider); | |
| 64 }; | |
| 65 | |
| 66 } // namespace policy | |
| 67 | |
| 68 #endif // CHROME_BROWSER_POLICY_FORWARDING_POLICY_PROVIDER_H_ | |
| OLD | NEW |