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

Unified Diff: chrome/browser/policy/policy_schema.h

Issue 15133005: Added a PolicySchema class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | chrome/browser/policy/policy_schema.cc » ('j') | chrome/browser/policy/policy_schema.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | chrome/browser/policy/policy_schema.cc » ('j') | chrome/browser/policy/policy_schema.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698