| 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 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // be quickly loaded at runtime. | 76 // be quickly loaded at runtime. |
| 77 static Schema Wrap(const internal::SchemaData* data); | 77 static Schema Wrap(const internal::SchemaData* data); |
| 78 | 78 |
| 79 // Parses the JSON schema in |schema| and returns a Schema that owns | 79 // Parses the JSON schema in |schema| and returns a Schema that owns |
| 80 // the internal representation. If |schema| is invalid then an invalid Schema | 80 // the internal representation. If |schema| is invalid then an invalid Schema |
| 81 // is returned and |error| contains a reason for the failure. | 81 // is returned and |error| contains a reason for the failure. |
| 82 static Schema Parse(const std::string& schema, std::string* error); | 82 static Schema Parse(const std::string& schema, std::string* error); |
| 83 | 83 |
| 84 // Returns true if this Schema is valid. Schemas returned by the methods below | 84 // Returns true if this Schema is valid. Schemas returned by the methods below |
| 85 // may be invalid, and in those cases the other methods must not be used. | 85 // may be invalid, and in those cases the other methods must not be used. |
| 86 bool valid() const { return node_ != NULL; } | 86 bool valid() const; |
| 87 | 87 |
| 88 base::Value::Type type() const; | 88 base::Value::Type type() const; |
| 89 | 89 |
| 90 // Validate |value| against current schema, |strategy| is the strategy to | 90 // Validate |value| against current schema, |strategy| is the strategy to |
| 91 // handle unknown properties or invalid values. Allowed errors will be | 91 // handle unknown properties or invalid values. Allowed errors will be |
| 92 // ignored. |error_path| and |error| will contain the last error location and | 92 // ignored. |error_path| and |error| will contain the last error location and |
| 93 // detailed message if |value| doesn't strictly conform to the schema. If | 93 // detailed message if |value| doesn't strictly conform to the schema. If |
| 94 // |value| doesn't conform to the schema even within the allowance of | 94 // |value| doesn't conform to the schema even within the allowance of |
| 95 // |strategy|, false will be returned and |error_path| and |error| will | 95 // |strategy|, false will be returned and |error_path| and |error| will |
| 96 // contain the corresponding error that caused the failure. |error_path| can | 96 // contain the corresponding error that caused the failure. |error_path| can |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 bool ValidateIntegerRestriction(int index, int value) const; | 185 bool ValidateIntegerRestriction(int index, int value) const; |
| 186 bool ValidateStringRestriction(int index, const char* str) const; | 186 bool ValidateStringRestriction(int index, const char* str) const; |
| 187 | 187 |
| 188 scoped_refptr<const InternalStorage> storage_; | 188 scoped_refptr<const InternalStorage> storage_; |
| 189 const internal::SchemaNode* node_; | 189 const internal::SchemaNode* node_; |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 } // namespace policy | 192 } // namespace policy |
| 193 | 193 |
| 194 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 194 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
| OLD | NEW |