Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_POLICY_POLICY_SCHEMA_H_ | |
| 6 #define CHROME_BROWSER_POLICY_POLICY_SCHEMA_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/values.h" | |
| 14 | |
| 15 namespace policy { | |
| 16 | |
| 17 // Maps known policy keys to their expected types. Currently, only the top-level | |
| 18 // 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
| |
| 19 class PolicySchema { | |
| 20 public: | |
| 21 typedef std::map<std::string, base::Value::Type> TypeMap; | |
| 22 | |
| 23 // Parses |schema| as a JSON v3 schema, and additionally verifies that: | |
| 24 // - the version is JSON schema v3; | |
| 25 // - the top-level entry is of type "object"; | |
| 26 // - the top-level object doesn't contain "additionalProperties" nor | |
| 27 // "patternProperties"; | |
| 28 // - each "property" maps to a schema with one "type"; | |
| 29 // If all the checks pass then the parsed PolicySchema is returned; otherwise | |
| 30 // returns NULL. | |
| 31 static scoped_ptr<PolicySchema> Parse(const std::string& schema, | |
| 32 std::string* error); | |
| 33 ~PolicySchema(); | |
| 34 | |
| 35 const TypeMap& type_map() const { return type_map_; } | |
| 36 | |
| 37 private: | |
| 38 PolicySchema(); | |
| 39 | |
| 40 TypeMap type_map_; | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(PolicySchema); | |
| 43 }; | |
| 44 | |
| 45 } // namespace policy | |
| 46 | |
| 47 #endif // CHROME_BROWSER_POLICY_POLICY_SCHEMA_H_ | |
| OLD | NEW |