| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 private: | 74 private: |
| 75 // The name of the policy. | 75 // The name of the policy. |
| 76 const char* policy_name_; | 76 const char* policy_name_; |
| 77 | 77 |
| 78 // The type the value of the policy should have. | 78 // The type the value of the policy should have. |
| 79 base::Value::Type value_type_; | 79 base::Value::Type value_type_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(TypeCheckingPolicyHandler); | 81 DISALLOW_COPY_AND_ASSIGN(TypeCheckingPolicyHandler); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 // Abstract class derived from TypeCheckingPolicyHandler that ensures an int |
| 85 // policy's value lies in an allowed range. |
| 86 class IntRangePolicyHandlerBase : public TypeCheckingPolicyHandler { |
| 87 public: |
| 88 IntRangePolicyHandlerBase(const char* policy_name, |
| 89 int min, |
| 90 int max); |
| 91 |
| 92 // ConfigurationPolicyHandler: |
| 93 virtual bool CheckPolicySettings(const PolicyMap& policies, |
| 94 PolicyErrorMap* errors) OVERRIDE; |
| 95 |
| 96 protected: |
| 97 virtual ~IntRangePolicyHandlerBase(); |
| 98 |
| 99 // Checks that the value lies in the allowed range, returns false on errors. |
| 100 bool CheckRange(const base::Value* input, |
| 101 int* output, |
| 102 PolicyErrorMap* errors); |
| 103 |
| 104 private: |
| 105 // The minimum value allowed. |
| 106 int min_; |
| 107 |
| 108 // The maximum value allowed. |
| 109 int max_; |
| 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(IntRangePolicyHandlerBase); |
| 112 }; |
| 113 |
| 84 // ConfigurationPolicyHandler for policies that map directly to a preference. | 114 // ConfigurationPolicyHandler for policies that map directly to a preference. |
| 85 class SimplePolicyHandler : public TypeCheckingPolicyHandler { | 115 class SimplePolicyHandler : public TypeCheckingPolicyHandler { |
| 86 public: | 116 public: |
| 87 SimplePolicyHandler(const char* policy_name, | 117 SimplePolicyHandler(const char* policy_name, |
| 88 const char* pref_path, | 118 const char* pref_path, |
| 89 base::Value::Type value_type); | 119 base::Value::Type value_type); |
| 90 virtual ~SimplePolicyHandler(); | 120 virtual ~SimplePolicyHandler(); |
| 91 | 121 |
| 92 // ConfigurationPolicyHandler methods: | 122 // ConfigurationPolicyHandler methods: |
| 93 virtual void ApplyPolicySettings(const PolicyMap& policies, | 123 virtual void ApplyPolicySettings(const PolicyMap& policies, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Name of the pref to write. | 160 // Name of the pref to write. |
| 131 const char* pref_path_; | 161 const char* pref_path_; |
| 132 | 162 |
| 133 // The mapping table. | 163 // The mapping table. |
| 134 const MappingEntry* mapping_begin_; | 164 const MappingEntry* mapping_begin_; |
| 135 const MappingEntry* mapping_end_; | 165 const MappingEntry* mapping_end_; |
| 136 | 166 |
| 137 DISALLOW_COPY_AND_ASSIGN(StringToIntEnumListPolicyHandler); | 167 DISALLOW_COPY_AND_ASSIGN(StringToIntEnumListPolicyHandler); |
| 138 }; | 168 }; |
| 139 | 169 |
| 170 // A policy handler implementation that ensures an int policy's value lies in an |
| 171 // allowed range. |
| 172 class IntRangePolicyHandler : public IntRangePolicyHandlerBase { |
| 173 public: |
| 174 IntRangePolicyHandler(const char* policy_name, |
| 175 const char* pref_path, |
| 176 int min, |
| 177 int max); |
| 178 |
| 179 // ConfigurationPolicyHandler: |
| 180 virtual void ApplyPolicySettings(const PolicyMap& policies, |
| 181 PrefValueMap* prefs) OVERRIDE; |
| 182 |
| 183 private: |
| 184 virtual ~IntRangePolicyHandler(); |
| 185 |
| 186 // Name of the pref to write. |
| 187 const char* pref_path_; |
| 188 |
| 189 DISALLOW_COPY_AND_ASSIGN(IntRangePolicyHandler); |
| 190 }; |
| 191 |
| 192 // A policy handler implementation that maps an int percentage value to a |
| 193 // double. |
| 194 class IntPercentageToDoublePolicyHandler : public IntRangePolicyHandlerBase { |
| 195 public: |
| 196 IntPercentageToDoublePolicyHandler(const char* policy_name, |
| 197 const char* pref_path, |
| 198 int min, |
| 199 int max); |
| 200 |
| 201 // ConfigurationPolicyHandler: |
| 202 virtual void ApplyPolicySettings(const PolicyMap& policies, |
| 203 PrefValueMap* prefs) OVERRIDE; |
| 204 |
| 205 private: |
| 206 virtual ~IntPercentageToDoublePolicyHandler(); |
| 207 |
| 208 // Name of the pref to write. |
| 209 const char* pref_path_; |
| 210 |
| 211 DISALLOW_COPY_AND_ASSIGN(IntPercentageToDoublePolicyHandler); |
| 212 }; |
| 213 |
| 140 // Implements additional checks for policies that are lists of extension IDs. | 214 // Implements additional checks for policies that are lists of extension IDs. |
| 141 class ExtensionListPolicyHandler : public TypeCheckingPolicyHandler { | 215 class ExtensionListPolicyHandler : public TypeCheckingPolicyHandler { |
| 142 public: | 216 public: |
| 143 ExtensionListPolicyHandler(const char* policy_name, | 217 ExtensionListPolicyHandler(const char* policy_name, |
| 144 const char* pref_path, | 218 const char* pref_path, |
| 145 bool allow_wildcards); | 219 bool allow_wildcards); |
| 146 virtual ~ExtensionListPolicyHandler(); | 220 virtual ~ExtensionListPolicyHandler(); |
| 147 | 221 |
| 148 // ConfigurationPolicyHandler methods: | 222 // ConfigurationPolicyHandler methods: |
| 149 virtual bool CheckPolicySettings(const PolicyMap& policies, | 223 virtual bool CheckPolicySettings(const PolicyMap& policies, |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 private: | 532 private: |
| 459 void ApplyPolicySettingsFromHomePage(const PolicyMap& policies, | 533 void ApplyPolicySettingsFromHomePage(const PolicyMap& policies, |
| 460 PrefValueMap* prefs); | 534 PrefValueMap* prefs); |
| 461 | 535 |
| 462 DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupPolicyHandler); | 536 DISALLOW_COPY_AND_ASSIGN(RestoreOnStartupPolicyHandler); |
| 463 }; | 537 }; |
| 464 | 538 |
| 465 } // namespace policy | 539 } // namespace policy |
| 466 | 540 |
| 467 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ | 541 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_HANDLER_H_ |
| OLD | NEW |