Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2857)

Unified Diff: chrome/browser/policy/configuration_policy_handler.h

Issue 12217068: Add policies to control Chrome OS power management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copy&paste mistake. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/configuration_policy_handler.h
diff --git a/chrome/browser/policy/configuration_policy_handler.h b/chrome/browser/policy/configuration_policy_handler.h
index 8d75ddfb32c98bcae425a2e0c5b2cd1e15846c48..b10320d3f42a5ccd1d3fa2090b6d069b0319c379 100644
--- a/chrome/browser/policy/configuration_policy_handler.h
+++ b/chrome/browser/policy/configuration_policy_handler.h
@@ -81,6 +81,36 @@ class TypeCheckingPolicyHandler : public ConfigurationPolicyHandler {
DISALLOW_COPY_AND_ASSIGN(TypeCheckingPolicyHandler);
};
+// Abstract class derived from TypeCheckingPolicyHandler that ensures an int
+// policy's value lies in an allowed range.
+class IntRangePolicyHandlerBase : public TypeCheckingPolicyHandler {
+ public:
+ IntRangePolicyHandlerBase(const char* policy_name,
+ int min,
+ int max);
+
+ // ConfigurationPolicyHandler:
+ virtual bool CheckPolicySettings(const PolicyMap& policies,
+ PolicyErrorMap* errors) OVERRIDE;
+
+ protected:
+ virtual ~IntRangePolicyHandlerBase();
+
+ // Checks that the value lies in the allowed range, returns false on errors.
+ bool CheckRange(const base::Value* input,
+ int* output,
+ PolicyErrorMap* errors);
+
+ private:
+ // The minimum value allowed.
+ int min_;
+
+ // The maximum value allowed.
+ int max_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntRangePolicyHandlerBase);
+};
+
// ConfigurationPolicyHandler for policies that map directly to a preference.
class SimplePolicyHandler : public TypeCheckingPolicyHandler {
public:
@@ -137,6 +167,50 @@ class StringToIntEnumListPolicyHandler : public TypeCheckingPolicyHandler {
DISALLOW_COPY_AND_ASSIGN(StringToIntEnumListPolicyHandler);
};
+// A policy handler implementation that ensures an int policy's value lies in an
+// allowed range.
+class IntRangePolicyHandler : public IntRangePolicyHandlerBase {
+ public:
+ IntRangePolicyHandler(const char* policy_name,
+ const char* pref_path,
+ int min,
+ int max);
+
+ // ConfigurationPolicyHandler:
+ virtual void ApplyPolicySettings(const PolicyMap& policies,
+ PrefValueMap* prefs) OVERRIDE;
+
+ private:
+ virtual ~IntRangePolicyHandler();
+
+ // Name of the pref to write.
+ const char* pref_path_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntRangePolicyHandler);
+};
+
+// A policy handler implementation that maps an int percentage value to a
+// double.
+class IntPercentageToDoublePolicyHandler : public IntRangePolicyHandlerBase {
+ public:
+ IntPercentageToDoublePolicyHandler(const char* policy_name,
+ const char* pref_path,
+ int min,
+ int max);
+
+ // ConfigurationPolicyHandler:
+ virtual void ApplyPolicySettings(const PolicyMap& policies,
+ PrefValueMap* prefs) OVERRIDE;
+
+ private:
+ virtual ~IntPercentageToDoublePolicyHandler();
+
+ // Name of the pref to write.
+ const char* pref_path_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntPercentageToDoublePolicyHandler);
+};
+
// Implements additional checks for policies that are lists of extension IDs.
class ExtensionListPolicyHandler : public TypeCheckingPolicyHandler {
public:

Powered by Google App Engine
This is Rietveld 408576698