Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 LOG(ERROR) << MessageHeader() << "Found an empty string, but expected a " | 396 LOG(ERROR) << MessageHeader() << "Found an empty string, but expected a " |
| 397 << "non-empty string."; | 397 << "non-empty string."; |
| 398 path_.pop_back(); | 398 path_.pop_back(); |
| 399 return true; | 399 return true; |
| 400 } | 400 } |
| 401 | 401 |
| 402 bool Validator::RequireField(const base::DictionaryValue& dict, | 402 bool Validator::RequireField(const base::DictionaryValue& dict, |
| 403 const std::string& field_name) { | 403 const std::string& field_name) { |
| 404 if (dict.HasKey(field_name)) | 404 if (dict.HasKey(field_name)) |
| 405 return true; | 405 return true; |
| 406 error_or_warning_found_ = true; | |
| 407 std::string message = MessageHeader() + "The required field '" + field_name + | 406 std::string message = MessageHeader() + "The required field '" + field_name + |
| 408 "' is missing."; | 407 "' is missing."; |
| 409 if (error_on_missing_field_) | 408 if (error_on_missing_field_) { |
| 409 error_or_warning_found_ = true; | |
| 410 LOG(ERROR) << message; | 410 LOG(ERROR) << message; |
| 411 else | 411 } else { |
| 412 LOG(WARNING) << message; | 412 VLOG(1) << message; |
| 413 } | |
|
stevenjb
2014/11/04 19:32:18
This doesn't seem to me like it should be a "warni
| |
| 413 return false; | 414 return false; |
| 414 } | 415 } |
| 415 | 416 |
| 416 bool Validator::CheckGuidIsUniqueAndAddToSet(const base::DictionaryValue& dict, | 417 bool Validator::CheckGuidIsUniqueAndAddToSet(const base::DictionaryValue& dict, |
| 417 const std::string& key_guid, | 418 const std::string& key_guid, |
| 418 std::set<std::string> *guids) { | 419 std::set<std::string> *guids) { |
| 419 std::string guid; | 420 std::string guid; |
| 420 if (dict.GetStringWithoutPathExpansion(key_guid, &guid)) { | 421 if (dict.GetStringWithoutPathExpansion(key_guid, &guid)) { |
| 421 if (guids->count(guid) != 0) { | 422 if (guids->count(guid) != 0) { |
| 422 error_or_warning_found_ = true; | 423 error_or_warning_found_ = true; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 } | 849 } |
| 849 | 850 |
| 850 std::string Validator::MessageHeader() { | 851 std::string Validator::MessageHeader() { |
| 851 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); | 852 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); |
| 852 std::string message = "At " + path + ": "; | 853 std::string message = "At " + path + ": "; |
| 853 return message; | 854 return message; |
| 854 } | 855 } |
| 855 | 856 |
| 856 } // namespace onc | 857 } // namespace onc |
| 857 } // namespace chromeos | 858 } // namespace chromeos |
| OLD | NEW |