| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 '''python %prog [options] platform chromium_os_flag template | 6 '''python %prog [options] platform chromium_os_flag template |
| 7 | 7 |
| 8 platform specifies which platform source is being generated for | 8 platform specifies which platform source is being generated for |
| 9 and can be one of (win, mac, linux) | 9 and can be one of (win, mac, linux) |
| 10 chromium_os_flag should be 1 if this is a Chromium OS build | 10 chromium_os_flag should be 1 if this is a Chromium OS build |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 riskTags.ComputeMaxTags(policy_details) | 225 riskTags.ComputeMaxTags(policy_details) |
| 226 sorted_policy_details = sorted(policy_details, key=lambda policy: policy.name) | 226 sorted_policy_details = sorted(policy_details, key=lambda policy: policy.name) |
| 227 | 227 |
| 228 def GenerateFile(path, writer, sorted=False, xml=False): | 228 def GenerateFile(path, writer, sorted=False, xml=False): |
| 229 if path: | 229 if path: |
| 230 with open(path, 'w') as f: | 230 with open(path, 'w') as f: |
| 231 _OutputGeneratedWarningHeader(f, template_file_name, xml) | 231 _OutputGeneratedWarningHeader(f, template_file_name, xml) |
| 232 writer(sorted and sorted_policy_details or policy_details, | 232 writer(sorted and sorted_policy_details or policy_details, |
| 233 os, f, riskTags) | 233 os, f, riskTags) |
| 234 | 234 |
| 235 GenerateFile(opts.header_path, _WritePolicyConstantHeader, sorted=True) | 235 if opts.header_path: |
| 236 GenerateFile(opts.source_path, _WritePolicyConstantSource, sorted=True) | 236 GenerateFile(opts.header_path, _WritePolicyConstantHeader, sorted=True) |
| 237 GenerateFile(opts.risk_header_path, _WritePolicyRiskTagHeader) | 237 if opts.source_path: |
| 238 GenerateFile(opts.cloud_policy_proto_path, _WriteCloudPolicyProtobuf) | 238 GenerateFile(opts.source_path, _WritePolicyConstantSource, sorted=True) |
| 239 GenerateFile(opts.cloud_policy_full_runtime_proto_path, | 239 if opts.risk_header_path: |
| 240 _WriteCloudPolicyFullRuntimeProtobuf) | 240 GenerateFile(opts.risk_header_path, _WritePolicyRiskTagHeader) |
| 241 GenerateFile(opts.chrome_settings_proto_path, _WriteChromeSettingsProtobuf) | 241 if opts.cloud_policy_proto_path: |
| 242 GenerateFile(opts.cloud_policy_decoder_path, _WriteCloudPolicyDecoder) | 242 GenerateFile(opts.cloud_policy_proto_path, _WriteCloudPolicyProtobuf) |
| 243 if opts.cloud_policy_full_runtime_proto_path: |
| 244 GenerateFile(opts.cloud_policy_full_runtime_proto_path, |
| 245 _WriteCloudPolicyFullRuntimeProtobuf) |
| 246 if opts.chrome_settings_proto_path: |
| 247 GenerateFile(opts.chrome_settings_proto_path, _WriteChromeSettingsProtobuf) |
| 248 if opts.cloud_policy_decoder_path: |
| 249 GenerateFile(opts.cloud_policy_decoder_path, _WriteCloudPolicyDecoder) |
| 243 | 250 |
| 244 if os == 'android': | 251 if os == 'android' and opts.app_restrictions_path: |
| 245 GenerateFile(opts.app_restrictions_path, _WriteAppRestrictions, xml=True) | 252 GenerateFile(opts.app_restrictions_path, _WriteAppRestrictions, xml=True) |
| 246 | 253 |
| 247 return 0 | 254 return 0 |
| 248 | 255 |
| 249 | 256 |
| 250 #------------------ shared helpers ---------------------------------# | 257 #------------------ shared helpers ---------------------------------# |
| 251 | 258 |
| 252 def _OutputGeneratedWarningHeader(f, template_file_path, xml_style): | 259 def _OutputGeneratedWarningHeader(f, template_file_path, xml_style): |
| 253 left_margin = '//' | 260 left_margin = '//' |
| 254 if xml_style: | 261 if xml_style: |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 f.write('<restrictions xmlns:android="' | 1268 f.write('<restrictions xmlns:android="' |
| 1262 'http://schemas.android.com/apk/res/android">\n\n') | 1269 'http://schemas.android.com/apk/res/android">\n\n') |
| 1263 for policy in policies: | 1270 for policy in policies: |
| 1264 if (policy.is_supported and policy.restriction_type != 'invalid' and | 1271 if (policy.is_supported and policy.restriction_type != 'invalid' and |
| 1265 not policy.is_deprecated and not policy.is_future): | 1272 not policy.is_deprecated and not policy.is_future): |
| 1266 WriteAppRestriction(policy) | 1273 WriteAppRestriction(policy) |
| 1267 f.write('</restrictions>') | 1274 f.write('</restrictions>') |
| 1268 | 1275 |
| 1269 if __name__ == '__main__': | 1276 if __name__ == '__main__': |
| 1270 sys.exit(main()) | 1277 sys.exit(main()) |
| OLD | NEW |