OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |