OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <cstdio> | 6 #include <cstdio> |
7 #include <iostream> | 7 #include <iostream> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
| 13 #include "base/json/json_reader.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "chromeos/network/onc/onc_signature.h" | 16 #include "chromeos/network/onc/onc_signature.h" |
16 #include "chromeos/network/onc/onc_validator.h" | 17 #include "chromeos/network/onc/onc_validator.h" |
17 | 18 |
18 // TODO Check why this file do not fail on default trybots | 19 // TODO Check why this file do not fail on default trybots |
19 // http://crbug.com/543919 | 20 // http://crbug.com/543919 |
20 | 21 |
21 // Command line switches. | 22 // Command line switches. |
22 const char kSwitchErrorOnUnknownField[] = "error-on-unknown-field"; | 23 const char kSwitchErrorOnUnknownField[] = "error-on-unknown-field"; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 kStatusValid, | 83 kStatusValid, |
83 kStatusWarnings, | 84 kStatusWarnings, |
84 kStatusInvalid, | 85 kStatusInvalid, |
85 kStatusJsonError, | 86 kStatusJsonError, |
86 kStatusArgumentError); | 87 kStatusArgumentError); |
87 } | 88 } |
88 | 89 |
89 std::unique_ptr<base::DictionaryValue> ReadDictionary( | 90 std::unique_ptr<base::DictionaryValue> ReadDictionary( |
90 const std::string& filename) { | 91 const std::string& filename) { |
91 base::FilePath path(filename); | 92 base::FilePath path(filename); |
92 JSONFileValueDeserializer deserializer(path); | 93 JSONFileValueDeserializer deserializer(path, |
93 deserializer.set_allow_trailing_comma(true); | 94 base::JSON_ALLOW_TRAILING_COMMAS); |
94 | 95 |
95 std::string json_error; | 96 std::string json_error; |
96 std::unique_ptr<base::Value> value = | 97 std::unique_ptr<base::Value> value = |
97 deserializer.Deserialize(NULL, &json_error); | 98 deserializer.Deserialize(NULL, &json_error); |
98 if (!value) { | 99 if (!value) { |
99 LOG(ERROR) << "Couldn't json-deserialize file '" << filename | 100 LOG(ERROR) << "Couldn't json-deserialize file '" << filename |
100 << "': " << json_error; | 101 << "': " << json_error; |
101 return nullptr; | 102 return nullptr; |
102 } | 103 } |
103 | 104 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 case chromeos::onc::Validator::VALID: | 162 case chromeos::onc::Validator::VALID: |
162 return kStatusValid; | 163 return kStatusValid; |
163 case chromeos::onc::Validator::VALID_WITH_WARNINGS: | 164 case chromeos::onc::Validator::VALID_WITH_WARNINGS: |
164 return kStatusWarnings; | 165 return kStatusWarnings; |
165 case chromeos::onc::Validator::INVALID: | 166 case chromeos::onc::Validator::INVALID: |
166 return kStatusInvalid; | 167 return kStatusInvalid; |
167 default: | 168 default: |
168 CHECK(false); | 169 CHECK(false); |
169 } | 170 } |
170 } | 171 } |
OLD | NEW |