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

Unified Diff: components/policy/core/common/schema.h

Issue 134153005: Add strictness to Schema::Validate() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@expand-policy-schema-2
Patch Set: pull from previous CL Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/policy/core/common/schema.cc » ('j') | components/policy/core/common/schema.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..69b7d99669e27c3da8e918f43d41228d2fa23334 100644
--- a/components/policy/core/common/schema.h
+++ b/components/policy/core/common/schema.h
@@ -22,6 +22,19 @@ 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
+// that in Schema::Normalize() allowed errors will be dropped and thus
+// ignored.
+enum SchemaOnErrorStrategy {
+ SCHEMA_VERY_STRICT = 0,
Joao da Silva 2014/01/22 10:49:53 just SCHEMA_STRICT. Add a documenting comment: //
binjin 2014/01/23 12:01:31 Done.
+ SCHEMA_ALLOW_UNKNOWN_TOPLEVEL,
Joao da Silva 2014/01/22 10:49:53 Add a comment: // Unknown properties in the top-l
binjin 2014/01/23 12:01:31 Done.
+ SCHEMA_ALLOW_UNKNOWN,
Joao da Silva 2014/01/22 10:49:53 Add a comment: // Unknown properties in any dicti
binjin 2014/01/23 12:01:31 Done.
+ SCHEMA_ALLOW_INVALID_TOPLEVEL,
Joao da Silva 2014/01/22 10:49:53 Add a comment: // Mismatched values will be ignor
binjin 2014/01/23 12:01:31 Done.
+ SCHEMA_ALLOW_INVALID_TOPLEVEL_AND_ALLOW_UNKNOWN,
Joao da Silva 2014/01/22 10:49:53 Add a comment: // Mismatched values will be ignor
binjin 2014/01/23 12:01:31 Done.
+ SCHEMA_ALLOW_INVALID,
Joao da Silva 2014/01/22 10:49:53 Add a comment: // Mismatched values will be ignor
binjin 2014/01/23 12:01:31 Done.
+};
+
// 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 +70,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
+ // ignored. If |value| don't conform the schema, false will be returned and
+ // |error| will contain a message state the detailed reason.
Joao da Silva 2014/01/22 10:49:53 |error| will contain the detailed reason.
binjin 2014/01/23 12:01:31 Done.
+ 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
+ // dropped in place. If |value| don't conform the schema, false will be
+ // returned and |error| will contain a message state the detailed message.
Joao da Silva 2014/01/22 10:49:53 returned and |error| will contain the detailed rea
binjin 2014/01/23 12:01:31 Done.
+ 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 {
« no previous file with comments | « no previous file | components/policy/core/common/schema.cc » ('j') | components/policy/core/common/schema.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698