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

Side by Side Diff: components/json_schema/json_schema_validator.cc

Issue 1323923002: Remove use of JSONReader::DeprecatedRead from components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Error fix Created 5 years, 3 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/json_schema/json_schema_validator.h" 5 #include "components/json_schema/json_schema_validator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cfloat> 8 #include <cfloat>
9 #include <cmath> 9 #include <cmath>
10 #include <vector> 10 #include <vector>
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 std::string* error) { 392 std::string* error) {
393 return JSONSchemaValidator::IsValidSchema(schema, 0, error); 393 return JSONSchemaValidator::IsValidSchema(schema, 0, error);
394 } 394 }
395 395
396 // static 396 // static
397 scoped_ptr<base::DictionaryValue> JSONSchemaValidator::IsValidSchema( 397 scoped_ptr<base::DictionaryValue> JSONSchemaValidator::IsValidSchema(
398 const std::string& schema, 398 const std::string& schema,
399 int validator_options, 399 int validator_options,
400 std::string* error) { 400 std::string* error) {
401 base::JSONParserOptions json_options = base::JSON_PARSE_RFC; 401 base::JSONParserOptions json_options = base::JSON_PARSE_RFC;
402 scoped_ptr<base::Value> json(base::JSONReader::DeprecatedReadAndReturnError( 402 scoped_ptr<base::Value> json =
403 schema, json_options, NULL, error)); 403 base::JSONReader::ReadAndReturnError(schema, json_options, NULL, error);
404 if (!json) 404 if (!json)
405 return scoped_ptr<base::DictionaryValue>(); 405 return scoped_ptr<base::DictionaryValue>();
406 base::DictionaryValue* dict = NULL; 406 base::DictionaryValue* dict = NULL;
407 if (!json->GetAsDictionary(&dict)) { 407 if (!json->GetAsDictionary(&dict)) {
408 *error = "Schema must be a JSON object"; 408 *error = "Schema must be a JSON object";
409 return scoped_ptr<base::DictionaryValue>(); 409 return scoped_ptr<base::DictionaryValue>();
410 } 410 }
411 if (!::IsValidSchema(dict, validator_options, error)) 411 if (!::IsValidSchema(dict, validator_options, error))
412 return scoped_ptr<base::DictionaryValue>(); 412 return scoped_ptr<base::DictionaryValue>();
413 ignore_result(json.release()); 413 ignore_result(json.release());
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 836
837 if (*additional_properties_schema) { 837 if (*additional_properties_schema) {
838 std::string additional_properties_type(schema::kAny); 838 std::string additional_properties_type(schema::kAny);
839 CHECK((*additional_properties_schema)->GetString( 839 CHECK((*additional_properties_schema)->GetString(
840 schema::kType, &additional_properties_type)); 840 schema::kType, &additional_properties_type));
841 return additional_properties_type == schema::kAny; 841 return additional_properties_type == schema::kAny;
842 } else { 842 } else {
843 return default_allow_additional_properties_; 843 return default_allow_additional_properties_;
844 } 844 }
845 } 845 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698