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 <cstdio> | 5 #include <cstdio> |
6 #include <iostream> | 6 #include <iostream> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 " %i File is invalid.\n" | 75 " %i File is invalid.\n" |
76 " %i File couldn't be read or is not a valid JSON dictionary.\n" | 76 " %i File couldn't be read or is not a valid JSON dictionary.\n" |
77 " %i Some command line arguments are wrong.\n", | 77 " %i Some command line arguments are wrong.\n", |
78 kStatusValid, | 78 kStatusValid, |
79 kStatusWarnings, | 79 kStatusWarnings, |
80 kStatusInvalid, | 80 kStatusInvalid, |
81 kStatusJsonError, | 81 kStatusJsonError, |
82 kStatusArgumentError); | 82 kStatusArgumentError); |
83 } | 83 } |
84 | 84 |
85 scoped_ptr<base::DictionaryValue> ReadDictionary(std::string filename) { | 85 scoped_ptr<base::DictionaryValue> ReadDictionary(const std::string& filename) { |
86 base::FilePath path(filename); | 86 base::FilePath path(filename); |
87 JSONFileValueDeserializer deserializer(path); | 87 JSONFileValueDeserializer deserializer(path); |
88 deserializer.set_allow_trailing_comma(true); | 88 deserializer.set_allow_trailing_comma(true); |
89 | 89 |
90 base::DictionaryValue* dict = NULL; | 90 base::DictionaryValue* dict = NULL; |
91 | 91 |
92 std::string json_error; | 92 std::string json_error; |
93 base::Value* value = deserializer.Deserialize(NULL, &json_error); | 93 base::Value* value = deserializer.Deserialize(NULL, &json_error); |
94 if (!value) { | 94 if (!value) { |
95 LOG(ERROR) << "Couldn't json-deserialize file '" << filename | 95 LOG(ERROR) << "Couldn't json-deserialize file '" << filename |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } else if (type_arg == kCertificate) { | 144 } else if (type_arg == kCertificate) { |
145 signature = &chromeos::onc::kCertificateSignature; | 145 signature = &chromeos::onc::kCertificateSignature; |
146 } else { | 146 } else { |
147 LOG(ERROR) << "Unknown ONC type '" << type_arg << "'"; | 147 LOG(ERROR) << "Unknown ONC type '" << type_arg << "'"; |
148 return kStatusArgumentError; | 148 return kStatusArgumentError; |
149 } | 149 } |
150 | 150 |
151 chromeos::onc::Validator::Result result; | 151 chromeos::onc::Validator::Result result; |
152 validator.ValidateAndRepairObject(signature, *onc_object, &result); | 152 validator.ValidateAndRepairObject(signature, *onc_object, &result); |
153 | 153 |
154 switch(result) { | 154 switch (result) { |
155 case chromeos::onc::Validator::VALID: | 155 case chromeos::onc::Validator::VALID: |
156 return kStatusValid; | 156 return kStatusValid; |
157 case chromeos::onc::Validator::VALID_WITH_WARNINGS: | 157 case chromeos::onc::Validator::VALID_WITH_WARNINGS: |
158 return kStatusWarnings; | 158 return kStatusWarnings; |
159 case chromeos::onc::Validator::INVALID: | 159 case chromeos::onc::Validator::INVALID: |
160 return kStatusInvalid; | 160 return kStatusInvalid; |
161 default: | 161 default: |
162 CHECK(false); | 162 CHECK(false); |
163 } | 163 } |
164 } | 164 } |
OLD | NEW |