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_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ |
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/values.h" |
| 13 #include "policy/configuration_policy_type.h" |
12 | 14 |
13 class PrefValueMap; | 15 class PrefValueMap; |
14 | 16 |
15 namespace policy { | 17 namespace policy { |
16 | 18 |
17 class PolicyErrorMap; | 19 class PolicyErrorMap; |
18 class PolicyMap; | 20 class PolicyMap; |
19 | 21 |
20 // An abstract super class that subclasses should implement to map policies to | 22 // An abstract super class that subclasses should implement to map policies to |
21 // their corresponding preferences, and to check whether the policies are valid. | 23 // their corresponding preferences, and to check whether the policies are valid. |
(...skipping 17 matching lines...) Expand all Loading... |
39 PrefValueMap* prefs) = 0; | 41 PrefValueMap* prefs) = 0; |
40 | 42 |
41 // Creates a new HandlerList with all the known handlers and returns it. | 43 // Creates a new HandlerList with all the known handlers and returns it. |
42 // The new list and its elements are owned by the caller. | 44 // The new list and its elements are owned by the caller. |
43 static HandlerList* CreateHandlerList(); | 45 static HandlerList* CreateHandlerList(); |
44 | 46 |
45 private: | 47 private: |
46 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyHandler); | 48 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyHandler); |
47 }; | 49 }; |
48 | 50 |
| 51 // Abstract class derived from ConfigurationPolicyHandler that should be |
| 52 // subclassed to handle a single policy (not a combination of policies). |
| 53 class TypeCheckingPolicyHandler : public ConfigurationPolicyHandler { |
| 54 public: |
| 55 TypeCheckingPolicyHandler(ConfigurationPolicyType policy_type, |
| 56 base::Value::Type value_type); |
| 57 |
| 58 // ConfigurationPolicyHandler methods: |
| 59 virtual bool CheckPolicySettings(const PolicyMap* policies, |
| 60 PolicyErrorMap* errors) OVERRIDE; |
| 61 |
| 62 protected: |
| 63 virtual ~TypeCheckingPolicyHandler(); |
| 64 |
| 65 // Runs policy checks and returns the policy value if successful. |
| 66 bool CheckAndGetValue(const PolicyMap* policies, |
| 67 PolicyErrorMap* errors, |
| 68 const Value** value); |
| 69 |
| 70 ConfigurationPolicyType policy_type() const; |
| 71 |
| 72 private: |
| 73 // The ConfigurationPolicyType of the policy. |
| 74 ConfigurationPolicyType policy_type_; |
| 75 |
| 76 // The type the value of the policy should have. |
| 77 base::Value::Type value_type_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(TypeCheckingPolicyHandler); |
| 80 }; |
| 81 |
49 } // namespace policy | 82 } // namespace policy |
50 | 83 |
51 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ | 84 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ |
OLD | NEW |