| 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 COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_HANDLER_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_HANDLER_H_ |
| 6 #define COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_HANDLER_H_ | 6 #define COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "components/policy/core/common/schema.h" | 16 #include "components/policy/core/common/schema.h" |
| 17 #include "components/policy/policy_export.h" | 17 #include "components/policy/policy_export.h" |
| 18 | 18 |
| 19 class PrefValueMap; | 19 class PrefValueMap; |
| 20 | 20 |
| 21 namespace policy { | 21 namespace policy { |
| 22 | 22 |
| 23 class PolicyErrorMap; | 23 class PolicyErrorMap; |
| 24 struct PolicyHandlerParameters; |
| 24 class PolicyMap; | 25 class PolicyMap; |
| 25 | 26 |
| 26 // Maps a policy type to a preference path, and to the expected value type. | 27 // Maps a policy type to a preference path, and to the expected value type. |
| 27 struct POLICY_EXPORT PolicyToPreferenceMapEntry { | 28 struct POLICY_EXPORT PolicyToPreferenceMapEntry { |
| 28 const char* const policy_name; | 29 const char* const policy_name; |
| 29 const char* const preference_path; | 30 const char* const preference_path; |
| 30 const base::Value::Type value_type; | 31 const base::Value::Type value_type; |
| 31 }; | 32 }; |
| 32 | 33 |
| 33 // An abstract super class that subclasses should implement to map policies to | 34 // An abstract super class that subclasses should implement to map policies to |
| 34 // their corresponding preferences, and to check whether the policies are valid. | 35 // their corresponding preferences, and to check whether the policies are valid. |
| 35 class POLICY_EXPORT ConfigurationPolicyHandler { | 36 class POLICY_EXPORT ConfigurationPolicyHandler { |
| 36 public: | 37 public: |
| 37 static std::string ValueTypeToString(base::Value::Type type); | 38 static std::string ValueTypeToString(base::Value::Type type); |
| 38 | 39 |
| 39 ConfigurationPolicyHandler(); | 40 ConfigurationPolicyHandler(); |
| 40 virtual ~ConfigurationPolicyHandler(); | 41 virtual ~ConfigurationPolicyHandler(); |
| 41 | 42 |
| 42 // Returns whether the policy settings handled by this | 43 // Returns whether the policy settings handled by this |
| 43 // ConfigurationPolicyHandler can be applied. Fills |errors| with error | 44 // ConfigurationPolicyHandler can be applied. Fills |errors| with error |
| 44 // messages or warnings. |errors| may contain error messages even when | 45 // messages or warnings. |errors| may contain error messages even when |
| 45 // |CheckPolicySettings()| returns true. | 46 // |CheckPolicySettings()| returns true. |
| 46 virtual bool CheckPolicySettings(const PolicyMap& policies, | 47 virtual bool CheckPolicySettings(const PolicyMap& policies, |
| 47 PolicyErrorMap* errors) = 0; | 48 PolicyErrorMap* errors) = 0; |
| 48 | 49 |
| 49 // Processes the policies handled by this ConfigurationPolicyHandler and sets | 50 // Processes the policies handled by this ConfigurationPolicyHandler and sets |
| 50 // the appropriate preferences in |prefs|. | 51 // the appropriate preferences in |prefs|. |
| 52 virtual void ApplyPolicySettingsWithParameters( |
| 53 const PolicyMap& policies, |
| 54 const PolicyHandlerParameters& parameters, |
| 55 PrefValueMap* prefs); |
| 56 |
| 57 // This is a convenience version of ApplyPolicySettingsWithParameters() |
| 58 // that leaves out the |parameters|. Anyone extending |
| 59 // ConfigurationPolicyHandler should implement either ApplyPolicySettings or |
| 60 // ApplyPolicySettingsWithParameters. |
| 51 virtual void ApplyPolicySettings(const PolicyMap& policies, | 61 virtual void ApplyPolicySettings(const PolicyMap& policies, |
| 52 PrefValueMap* prefs) = 0; | 62 PrefValueMap* prefs); |
| 53 | 63 |
| 54 // Modifies the values of some of the policies in |policies| so that they | 64 // Modifies the values of some of the policies in |policies| so that they |
| 55 // are more suitable to display to the user. This can be used to remove | 65 // are more suitable to display to the user. This can be used to remove |
| 56 // sensitive values such as passwords, or to pretty-print values. | 66 // sensitive values such as passwords, or to pretty-print values. |
| 57 virtual void PrepareForDisplaying(PolicyMap* policies) const; | 67 virtual void PrepareForDisplaying(PolicyMap* policies) const; |
| 58 | 68 |
| 59 private: | 69 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyHandler); | 70 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyHandler); |
| 61 }; | 71 }; |
| 62 | 72 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 private: | 293 private: |
| 284 ScopedVector<ConfigurationPolicyHandler> legacy_policy_handlers_; | 294 ScopedVector<ConfigurationPolicyHandler> legacy_policy_handlers_; |
| 285 scoped_ptr<SchemaValidatingPolicyHandler> new_policy_handler_; | 295 scoped_ptr<SchemaValidatingPolicyHandler> new_policy_handler_; |
| 286 | 296 |
| 287 DISALLOW_COPY_AND_ASSIGN(LegacyPoliciesDeprecatingPolicyHandler); | 297 DISALLOW_COPY_AND_ASSIGN(LegacyPoliciesDeprecatingPolicyHandler); |
| 288 }; | 298 }; |
| 289 | 299 |
| 290 } // namespace policy | 300 } // namespace policy |
| 291 | 301 |
| 292 #endif // COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_HANDLER_H_ | 302 #endif // COMPONENTS_POLICY_CORE_BROWSER_CONFIGURATION_POLICY_HANDLER_H_ |
| OLD | NEW |