Chromium Code Reviews| Index: components/policy/core/common/schema.h |
| diff --git a/components/policy/core/common/schema.h b/components/policy/core/common/schema.h |
| index e4190fbde4a65b4c0b8c0a0de5ebc6a30142d8cd..8c4856d800d9bcd6b5ed7c0a021477f3cd0ae6b9 100644 |
| --- a/components/policy/core/common/schema.h |
| +++ b/components/policy/core/common/schema.h |
| @@ -22,6 +22,26 @@ struct POLICY_EXPORT PropertiesNode; |
| } // namespace internal |
| +// Option flags passed to Schema::Validate() and Schema::Normalize(), describing |
| +// the strategy to handle unknown or invalid properties for dict type. Note |
|
Joao da Silva
2014/01/23 15:52:36
This is not only for the dict type. How about:
"t
binjin
2014/01/23 17:20:13
Done.
|
| +// that in Schema::Normalize() allowed errors will be dropped and thus |
| +// ignored. |
| +enum SchemaOnErrorStrategy { |
| + // No errors will be allowed. |
| + SCHEMA_STRICT = 0, |
| + // Unknown properties in the top-level dictionary will be ignored. |
| + SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, |
| + // Unknown properties in any dictionary will be ignored. |
| + SCHEMA_ALLOW_UNKNOWN, |
| + // Mismatched values will be ignored at the toplevel. |
| + SCHEMA_ALLOW_INVALID_TOPLEVEL, |
| + // Mismatched values will be ignored at the top-level dictionary. |
|
Joao da Silva
2014/01/23 15:52:36
"at the top-level value."
It could be a list, for
binjin
2014/01/23 17:20:13
Done.
|
| + // Unknown properties in any dictionary will be ignored. |
| + SCHEMA_ALLOW_INVALID_TOPLEVEL_AND_ALLOW_UNKNOWN, |
| + // Mismatched values will be ignored. |
| + SCHEMA_ALLOW_INVALID, |
| +}; |
| + |
| // Describes the expected type of one policy. Also recursively describes the |
| // types of inner elements, for structured types. |
| // Objects of this class refer to external, immutable data and are cheap to |
| @@ -57,8 +77,21 @@ class POLICY_EXPORT Schema { |
| base::Value::Type type() const; |
| - // Returns true if |value| conforms to this Schema. |
| - bool Validate(const base::Value& value) const; |
| + // Validate |value| against current schema, |strategy| is the strategy to |
| + // handle unknown or invalid properties in dict type. Allowed errors will be |
|
Joao da Silva
2014/01/23 15:52:36
"handle unknown properties or invalid values."
binjin
2014/01/23 17:20:13
Done.
|
| + // ignored. If |value| don't conform the schema, false will be returned and |
| + // |error| will contain the detailed reason. |
| + bool Validate(const base::Value& value, |
| + SchemaOnErrorStrategy strategy, |
| + std::string* error) const; |
| + |
| + // Validate |value| against current schema, |strategy| is the strategy to |
| + // handle unknown or invalid properties in dict type. Allowed errors will be |
|
Joao da Silva
2014/01/23 15:52:36
"handle unknown properties or invalid values."
binjin
2014/01/23 17:20:13
Done.
|
| + // dropped in place. If |value| don't conform the schema, false will be |
| + // returned and |error| will contain the detailed message. |
| + bool Normalize(base::Value* value, |
| + SchemaOnErrorStrategy strategy, |
| + std::string* error) const; |
| // Used to iterate over the known properties of TYPE_DICTIONARY schemas. |
| class POLICY_EXPORT Iterator { |