Chromium Code Reviews| 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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 // Returns a Schema that references static data. This can be used by | 44 // Returns a Schema that references static data. This can be used by |
| 45 // the embedder to pass structures generated at compile time, which can then | 45 // the embedder to pass structures generated at compile time, which can then |
| 46 // be quickly loaded at runtime. | 46 // be quickly loaded at runtime. |
| 47 static Schema Wrap(const internal::SchemaData* data); | 47 static Schema Wrap(const internal::SchemaData* data); |
| 48 | 48 |
| 49 // Parses the JSON schema in |schema| and returns a Schema that owns | 49 // Parses the JSON schema in |schema| and returns a Schema that owns |
| 50 // the internal representation. If |schema| is invalid then an invalid Schema | 50 // the internal representation. If |schema| is invalid then an invalid Schema |
| 51 // is returned and |error| contains a reason for the failure. | 51 // is returned and |error| contains a reason for the failure. |
| 52 static Schema Parse(const std::string& schema, std::string* error); | 52 static Schema Parse(const std::string& schema, std::string* error); |
| 53 | 53 |
| 54 // Same as Parse(), but if |with_backwards_compatibility| is true then arrays | |
| 55 // that don't declare a schema for their items will default to be arrays of | |
| 56 // strings. This is meant to support Legacy Browser Support until it is | |
| 57 // updated to use a proper schema. | |
|
Mattias Nissler (ping if slow)
2013/12/03 20:22:00
I don't get why LBS needs this - shouldn't arrays
Joao da Silva
2013/12/04 10:20:06
LBS does not include the "items" schema because ot
| |
| 58 // TODO(joaodasilva): remove this by M35. http://crbug.com/325349 | |
| 59 static Schema ParseWithBackwardsCompatibility( | |
| 60 const std::string& schema, | |
| 61 std::string* error, | |
| 62 bool with_backwards_compatibility); | |
| 63 | |
| 54 // Returns true if this Schema is valid. Schemas returned by the methods below | 64 // Returns true if this Schema is valid. Schemas returned by the methods below |
| 55 // may be invalid, and in those cases the other methods must not be used. | 65 // may be invalid, and in those cases the other methods must not be used. |
| 56 bool valid() const { return node_ != NULL; } | 66 bool valid() const { return node_ != NULL; } |
| 57 | 67 |
| 58 base::Value::Type type() const; | 68 base::Value::Type type() const; |
| 59 | 69 |
| 60 // Returns true if |value| conforms to this Schema. | 70 // Returns true if |value| conforms to this Schema. |
| 61 bool Validate(const base::Value& value) const; | 71 bool Validate(const base::Value& value) const; |
| 62 | 72 |
| 63 // Used to iterate over the known properties of TYPE_DICTIONARY schemas. | 73 // Used to iterate over the known properties of TYPE_DICTIONARY schemas. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 Schema(const scoped_refptr<const InternalStorage>& storage, | 128 Schema(const scoped_refptr<const InternalStorage>& storage, |
| 119 const internal::SchemaNode* node); | 129 const internal::SchemaNode* node); |
| 120 | 130 |
| 121 scoped_refptr<const InternalStorage> storage_; | 131 scoped_refptr<const InternalStorage> storage_; |
| 122 const internal::SchemaNode* node_; | 132 const internal::SchemaNode* node_; |
| 123 }; | 133 }; |
| 124 | 134 |
| 125 } // namespace policy | 135 } // namespace policy |
| 126 | 136 |
| 127 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 137 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
| OLD | NEW |