Chromium Code Reviews| 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 2eb7984ac3afdc65d0dbef4beabc89b54b87ac10..980eba3d062b8349342490daa7fcd6a68cae9d79 100644 |
| --- a/chrome/browser/policy/configuration_policy_handler.cc |
| +++ b/chrome/browser/policy/configuration_policy_handler.cc |
| @@ -227,9 +227,10 @@ bool ExtensionListPolicyHandler::CheckPolicySettings( |
| void ExtensionListPolicyHandler::ApplyPolicySettings( |
| const PolicyMap& policies, |
| PrefValueMap* prefs) { |
| - const Value* value = policies.GetValue(policy_name()); |
| - if (value) |
| - prefs->SetValue(pref_path(), value->DeepCopy()); |
| + scoped_ptr<base::ListValue> list; |
| + PolicyErrorMap errors; |
| + if (CheckAndGetList(policies, &errors, &list) && list) |
| + prefs->SetValue(pref_path(), list.release()); |
| } |
| const char* ExtensionListPolicyHandler::pref_path() const { |
| @@ -239,9 +240,9 @@ const char* ExtensionListPolicyHandler::pref_path() const { |
| bool ExtensionListPolicyHandler::CheckAndGetList( |
| const PolicyMap& policies, |
| PolicyErrorMap* errors, |
| - const base::ListValue** extension_ids) { |
| + scoped_ptr<base::ListValue>* extension_ids) { |
| if (extension_ids) |
| - *extension_ids = NULL; |
| + extension_ids->reset(); |
| const base::Value* value = NULL; |
| if (!CheckAndGetValue(policies, errors, &value)) |
| @@ -257,6 +258,7 @@ bool ExtensionListPolicyHandler::CheckAndGetList( |
| } |
| // Check that the list contains valid extension ID strings only. |
|
Joao da Silva
2012/10/17 09:26:49
This comment is outdated
Mattias Nissler (ping if slow)
2012/10/17 09:41:19
Done.
|
| + scoped_ptr<base::ListValue> filtered_list(new base::ListValue()); |
| for (base::ListValue::const_iterator entry(list_value->begin()); |
| entry != list_value->end(); ++entry) { |
| std::string id; |
| @@ -265,19 +267,20 @@ bool ExtensionListPolicyHandler::CheckAndGetList( |
| entry - list_value->begin(), |
| IDS_POLICY_TYPE_ERROR, |
| ValueTypeToString(base::Value::TYPE_STRING)); |
| - return false; |
| + continue; |
| } |
| if (!(allow_wildcards_ && id == "*") && |
| !extensions::Extension::IdIsValid(id)) { |
| errors->AddError(policy_name(), |
| entry - list_value->begin(), |
| IDS_POLICY_VALUE_FORMAT_ERROR); |
| - return false; |
| + continue; |
| } |
| + filtered_list->Append(base::Value::CreateStringValue(id)); |
| } |
| if (extension_ids) |
| - *extension_ids = list_value; |
| + *extension_ids = filtered_list.Pass(); |
| return true; |
| } |