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

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: Rebased. 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
« no previous file with comments | « chrome/app/policy/policy_templates.json ('k') | chrome/browser/policy/configuration_policy_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4715b04470a6d1dc2d7adb21784002df3a109e16 100644
--- a/chrome/browser/policy/configuration_policy_handler.h
+++ b/chrome/browser/policy/configuration_policy_handler.h
@@ -81,6 +81,44 @@ 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. Either clamps or rejects values
+// outside the range.
+class IntRangePolicyHandlerBase : public TypeCheckingPolicyHandler {
+ public:
+ IntRangePolicyHandlerBase(const char* policy_name,
+ int min,
+ int max,
+ bool clamp);
+
+ // ConfigurationPolicyHandler:
+ virtual bool CheckPolicySettings(const PolicyMap& policies,
+ PolicyErrorMap* errors) OVERRIDE;
+
+ protected:
+ virtual ~IntRangePolicyHandlerBase();
+
+ // Ensures that the value is in the allowed range. Returns false if the value
+ // cannot be parsed or lies outside the allowed range and clamping is
+ // disabled.
+ bool EnsureInRange(const base::Value* input,
+ int* output,
+ PolicyErrorMap* errors);
+
+ private:
+ // The minimum value allowed.
+ int min_;
+
+ // The maximum value allowed.
+ int max_;
+
+ // Whether to clamp values lying outside the allowed range instead of
+ // rejecting them.
+ bool clamp_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntRangePolicyHandlerBase);
+};
+
// ConfigurationPolicyHandler for policies that map directly to a preference.
class SimplePolicyHandler : public TypeCheckingPolicyHandler {
public:
@@ -137,6 +175,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,
+ bool clamp);
+ virtual ~IntRangePolicyHandler();
+
+ // ConfigurationPolicyHandler:
+ virtual void ApplyPolicySettings(const PolicyMap& policies,
+ PrefValueMap* prefs) OVERRIDE;
+
+ private:
+ // 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,
+ bool clamp);
+ virtual ~IntPercentageToDoublePolicyHandler();
+
+ // ConfigurationPolicyHandler:
+ virtual void ApplyPolicySettings(const PolicyMap& policies,
+ PrefValueMap* prefs) OVERRIDE;
+
+ private:
+ // 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:
« no previous file with comments | « chrome/app/policy/policy_templates.json ('k') | chrome/browser/policy/configuration_policy_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698