| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/policy_handlers.h" | 5 #include "chrome/browser/extensions/policy_handlers.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 if (!value->GetAsList(&list_value)) { | 71 if (!value->GetAsList(&list_value)) { |
| 72 NOTREACHED(); | 72 NOTREACHED(); |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Filter the list, rejecting any invalid extension IDs. | 76 // Filter the list, rejecting any invalid extension IDs. |
| 77 std::unique_ptr<base::ListValue> filtered_list(new base::ListValue()); | 77 std::unique_ptr<base::ListValue> filtered_list(new base::ListValue()); |
| 78 for (base::ListValue::const_iterator entry(list_value->begin()); | 78 for (base::ListValue::const_iterator entry(list_value->begin()); |
| 79 entry != list_value->end(); ++entry) { | 79 entry != list_value->end(); ++entry) { |
| 80 std::string id; | 80 std::string id; |
| 81 if (!(*entry)->GetAsString(&id)) { | 81 if (!entry->GetAsString(&id)) { |
| 82 errors->AddError(policy_name(), entry - list_value->begin(), | 82 errors->AddError(policy_name(), entry - list_value->begin(), |
| 83 IDS_POLICY_TYPE_ERROR, | 83 IDS_POLICY_TYPE_ERROR, |
| 84 base::Value::GetTypeName(base::Value::Type::STRING)); | 84 base::Value::GetTypeName(base::Value::Type::STRING)); |
| 85 continue; | 85 continue; |
| 86 } | 86 } |
| 87 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) { | 87 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) { |
| 88 errors->AddError(policy_name(), | 88 errors->AddError(policy_name(), |
| 89 entry - list_value->begin(), | 89 entry - list_value->begin(), |
| 90 IDS_POLICY_VALUE_FORMAT_ERROR); | 90 IDS_POLICY_VALUE_FORMAT_ERROR); |
| 91 continue; | 91 continue; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 const base::ListValue* policy_list_value = nullptr; | 136 const base::ListValue* policy_list_value = nullptr; |
| 137 if (!policy_value->GetAsList(&policy_list_value)) { | 137 if (!policy_value->GetAsList(&policy_list_value)) { |
| 138 // This should have been caught in CheckPolicySettings. | 138 // This should have been caught in CheckPolicySettings. |
| 139 NOTREACHED(); | 139 NOTREACHED(); |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 for (base::ListValue::const_iterator entry(policy_list_value->begin()); | 143 for (base::ListValue::const_iterator entry(policy_list_value->begin()); |
| 144 entry != policy_list_value->end(); ++entry) { | 144 entry != policy_list_value->end(); ++entry) { |
| 145 std::string entry_string; | 145 std::string entry_string; |
| 146 if (!(*entry)->GetAsString(&entry_string)) { | 146 if (!entry->GetAsString(&entry_string)) { |
| 147 if (errors) { | 147 if (errors) { |
| 148 errors->AddError(policy_name(), entry - policy_list_value->begin(), | 148 errors->AddError(policy_name(), entry - policy_list_value->begin(), |
| 149 IDS_POLICY_TYPE_ERROR, | 149 IDS_POLICY_TYPE_ERROR, |
| 150 base::Value::GetTypeName(base::Value::Type::STRING)); | 150 base::Value::GetTypeName(base::Value::Type::STRING)); |
| 151 } | 151 } |
| 152 continue; | 152 continue; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Each string item of the list has the following form: | 155 // Each string item of the list has the following form: |
| 156 // <extension_id>;<update_url> | 156 // <extension_id>;<update_url> |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 const base::ListValue* list_value = NULL; | 223 const base::ListValue* list_value = NULL; |
| 224 if (!value->GetAsList(&list_value)) { | 224 if (!value->GetAsList(&list_value)) { |
| 225 NOTREACHED(); | 225 NOTREACHED(); |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Check that the list contains valid URLPattern strings only. | 229 // Check that the list contains valid URLPattern strings only. |
| 230 for (base::ListValue::const_iterator entry(list_value->begin()); | 230 for (base::ListValue::const_iterator entry(list_value->begin()); |
| 231 entry != list_value->end(); ++entry) { | 231 entry != list_value->end(); ++entry) { |
| 232 std::string url_pattern_string; | 232 std::string url_pattern_string; |
| 233 if (!(*entry)->GetAsString(&url_pattern_string)) { | 233 if (!entry->GetAsString(&url_pattern_string)) { |
| 234 errors->AddError(policy_name(), entry - list_value->begin(), | 234 errors->AddError(policy_name(), entry - list_value->begin(), |
| 235 IDS_POLICY_TYPE_ERROR, | 235 IDS_POLICY_TYPE_ERROR, |
| 236 base::Value::GetTypeName(base::Value::Type::STRING)); | 236 base::Value::GetTypeName(base::Value::Type::STRING)); |
| 237 return false; | 237 return false; |
| 238 } | 238 } |
| 239 | 239 |
| 240 URLPattern pattern(URLPattern::SCHEME_ALL); | 240 URLPattern pattern(URLPattern::SCHEME_ALL); |
| 241 if (pattern.Parse(url_pattern_string) != URLPattern::PARSE_SUCCESS) { | 241 if (pattern.Parse(url_pattern_string) != URLPattern::PARSE_SUCCESS) { |
| 242 errors->AddError(policy_name(), | 242 errors->AddError(policy_name(), |
| 243 entry - list_value->begin(), | 243 entry - list_value->begin(), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 void ExtensionSettingsPolicyHandler::ApplyPolicySettings( | 329 void ExtensionSettingsPolicyHandler::ApplyPolicySettings( |
| 330 const policy::PolicyMap& policies, | 330 const policy::PolicyMap& policies, |
| 331 PrefValueMap* prefs) { | 331 PrefValueMap* prefs) { |
| 332 std::unique_ptr<base::Value> policy_value; | 332 std::unique_ptr<base::Value> policy_value; |
| 333 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value) | 333 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value) |
| 334 return; | 334 return; |
| 335 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value)); | 335 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value)); |
| 336 } | 336 } |
| 337 | 337 |
| 338 } // namespace extensions | 338 } // namespace extensions |
| OLD | NEW |