Chromium Code Reviews| Index: components/policy/core/browser/configuration_policy_handler.cc |
| diff --git a/components/policy/core/browser/configuration_policy_handler.cc b/components/policy/core/browser/configuration_policy_handler.cc |
| index f4918a657b75682c9524804987a763b468689544..ea8d7b6417789c45ac90192dadfafccc0fe42a0b 100644 |
| --- a/components/policy/core/browser/configuration_policy_handler.cc |
| +++ b/components/policy/core/browser/configuration_policy_handler.cc |
| @@ -368,6 +368,67 @@ bool SchemaValidatingPolicyHandler::CheckAndGetValue( |
| return result; |
| } |
| +// SimpleSchemaValidatingPolicyHandler implementation -------------------------- |
| + |
| +SimpleSchemaValidatingPolicyHandler::SimpleSchemaValidatingPolicyHandler( |
| + const char* policy_name, |
| + const char* pref_path, |
| + Schema schema, |
| + SchemaOnErrorStrategy strategy, |
| + bool recommended, |
| + bool mandatory) |
| + : SchemaValidatingPolicyHandler(policy_name, |
| + schema.GetKnownProperty(policy_name), |
| + strategy), |
| + pref_path_(pref_path), |
| + recommended_(recommended), |
| + mandatory_(mandatory) { |
| +} |
| + |
| +SimpleSchemaValidatingPolicyHandler::SimpleSchemaValidatingPolicyHandler( |
|
bartfab (slow)
2014/06/03 11:58:21
Nit: Reorder these constructors so that the implem
kaliamoorthi
2014/06/04 18:01:58
Done.
|
| + const char* policy_name, |
| + const char* pref_path, |
| + Schema schema, |
| + SchemaOnErrorStrategy strategy) |
| + : SchemaValidatingPolicyHandler(policy_name, |
| + schema.GetKnownProperty(policy_name), |
| + strategy), |
| + pref_path_(pref_path), |
| + recommended_(true), |
| + mandatory_(true) { |
| +} |
| + |
| +SimpleSchemaValidatingPolicyHandler::~SimpleSchemaValidatingPolicyHandler() { |
| +} |
| + |
| +bool SimpleSchemaValidatingPolicyHandler::CheckPolicySettings( |
| + const PolicyMap& policies, |
| + PolicyErrorMap* errors) { |
| + const PolicyMap::Entry* policy_entry = |
| + policies.Get(SchemaValidatingPolicyHandler::policy_name()); |
|
bartfab (slow)
2014/06/03 11:58:21
Nit: No need for the SchemaValidatingPolicyHandler
kaliamoorthi
2014/06/04 18:01:58
Done.
|
| + if (!policy_entry) |
| + return false; |
|
bartfab (slow)
2014/06/03 11:58:21
SchemaValidatingPolicyHandler returns |true| if th
kaliamoorthi
2014/06/04 18:01:58
Done.
|
| + if ((policy_entry->level == policy::POLICY_LEVEL_MANDATORY && !mandatory_) || |
| + (policy_entry->level == policy::POLICY_LEVEL_RECOMMENDED && |
| + !recommended_)) { |
| + if (errors != NULL) |
|
bartfab (slow)
2014/06/03 11:58:21
Nit: "if (errors)" is sufficient
kaliamoorthi
2014/06/04 18:01:58
Done.
|
| + errors->AddError(policy_name(), IDS_POLICY_LEVEL_ERROR); |
| + return false; |
| + } |
| + |
| + return SchemaValidatingPolicyHandler::CheckPolicySettings(policies, errors); |
| +} |
| + |
| +void SimpleSchemaValidatingPolicyHandler::ApplyPolicySettings( |
| + const PolicyMap& policies, |
| + PrefValueMap* prefs) { |
| + if (!pref_path_) |
| + return; |
| + const base::Value* value = policies.GetValue(policy_name()); |
| + if (value) |
| + prefs->SetValue(pref_path_, value->DeepCopy()); |
| +} |
| + |
| // LegacyPoliciesDeprecatingPolicyHandler implementation ----------------------- |
| // TODO(binjin): Add a new common base class for SchemaValidatingPolicyHandler |