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

Side by Side Diff: chrome/browser/extensions/policy_handlers.cc

Issue 2149253003: Switch various ValueTypeToString()s to base::Value::GetTypeName(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@value
Patch Set: rebase Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(), 82 errors->AddError(policy_name(), entry - list_value->begin(),
83 entry - list_value->begin(),
84 IDS_POLICY_TYPE_ERROR, 83 IDS_POLICY_TYPE_ERROR,
85 ValueTypeToString(base::Value::TYPE_STRING)); 84 base::Value::GetTypeName(base::Value::TYPE_STRING));
86 continue; 85 continue;
87 } 86 }
88 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) { 87 if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) {
89 errors->AddError(policy_name(), 88 errors->AddError(policy_name(),
90 entry - list_value->begin(), 89 entry - list_value->begin(),
91 IDS_POLICY_VALUE_FORMAT_ERROR); 90 IDS_POLICY_VALUE_FORMAT_ERROR);
92 continue; 91 continue;
93 } 92 }
94 filtered_list->AppendString(id); 93 filtered_list->AppendString(id);
95 } 94 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // This should have been caught in CheckPolicySettings. 140 // This should have been caught in CheckPolicySettings.
142 NOTREACHED(); 141 NOTREACHED();
143 return false; 142 return false;
144 } 143 }
145 144
146 for (base::ListValue::const_iterator entry(policy_list_value->begin()); 145 for (base::ListValue::const_iterator entry(policy_list_value->begin());
147 entry != policy_list_value->end(); ++entry) { 146 entry != policy_list_value->end(); ++entry) {
148 std::string entry_string; 147 std::string entry_string;
149 if (!(*entry)->GetAsString(&entry_string)) { 148 if (!(*entry)->GetAsString(&entry_string)) {
150 if (errors) { 149 if (errors) {
151 errors->AddError(policy_name(), 150 errors->AddError(policy_name(), entry - policy_list_value->begin(),
152 entry - policy_list_value->begin(),
153 IDS_POLICY_TYPE_ERROR, 151 IDS_POLICY_TYPE_ERROR,
154 ValueTypeToString(base::Value::TYPE_STRING)); 152 base::Value::GetTypeName(base::Value::TYPE_STRING));
155 } 153 }
156 continue; 154 continue;
157 } 155 }
158 156
159 // Each string item of the list has the following form: 157 // Each string item of the list has the following form:
160 // <extension_id>;<update_url> 158 // <extension_id>;<update_url>
161 // Note: The update URL might also contain semicolons. 159 // Note: The update URL might also contain semicolons.
162 size_t pos = entry_string.find(';'); 160 size_t pos = entry_string.find(';');
163 if (pos == std::string::npos) { 161 if (pos == std::string::npos) {
164 if (errors) { 162 if (errors) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (!value->GetAsList(&list_value)) { 212 if (!value->GetAsList(&list_value)) {
215 NOTREACHED(); 213 NOTREACHED();
216 return false; 214 return false;
217 } 215 }
218 216
219 // Check that the list contains valid URLPattern strings only. 217 // Check that the list contains valid URLPattern strings only.
220 for (base::ListValue::const_iterator entry(list_value->begin()); 218 for (base::ListValue::const_iterator entry(list_value->begin());
221 entry != list_value->end(); ++entry) { 219 entry != list_value->end(); ++entry) {
222 std::string url_pattern_string; 220 std::string url_pattern_string;
223 if (!(*entry)->GetAsString(&url_pattern_string)) { 221 if (!(*entry)->GetAsString(&url_pattern_string)) {
224 errors->AddError(policy_name(), 222 errors->AddError(policy_name(), entry - list_value->begin(),
225 entry - list_value->begin(),
226 IDS_POLICY_TYPE_ERROR, 223 IDS_POLICY_TYPE_ERROR,
227 ValueTypeToString(base::Value::TYPE_STRING)); 224 base::Value::GetTypeName(base::Value::TYPE_STRING));
228 return false; 225 return false;
229 } 226 }
230 227
231 URLPattern pattern(URLPattern::SCHEME_ALL); 228 URLPattern pattern(URLPattern::SCHEME_ALL);
232 if (pattern.Parse(url_pattern_string) != URLPattern::PARSE_SUCCESS) { 229 if (pattern.Parse(url_pattern_string) != URLPattern::PARSE_SUCCESS) {
233 errors->AddError(policy_name(), 230 errors->AddError(policy_name(),
234 entry - list_value->begin(), 231 entry - list_value->begin(),
235 IDS_POLICY_VALUE_FORMAT_ERROR); 232 IDS_POLICY_VALUE_FORMAT_ERROR);
236 return false; 233 return false;
237 } 234 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 void ExtensionSettingsPolicyHandler::ApplyPolicySettings( 317 void ExtensionSettingsPolicyHandler::ApplyPolicySettings(
321 const policy::PolicyMap& policies, 318 const policy::PolicyMap& policies,
322 PrefValueMap* prefs) { 319 PrefValueMap* prefs) {
323 std::unique_ptr<base::Value> policy_value; 320 std::unique_ptr<base::Value> policy_value;
324 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value) 321 if (!CheckAndGetValue(policies, NULL, &policy_value) || !policy_value)
325 return; 322 return;
326 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value)); 323 prefs->SetValue(pref_names::kExtensionManagement, std::move(policy_value));
327 } 324 }
328 325
329 } // namespace extensions 326 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698