Chromium Code Reviews| Index: chrome/browser/policy/policy_schema.h |
| diff --git a/chrome/browser/policy/policy_schema.h b/chrome/browser/policy/policy_schema.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..168efb89e75cb0b754ba08ccc0117dda2927347f |
| --- /dev/null |
| +++ b/chrome/browser/policy/policy_schema.h |
| @@ -0,0 +1,47 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_POLICY_POLICY_SCHEMA_H_ |
| +#define CHROME_BROWSER_POLICY_POLICY_SCHEMA_H_ |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/values.h" |
| + |
| +namespace policy { |
| + |
| +// Maps known policy keys to their expected types. Currently, only the top-level |
| +// type is declared; the types of list and dictionary entries are not declared. |
|
Mattias Nissler (ping if slow)
2013/05/15 10:04:12
Is there a plan for further type checks? In partic
Joao da Silva
2013/05/19 13:17:08
That comment made me think more about this, and I
|
| +class PolicySchema { |
| + public: |
| + typedef std::map<std::string, base::Value::Type> TypeMap; |
| + |
| + // Parses |schema| as a JSON v3 schema, and additionally verifies that: |
| + // - the version is JSON schema v3; |
| + // - the top-level entry is of type "object"; |
| + // - the top-level object doesn't contain "additionalProperties" nor |
| + // "patternProperties"; |
| + // - each "property" maps to a schema with one "type"; |
| + // If all the checks pass then the parsed PolicySchema is returned; otherwise |
| + // returns NULL. |
| + static scoped_ptr<PolicySchema> Parse(const std::string& schema, |
| + std::string* error); |
| + ~PolicySchema(); |
| + |
| + const TypeMap& type_map() const { return type_map_; } |
| + |
| + private: |
| + PolicySchema(); |
| + |
| + TypeMap type_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PolicySchema); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_POLICY_SCHEMA_H_ |