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 COMPONENTS_POLICY_CORE_COMMON_FORWARDING_POLICY_PROVIDER_H_ | |
6 #define COMPONENTS_POLICY_CORE_COMMON_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 #include "components/policy/policy_export.h" | |
13 | |
14 namespace policy { | |
15 | |
16 // A policy provider that forwards calls to another provider. | |
17 // This provider also tracks the SchemaRegistry, and becomes ready after making | |
18 // sure the delegate provider has refreshed its policies with an updated view | |
19 // of the complete schema. It is expected that the delegate's SchemaRegistry | |
20 // is a CombinedSchemaRegistry tracking the forwarding provider's registry. | |
21 class POLICY_EXPORT ForwardingPolicyProvider | |
22 : public ConfigurationPolicyProvider, | |
23 public ConfigurationPolicyProvider::Observer { | |
24 public: | |
25 // The |delegate| must outlive this provider. | |
26 explicit ForwardingPolicyProvider(ConfigurationPolicyProvider* delegate); | |
27 ~ForwardingPolicyProvider() override; | |
28 | |
29 // ConfigurationPolicyProvider: | |
30 // | |
31 // Note that Init() and Shutdown() are not forwarded to the |delegate_|, since | |
32 // this provider does not own it and its up to the |delegate_|'s owner to | |
33 // initialize it and shut it down. | |
34 // | |
35 // Note also that this provider may have a SchemaRegistry passed in Init() | |
36 // that doesn't match the |delegate_|'s; therefore OnSchemaRegistryUpdated() | |
37 // and OnSchemaRegistryReady() are not forwarded either. It is assumed that | |
38 // the |delegate_|'s SchemaRegistry contains a superset of this provider's | |
39 // SchemaRegistry though (i.e. it's a CombinedSchemaRegistry that contains | |
40 // this provider's SchemaRegistry). | |
41 // | |
42 // This provider manages its own initialization state for all policy domains | |
43 // except POLICY_DOMAIN_CHROME, whose status is always queried from the | |
44 // |delegate_|. RefreshPolicies() calls are also forwarded, since this | |
45 // provider doesn't have a "real" policy source of its own. | |
46 void Init(SchemaRegistry* registry) override; | |
47 bool IsInitializationComplete(PolicyDomain domain) const override; | |
48 void RefreshPolicies() override; | |
49 void OnSchemaRegistryReady() override; | |
50 void OnSchemaRegistryUpdated(bool has_new_schemas) override; | |
51 | |
52 // ConfigurationPolicyProvider::Observer: | |
53 void OnUpdatePolicy(ConfigurationPolicyProvider* provider) override; | |
54 | |
55 private: | |
56 enum InitializationState { | |
57 WAITING_FOR_REGISTRY_READY, | |
58 WAITING_FOR_REFRESH, | |
59 READY, | |
60 }; | |
61 | |
62 ConfigurationPolicyProvider* delegate_; | |
63 InitializationState state_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(ForwardingPolicyProvider); | |
66 }; | |
67 | |
68 } // namespace policy | |
69 | |
70 #endif // COMPONENTS_POLICY_CORE_COMMON_FORWARDING_POLICY_PROVIDER_H_ | |
OLD | NEW |