OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ |
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <map> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/policy/configuration_policy_store_interface.h" | 15 #include "chrome/browser/policy/configuration_policy_store_interface.h" |
| 16 #include "policy/configuration_policy_type.h" |
15 | 17 |
16 namespace policy { | 18 namespace policy { |
17 | 19 |
18 // A mostly-abstract super class for platform-specific policy providers. | 20 // A mostly-abstract super class for platform-specific policy providers. |
19 // Platform-specific policy providers (Windows Group Policy, gconf, | 21 // Platform-specific policy providers (Windows Group Policy, gconf, |
20 // etc.) should implement a subclass of this class. | 22 // etc.) should implement a subclass of this class. |
21 class ConfigurationPolicyProvider { | 23 class ConfigurationPolicyProvider { |
22 public: | 24 public: |
| 25 typedef std::map<ConfigurationPolicyType, Value*> PolicyMapType; |
| 26 |
23 class Observer { | 27 class Observer { |
24 public: | 28 public: |
25 virtual ~Observer() {} | 29 virtual ~Observer() {} |
26 virtual void OnUpdatePolicy() = 0; | 30 virtual void OnUpdatePolicy() = 0; |
27 virtual void OnProviderGoingAway() = 0; | 31 virtual void OnProviderGoingAway() = 0; |
28 }; | 32 }; |
29 | 33 |
30 // Used for static arrays of policy values that is used to initialize an | 34 // Used for static arrays of policy values that is used to initialize an |
31 // instance of the ConfigurationPolicyProvider. | 35 // instance of the ConfigurationPolicyProvider. |
32 struct PolicyDefinitionList { | 36 struct PolicyDefinitionList { |
(...skipping 19 matching lines...) Expand all Loading... |
52 // provided, otherwise false. | 56 // provided, otherwise false. |
53 virtual bool Provide(ConfigurationPolicyStoreInterface* store) = 0; | 57 virtual bool Provide(ConfigurationPolicyStoreInterface* store) = 0; |
54 | 58 |
55 // Check whether this provider has completed initialization. This is used to | 59 // Check whether this provider has completed initialization. This is used to |
56 // detect whether initialization is done in case providers implementations | 60 // detect whether initialization is done in case providers implementations |
57 // need to do asynchronous operations for initialization. | 61 // need to do asynchronous operations for initialization. |
58 virtual bool IsInitializationComplete() const; | 62 virtual bool IsInitializationComplete() const; |
59 | 63 |
60 protected: | 64 protected: |
61 // Decodes the value tree and writes the configuration to the given |store|. | 65 // Decodes the value tree and writes the configuration to the given |store|. |
62 void DecodePolicyValueTree(const DictionaryValue* policies, | 66 void ApplyPolicyValueTree(const DictionaryValue* policies, |
63 ConfigurationPolicyStoreInterface* store); | 67 ConfigurationPolicyStoreInterface* store); |
64 | 68 |
| 69 // Writes the configuration found in the already-decoded map |policies| to |
| 70 // the given |store|. |
| 71 void ApplyPolicyMap(const PolicyMapType* policies, |
| 72 ConfigurationPolicyStoreInterface* store); |
| 73 |
65 const PolicyDefinitionList* policy_definition_list() const { | 74 const PolicyDefinitionList* policy_definition_list() const { |
66 return policy_definition_list_; | 75 return policy_definition_list_; |
67 } | 76 } |
68 | 77 |
69 private: | 78 private: |
70 friend class ConfigurationPolicyObserverRegistrar; | 79 friend class ConfigurationPolicyObserverRegistrar; |
71 | 80 |
72 virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer) = 0; | 81 virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer) = 0; |
73 virtual void RemoveObserver( | 82 virtual void RemoveObserver( |
74 ConfigurationPolicyProvider::Observer* observer) = 0; | 83 ConfigurationPolicyProvider::Observer* observer) = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
101 private: | 110 private: |
102 ConfigurationPolicyProvider* provider_; | 111 ConfigurationPolicyProvider* provider_; |
103 ConfigurationPolicyProvider::Observer* observer_; | 112 ConfigurationPolicyProvider::Observer* observer_; |
104 | 113 |
105 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); | 114 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyObserverRegistrar); |
106 }; | 115 }; |
107 | 116 |
108 } // namespace policy | 117 } // namespace policy |
109 | 118 |
110 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ | 119 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_H_ |
OLD | NEW |