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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 error_or_warning_found_ = true; | 238 error_or_warning_found_ = true; |
239 LOG(WARNING) << MessageHeader() << "Found the field '" | 239 LOG(WARNING) << MessageHeader() << "Found the field '" |
240 << ::onc::kRecommended | 240 << ::onc::kRecommended |
241 << "' in an unmanaged ONC. Removing it."; | 241 << "' in an unmanaged ONC. Removing it."; |
242 return true; | 242 return true; |
243 } | 243 } |
244 | 244 |
245 std::unique_ptr<base::ListValue> repaired_recommended(new base::ListValue); | 245 std::unique_ptr<base::ListValue> repaired_recommended(new base::ListValue); |
246 for (const auto& entry : *recommended_list) { | 246 for (const auto& entry : *recommended_list) { |
247 std::string field_name; | 247 std::string field_name; |
248 if (!entry.GetAsString(&field_name)) { | 248 if (!entry->GetAsString(&field_name)) { |
249 NOTREACHED(); // The types of field values are already verified. | 249 NOTREACHED(); // The types of field values are already verified. |
250 continue; | 250 continue; |
251 } | 251 } |
252 | 252 |
253 const OncFieldSignature* field_signature = | 253 const OncFieldSignature* field_signature = |
254 GetFieldSignature(object_signature, field_name); | 254 GetFieldSignature(object_signature, field_name); |
255 | 255 |
256 bool found_error = false; | 256 bool found_error = false; |
257 std::string error_cause; | 257 std::string error_cause; |
258 if (!field_signature) { | 258 if (!field_signature) { |
(...skipping 138 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 |