| Index: chrome/browser/policy/configuration_policy_handler.cc
|
| diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc
|
| index 07120fbe374794069e40a79f1f454a18ab3b7003..cc2fa273d3b329c2e6b7aa18840b259120a3ce10 100644
|
| --- a/chrome/browser/policy/configuration_policy_handler.cc
|
| +++ b/chrome/browser/policy/configuration_policy_handler.cc
|
| @@ -400,6 +400,63 @@ void IntPercentageToDoublePolicyHandler::ApplyPolicySettings(
|
| }
|
| }
|
|
|
| +// IntSetPolicyHandler implementation ------------------------------------------
|
| +
|
| +IntSetPolicyHandler::IntSetPolicyHandler(const char* policy_name,
|
| + const char* pref_path,
|
| + const int* allowed_set_begin,
|
| + const int* allowed_set_end)
|
| + : TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_INTEGER),
|
| + pref_path_(pref_path),
|
| + allowed_set_begin_(allowed_set_begin),
|
| + allowed_set_end_(allowed_set_end) {
|
| +}
|
| +
|
| +IntSetPolicyHandler::~IntSetPolicyHandler() {
|
| +}
|
| +
|
| +bool IntSetPolicyHandler::CheckPolicySettings(const PolicyMap& policies,
|
| + PolicyErrorMap* errors) {
|
| + const base::Value* value;
|
| + return CheckAndGetValue(policies, errors, &value) &&
|
| + EnsureInAllowedSet(value, errors);
|
| +}
|
| +
|
| +void IntSetPolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
|
| + PrefValueMap* prefs) {
|
| + if (!pref_path_)
|
| + return;
|
| + const base::Value* value = policies.GetValue(policy_name());
|
| + if (value && EnsureInAllowedSet(value, NULL))
|
| + prefs->SetValue(pref_path_, value->DeepCopy());
|
| +}
|
| +
|
| +bool IntSetPolicyHandler::EnsureInAllowedSet(const base::Value* value,
|
| + PolicyErrorMap* errors) {
|
| + if (!value)
|
| + return true;
|
| +
|
| + int int_value;
|
| + if (!value->GetAsInteger(&int_value)) {
|
| + NOTREACHED();
|
| + return false;
|
| + }
|
| +
|
| + for (const int* entry = allowed_set_begin_; entry != allowed_set_end_;
|
| + ++entry) {
|
| + if (*entry == int_value)
|
| + return true;
|
| + }
|
| +
|
| + if (errors) {
|
| + errors->AddError(policy_name(),
|
| + IDS_POLICY_OUT_OF_RANGE_ERROR,
|
| + base::IntToString(int_value));
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| // ExtensionListPolicyHandler implementation -----------------------------------
|
|
|
| ExtensionListPolicyHandler::ExtensionListPolicyHandler(const char* policy_name,
|
|
|