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