| 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 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 | 1250 |
| 1251 | 1251 |
| 1252 #------------------ Chrome OS policy constants header --------------# | 1252 #------------------ Chrome OS policy constants header --------------# |
| 1253 | 1253 |
| 1254 # Returns a list of supported user policies by filtering |policies|. | 1254 # Returns a list of supported user policies by filtering |policies|. |
| 1255 def _GetSupportedUserPolicies(policies): | 1255 def _GetSupportedUserPolicies(policies): |
| 1256 return filter(lambda policy: policy.is_supported and | 1256 return filter(lambda policy: policy.is_supported and |
| 1257 not policy.is_device_only, policies) | 1257 not policy.is_device_only, policies) |
| 1258 | 1258 |
| 1259 | 1259 |
| 1260 # Returns a list of supported device policies by filtering |policies|. |
| 1261 def _GetSupportedDevicePolicies(policies): |
| 1262 return filter(lambda policy: policy.is_supported and |
| 1263 policy.is_device_only, policies) |
| 1264 |
| 1265 |
| 1260 # Returns the set of all policy.policy_protobuf_type strings from |policies|. | 1266 # Returns the set of all policy.policy_protobuf_type strings from |policies|. |
| 1261 def _GetProtobufTypes(policies): | 1267 def _GetProtobufTypes(policies): |
| 1262 return set(policy.policy_protobuf_type for policy in policies) | 1268 return set(policy.policy_protobuf_type for policy in policies) |
| 1263 | 1269 |
| 1264 | 1270 |
| 1265 # Writes the definition of an array that contains the pointers to the mutable | 1271 # Writes the definition of an array that contains the pointers to the mutable |
| 1266 # proto field for each policy in |policies| of the given |protobuf_type|. | 1272 # proto field for each policy in |policies| of the given |protobuf_type|. |
| 1267 def _WriteChromeOSPolicyAccessHeader(f, protobuf_type): | 1273 def _WriteChromeOSPolicyAccessHeader(f, protobuf_type): |
| 1268 f.write('// Access to the mutable protobuf function of all supported ' | 1274 f.write('// Access to the mutable protobuf function of all supported ' |
| 1269 '%s user\n// policies.\n' % protobuf_type.lower()) | 1275 '%s user\n// policies.\n' % protobuf_type.lower()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1293 | 1299 |
| 1294 f.write('namespace policy {\n\n') | 1300 f.write('namespace policy {\n\n') |
| 1295 | 1301 |
| 1296 # Policy keys. | 1302 # Policy keys. |
| 1297 f.write('// Registry key names for user and device policies.\n' | 1303 f.write('// Registry key names for user and device policies.\n' |
| 1298 'namespace key {\n\n') | 1304 'namespace key {\n\n') |
| 1299 for policy in policies: | 1305 for policy in policies: |
| 1300 f.write('extern const char k' + policy.name + '[];\n') | 1306 f.write('extern const char k' + policy.name + '[];\n') |
| 1301 f.write('\n} // namespace key\n\n') | 1307 f.write('\n} // namespace key\n\n') |
| 1302 | 1308 |
| 1309 # Device policy keys. |
| 1310 f.write('// NULL-terminated list of device policy registry key names.\n') |
| 1311 f.write('extern const char* kDevicePolicyKeys[];\n\n'); |
| 1312 |
| 1303 # User policy proto pointers, one struct for each protobuf type. | 1313 # User policy proto pointers, one struct for each protobuf type. |
| 1304 for protobuf_type in protobuf_types: | 1314 for protobuf_type in protobuf_types: |
| 1305 _WriteChromeOSPolicyAccessHeader(f, protobuf_type) | 1315 _WriteChromeOSPolicyAccessHeader(f, protobuf_type) |
| 1306 | 1316 |
| 1307 f.write('} // namespace policy\n\n' | 1317 f.write('} // namespace policy\n\n' |
| 1308 '#endif // __BINDINGS_POLICY_CONSTANTS_H_\n') | 1318 '#endif // __BINDINGS_POLICY_CONSTANTS_H_\n') |
| 1309 | 1319 |
| 1310 | 1320 |
| 1311 #------------------ Chrome OS policy constants source --------------# | 1321 #------------------ Chrome OS policy constants source --------------# |
| 1312 | 1322 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1331 '#include "bindings/policy_constants.h"\n\n' | 1341 '#include "bindings/policy_constants.h"\n\n' |
| 1332 'namespace em = enterprise_management;\n\n' | 1342 'namespace em = enterprise_management;\n\n' |
| 1333 'namespace policy {\n\n') | 1343 'namespace policy {\n\n') |
| 1334 | 1344 |
| 1335 # Policy keys. | 1345 # Policy keys. |
| 1336 f.write('namespace key {\n\n') | 1346 f.write('namespace key {\n\n') |
| 1337 for policy in policies: | 1347 for policy in policies: |
| 1338 f.write('const char k{name}[] = "{name}";\n'.format(name=policy.name)) | 1348 f.write('const char k{name}[] = "{name}";\n'.format(name=policy.name)) |
| 1339 f.write('\n} // namespace key\n\n') | 1349 f.write('\n} // namespace key\n\n') |
| 1340 | 1350 |
| 1351 # Device policy keys. |
| 1352 supported_device_policies = _GetSupportedDevicePolicies(policies) |
| 1353 f.write('const char* kDevicePolicyKeys[] = {\n\n'); |
| 1354 for policy in supported_device_policies: |
| 1355 f.write(' key::k%s,\n' % policy.name) |
| 1356 f.write(' nullptr};\n\n'); |
| 1357 |
| 1341 # User policy proto pointers, one struct for each protobuf type. | 1358 # User policy proto pointers, one struct for each protobuf type. |
| 1342 supported_user_policies = _GetSupportedUserPolicies(policies) | 1359 supported_user_policies = _GetSupportedUserPolicies(policies) |
| 1343 protobuf_types = _GetProtobufTypes(supported_user_policies) | 1360 protobuf_types = _GetProtobufTypes(supported_user_policies) |
| 1344 for protobuf_type in protobuf_types: | 1361 for protobuf_type in protobuf_types: |
| 1345 _WriteChromeOSPolicyAccessSource(supported_user_policies, f, protobuf_type) | 1362 _WriteChromeOSPolicyAccessSource(supported_user_policies, f, protobuf_type) |
| 1346 | 1363 |
| 1347 f.write('} // namespace policy\n') | 1364 f.write('} // namespace policy\n') |
| 1348 | 1365 |
| 1349 | 1366 |
| 1350 #------------------ app restrictions -------------------------------# | 1367 #------------------ app restrictions -------------------------------# |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1375 f.write('<restrictions xmlns:android="' | 1392 f.write('<restrictions xmlns:android="' |
| 1376 'http://schemas.android.com/apk/res/android">\n\n') | 1393 'http://schemas.android.com/apk/res/android">\n\n') |
| 1377 for policy in policies: | 1394 for policy in policies: |
| 1378 if (policy.is_supported and policy.restriction_type != 'invalid' and | 1395 if (policy.is_supported and policy.restriction_type != 'invalid' and |
| 1379 not policy.is_deprecated and not policy.is_future): | 1396 not policy.is_deprecated and not policy.is_future): |
| 1380 WriteAppRestriction(policy) | 1397 WriteAppRestriction(policy) |
| 1381 f.write('</restrictions>') | 1398 f.write('</restrictions>') |
| 1382 | 1399 |
| 1383 if __name__ == '__main__': | 1400 if __name__ == '__main__': |
| 1384 sys.exit(main()) | 1401 sys.exit(main()) |
| OLD | NEW |