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

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

Issue 11183029: Don't reject extension list policies with invalid entries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment. Created 8 years, 2 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.cc
diff --git a/chrome/browser/policy/configuration_policy_handler.cc b/chrome/browser/policy/configuration_policy_handler.cc
index 2eb7984ac3afdc65d0dbef4beabc89b54b87ac10..513b43e6e637347b2f6f69b62a0d3d5b9f855a28 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))
@@ -256,7 +257,8 @@ bool ExtensionListPolicyHandler::CheckAndGetList(
return false;
}
- // Check that the list contains valid extension ID strings only.
+ // Filter the list, rejecting any invalid extension IDs.
+ 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;
}
« no previous file with comments | « chrome/browser/policy/configuration_policy_handler.h ('k') | chrome/browser/policy/configuration_policy_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698