Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chromeos/tools/onc_validator/onc_validator.cc

Issue 2475583002: Adds option for JSON reader to allow invalid utf characters (Closed)
Patch Set: comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_utils_unittest.cc ('k') | components/bookmarks/browser/bookmark_storage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698