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

Unified Diff: chrome/tools/build/generate_policy_source.py

Issue 22364011: policy: generate JSON schema at build time as a string constant. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 3 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/tools/build/generate_policy_source.py
diff --git a/chrome/tools/build/generate_policy_source.py b/chrome/tools/build/generate_policy_source.py
index d88374d173342f98a96c3f951e641c090256ae58..c06baf8a61a7c6a93d891e15661047f51fb855cd 100755
--- a/chrome/tools/build/generate_policy_source.py
+++ b/chrome/tools/build/generate_policy_source.py
@@ -16,6 +16,7 @@ from optparse import OptionParser
import re
import sys
import textwrap
+import json
Joao da Silva 2013/09/11 11:43:37 alread in line 14
CHROME_POLICY_KEY = 'SOFTWARE\\\\Policies\\\\Google\\\\Chrome'
@@ -53,6 +54,7 @@ class PolicyDetails:
self.name = policy['name']
self.is_deprecated = policy.get('deprecated', False)
self.is_device_only = policy.get('device_only', False)
+ self.schema = policy.get('schema', {})
if is_chromium_os:
expected_platform = 'chrome_os'
@@ -223,7 +225,10 @@ def _WritePolicyConstantHeader(policies, os, f):
'configuration resides.\n'
'extern const wchar_t kRegistryChromePolicyKey[];\n')
- f.write('// Lists metadata such as name, expected type and id for all\n'
+ f.write('// JSON schema for policy.\n'
+ 'extern const char kPolicyJsonSchema[];\n'
+ '\n'
+ '// Lists metadata such as name, expected type and id for all\n'
'// policies. Used to initialize ConfigurationPolicyProviders and\n'
'// CloudExternalDataManagers.\n'
'struct PolicyDefinitionList {\n'
@@ -308,6 +313,16 @@ def _WritePolicyConstantSource(policies, os, f):
'L"' + CHROMIUM_POLICY_KEY + '";\n'
'#endif\n\n')
+ # Inline the JSON schema for policy.
+ schema = {}
+ schema['$schema'] = 'http://json-schema.org/draft-03/schema#'
+ schema['type'] = 'object'
+ schema['properties'] = {}
+ for policy in policies:
+ schema['properties'][policy.name] = policy.schema
Joao da Silva 2013/09/11 11:43:37 make this conditional on policy.is_supported.
+ f.write('const char kPolicyJsonSchema[] = %s;\n\n' %
+ json.dumps(json.dumps(schema)))
Joao da Silva 2013/09/11 11:59:00 pass separators=(',', ':') to these 2 calls. It wi
+
f.write('bool IsDeprecatedPolicy(const std::string& policy) {\n')
if has_deprecated_policies:
# arraysize() doesn't work with empty arrays.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698