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

Unified Diff: components/policy/tools/generate_policy_source.py

Issue 2777063009: Generate list of Chrome OS device polices (Closed)
Patch Set: Created 3 years, 9 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: components/policy/tools/generate_policy_source.py
diff --git a/components/policy/tools/generate_policy_source.py b/components/policy/tools/generate_policy_source.py
index 8f3c40c49b82d62cbe7253b736b4a36ce3329f74..3cc47d954f33eed347e929e78c958f58a3c6be4a 100755
--- a/components/policy/tools/generate_policy_source.py
+++ b/components/policy/tools/generate_policy_source.py
@@ -1257,6 +1257,12 @@ def _GetSupportedUserPolicies(policies):
not policy.is_device_only, policies)
+# Returns a list of supported device policies by filtering |policies|.
+def _GetSupportedDevicePolicies(policies):
+ return filter(lambda policy: policy.is_supported and
+ policy.is_device_only, policies)
+
+
# Returns the set of all policy.policy_protobuf_type strings from |policies|.
def _GetProtobufTypes(policies):
return set(policy.policy_protobuf_type for policy in policies)
@@ -1300,6 +1306,10 @@ def _WriteChromeOSPolicyConstantsHeader(policies, os, f, risk_tags):
f.write('extern const char k' + policy.name + '[];\n')
f.write('\n} // namespace key\n\n')
+ # Device policy keys.
+ f.write('// NULL-terminated list of device policy registry key names.\n')
+ f.write('extern const char* kDevicePolicyKeys[];\n\n');
+
# User policy proto pointers, one struct for each protobuf type.
for protobuf_type in protobuf_types:
_WriteChromeOSPolicyAccessHeader(f, protobuf_type)
@@ -1338,6 +1348,13 @@ def _WriteChromeOSPolicyConstantsSource(policies, os, f, risk_tags):
f.write('const char k{name}[] = "{name}";\n'.format(name=policy.name))
f.write('\n} // namespace key\n\n')
+ # Device policy keys.
+ supported_device_policies = _GetSupportedDevicePolicies(policies)
+ f.write('const char* kDevicePolicyKeys[] = {\n\n');
+ for policy in supported_device_policies:
+ f.write(' key::k%s,\n' % policy.name)
+ f.write(' nullptr};\n\n');
+
# User policy proto pointers, one struct for each protobuf type.
supported_user_policies = _GetSupportedUserPolicies(policies)
protobuf_types = _GetProtobufTypes(supported_user_policies)
« 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