Commit f2ea30b3 authored by kaliamoorthi's avatar kaliamoorthi Committed by Commit bot

Add optional mandatory policy setting for template generation

This CL modifies template writer such that mandatory policy templates are not generated when a flag is set.

BUG=410856

Review URL: https://codereview.chromium.org/546703004

Cr-Commit-Position: refs/heads/master@{#293917}
parent 3acfbb2b
......@@ -155,7 +155,7 @@ deps = {
Var('chromium_git') + '/external/snappy.git' + '@' + '762bb32f0c9d2f31ba4958c7c0933d22e80c20bf',
'src/tools/grit':
Var('chromium_git') + '/external/grit-i18n.git' + '@' + '77abf65c1d72af6fb7f9ef6f50cdf29fcf42d0a1', # from svn revision 175
Var('chromium_git') + '/external/grit-i18n.git' + '@' + '740badd5e3e44434a9a47b5d16749daac1e8ea80', # from svn revision 176
'src/tools/gyp':
Var('chromium_git') + '/external/gyp.git' + '@' + '6760f5b1a4852fd6ccbe4ffc409d73edac445744', # from svn revision 1972
......
......@@ -100,6 +100,9 @@
# documentation should state that the policy supports dynamic refresh or not.
# Supporting dynamic refresh means that Chrome respects the changes to the
# policy immediately, without the need for restart.
# 'can_be_mandatory' can be set to False to exclude that policy in the
# mandatory policies template. This only affects the template generation;
# The default is True.
# 'can_be_recommended' can be set to True to include that policy in the
# recommended policies templates. This only affects the template generation;
# all policies can be at the recommended level. The default is False.
......@@ -2743,6 +2746,7 @@
'dynamic_refresh': False,
'per_profile': True,
'can_be_recommended': True,
'can_be_mandatory' : False,
},
'example_value': [{'protocol': 'mailto', 'url': 'https://mail.google.com/mail/?extsrc=mailto&url=%s', 'default': 'true'}],
'id': 268,
......@@ -6786,6 +6790,10 @@
'desc': '''The name of the feature that indicates for a given policy that it can be recommended, instead of mandatory''',
'text': '''Can Be Recommended'''
},
'doc_feature_can_be_mandatory': {
'desc': '''The name of the feature that indicates for a given policy that it can be mandatory, instead of recommended''',
'text': '''Can Be Mandatory'''
},
'doc_feature_per_profile': {
'desc': '''The name of the feature that indicates whether a policy is applicable to browser Profiles individually or whether it affects the entire browser.''',
'text': '''Per Profile'''
......
......@@ -54,6 +54,9 @@ class PolicyDetails:
def __init__(self, policy, os, is_chromium_os):
self.id = policy['id']
self.name = policy['name']
features = policy.get('features', {})
self.can_be_recommended = features.get('can_be_recommended', False)
self.can_be_mandatory = features.get('can_be_mandatory', True)
self.is_deprecated = policy.get('deprecated', False)
self.is_device_only = policy.get('device_only', False)
self.schema = policy.get('schema', {})
......@@ -785,6 +788,9 @@ def _WritePolicyProto(f, policy, fields):
json.dumps(policy.schema, sort_keys=True, indent=4,
separators=(',', ': ')))
_OutputComment(f, '\nSupported on: %s' % ', '.join(policy.platforms))
if policy.can_be_recommended and not policy.can_be_mandatory:
_OutputComment(f, '\nNote: this policy must have a RECOMMENDED ' +\
'PolicyMode set in PolicyOptions.')
f.write('message %sProto {\n' % policy.name)
f.write(' optional PolicyOptions policy_options = 1;\n')
f.write(' optional %s %s = 2;\n' % (policy.protobuf_type, policy.name))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment