| Index: components/policy/core/common/schema.cc
|
| diff --git a/components/policy/core/common/schema.cc b/components/policy/core/common/schema.cc
|
| index 325ec2a26e11fe5715937ba0d0c57e5931d7b42e..8046aa748820a135a230fc3b29b67b05dbe67576 100644
|
| --- a/components/policy/core/common/schema.cc
|
| +++ b/components/policy/core/common/schema.cc
|
| @@ -299,6 +299,34 @@ Schema Schema::Wrap(const SchemaData* data) {
|
| return Schema(storage, storage->root_node());
|
| }
|
|
|
| +bool Schema::Matches(const base::Value& value) const {
|
| + if (!valid()) {
|
| + // Schema not found, invalid entry.
|
| + return false;
|
| + }
|
| +
|
| + if (!value.IsType(type()))
|
| + return false;
|
| +
|
| + const base::DictionaryValue* dict = NULL;
|
| + const base::ListValue* list = NULL;
|
| + if (value.GetAsDictionary(&dict)) {
|
| + for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd();
|
| + it.Advance()) {
|
| + if (!GetProperty(it.key()).Matches(it.value()))
|
| + return false;
|
| + }
|
| + } else if (value.GetAsList(&list)) {
|
| + for (base::ListValue::const_iterator it = list->begin();
|
| + it != list->end(); ++it) {
|
| + if (!*it || !GetItems().Matches(**it))
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + return true;
|
| +}
|
| +
|
| // static
|
| Schema Schema::Parse(const std::string& content, std::string* error) {
|
| // Validate as a generic JSON schema.
|
|
|