diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-28 18:01:28 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-28 18:01:28 +0000 |
commit | a43a3b434ed477799bba7b35591304fd251af474 (patch) | |
tree | 290ac40278e1a9c74d728d8902ef14f43081410d /components/json_schema | |
parent | 28acb80ab30aece2e8a59db74bcff0d1fc992a50 (diff) | |
download | chromium_src-a43a3b434ed477799bba7b35591304fd251af474.zip chromium_src-a43a3b434ed477799bba7b35591304fd251af474.tar.gz chromium_src-a43a3b434ed477799bba7b35591304fd251af474.tar.bz2 |
Resolve "$ref" attributes in JSON schemas.
This allows managed extensions to declare policies that have a recursive type
(e.g. a hierarchy of bookmarks with folders) or to reuse the same policy type
for multiple policies.
BUG=108992
Review URL: https://codereview.chromium.org/88573002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/json_schema')
-rw-r--r-- | components/json_schema/json_schema_validator.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/components/json_schema/json_schema_validator.cc b/components/json_schema/json_schema_validator.cc index 3cc9e2b..32cb93c 100644 --- a/components/json_schema/json_schema_validator.cc +++ b/components/json_schema/json_schema_validator.cc @@ -89,7 +89,7 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { { schema::kTitle, base::Value::TYPE_STRING }, }; - bool has_type = false; + bool has_type_or_ref = false; const base::ListValue* list_value = NULL; const base::DictionaryValue* dictionary_value = NULL; std::string string_value; @@ -119,7 +119,7 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { *error = "Invalid value for type attribute"; return false; } - has_type = true; + has_type_or_ref = true; continue; } @@ -242,10 +242,13 @@ bool IsValidSchema(const base::DictionaryValue* dict, std::string* error) { } } } + + if (it.key() == schema::kRef) + has_type_or_ref = true; } - if (!has_type) { - *error = "Schema must have a type attribute"; + if (!has_type_or_ref) { + *error = "Schema must have a type or a $ref attribute"; return false; } |