OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/network/onc/onc_validator.h" | 5 #include "chromeos/network/onc/onc_validator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 error_or_warning_found_ = true; | 237 error_or_warning_found_ = true; |
238 LOG(WARNING) << MessageHeader() << "Found the field '" | 238 LOG(WARNING) << MessageHeader() << "Found the field '" |
239 << ::onc::kRecommended | 239 << ::onc::kRecommended |
240 << "' in an unmanaged ONC. Removing it."; | 240 << "' in an unmanaged ONC. Removing it."; |
241 return true; | 241 return true; |
242 } | 242 } |
243 | 243 |
244 std::unique_ptr<base::ListValue> repaired_recommended(new base::ListValue); | 244 std::unique_ptr<base::ListValue> repaired_recommended(new base::ListValue); |
245 for (const auto& entry : *recommended_list) { | 245 for (const auto& entry : *recommended_list) { |
246 std::string field_name; | 246 std::string field_name; |
247 if (!entry->GetAsString(&field_name)) { | 247 if (!entry.GetAsString(&field_name)) { |
248 NOTREACHED(); // The types of field values are already verified. | 248 NOTREACHED(); // The types of field values are already verified. |
249 continue; | 249 continue; |
250 } | 250 } |
251 | 251 |
252 const OncFieldSignature* field_signature = | 252 const OncFieldSignature* field_signature = |
253 GetFieldSignature(object_signature, field_name); | 253 GetFieldSignature(object_signature, field_name); |
254 | 254 |
255 bool found_error = false; | 255 bool found_error = false; |
256 std::string error_cause; | 256 std::string error_cause; |
257 if (!field_signature) { | 257 if (!field_signature) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 397 |
398 bool Validator::ListFieldContainsValidValues( | 398 bool Validator::ListFieldContainsValidValues( |
399 const base::DictionaryValue& object, | 399 const base::DictionaryValue& object, |
400 const std::string& field_name, | 400 const std::string& field_name, |
401 const std::vector<const char*>& valid_values) { | 401 const std::vector<const char*>& valid_values) { |
402 const base::ListValue* list = NULL; | 402 const base::ListValue* list = NULL; |
403 if (object.GetListWithoutPathExpansion(field_name, &list)) { | 403 if (object.GetListWithoutPathExpansion(field_name, &list)) { |
404 path_.push_back(field_name); | 404 path_.push_back(field_name); |
405 for (const auto& entry : *list) { | 405 for (const auto& entry : *list) { |
406 std::string value; | 406 std::string value; |
407 if (!entry->GetAsString(&value)) { | 407 if (!entry.GetAsString(&value)) { |
408 NOTREACHED(); // The types of field values are already verified. | 408 NOTREACHED(); // The types of field values are already verified. |
409 continue; | 409 continue; |
410 } | 410 } |
411 if (!IsValidValue(value, valid_values)) { | 411 if (!IsValidValue(value, valid_values)) { |
412 path_.pop_back(); | 412 path_.pop_back(); |
413 return false; | 413 return false; |
414 } | 414 } |
415 } | 415 } |
416 path_.pop_back(); | 416 path_.pop_back(); |
417 } | 417 } |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 } | 1016 } |
1017 | 1017 |
1018 std::string Validator::MessageHeader() { | 1018 std::string Validator::MessageHeader() { |
1019 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, "."); | 1019 std::string path = path_.empty() ? "toplevel" : base::JoinString(path_, "."); |
1020 std::string message = "At " + path + ": "; | 1020 std::string message = "At " + path + ": "; |
1021 return message; | 1021 return message; |
1022 } | 1022 } |
1023 | 1023 |
1024 } // namespace onc | 1024 } // namespace onc |
1025 } // namespace chromeos | 1025 } // namespace chromeos |
OLD | NEW |