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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 680 |
681 If no definition is needed, the first return value will be an empty list. If | 681 If no definition is needed, the first return value will be an empty list. If |
682 any error occurs, the second return value will be None (ie, no way to fetch | 682 any error occurs, the second return value will be None (ie, no way to fetch |
683 the value). | 683 the value). |
684 | 684 |
685 |value|: The deserialized value to convert to base::Value.""" | 685 |value|: The deserialized value to convert to base::Value.""" |
686 if type(value) == bool or type(value) == int: | 686 if type(value) == bool or type(value) == int: |
687 return [], 'base::MakeUnique<base::Value>(%s)' %\ | 687 return [], 'base::MakeUnique<base::Value>(%s)' %\ |
688 json.dumps(value) | 688 json.dumps(value) |
689 elif type(value) == str: | 689 elif type(value) == str: |
690 return [], 'base::MakeUnique<base::StringValue>("%s")' % value | 690 return [], 'base::MakeUnique<base::Value>("%s")' % value |
691 elif type(value) == list: | 691 elif type(value) == list: |
692 setup = ['auto default_value = base::MakeUnique<base::ListValue>();'] | 692 setup = ['auto default_value = base::MakeUnique<base::ListValue>();'] |
693 for entry in value: | 693 for entry in value: |
694 decl, fetch = _GenerateDefaultValue(entry) | 694 decl, fetch = _GenerateDefaultValue(entry) |
695 # Nested lists are not supported. | 695 # Nested lists are not supported. |
696 if decl: | 696 if decl: |
697 return [], None | 697 return [], None |
698 setup.append('default_value->Append(%s);' % fetch) | 698 setup.append('default_value->Append(%s);' % fetch) |
699 return setup, 'std::move(default_value)' | 699 return setup, 'std::move(default_value)' |
700 return [], None | 700 return [], None |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 } // namespace policy | 1167 } // namespace policy |
1168 ''' | 1168 ''' |
1169 | 1169 |
1170 | 1170 |
1171 def _CreateValue(type, arg): | 1171 def _CreateValue(type, arg): |
1172 if type == 'Type::BOOLEAN': | 1172 if type == 'Type::BOOLEAN': |
1173 return 'new base::Value(%s)' % arg | 1173 return 'new base::Value(%s)' % arg |
1174 elif type == 'Type::INTEGER': | 1174 elif type == 'Type::INTEGER': |
1175 return 'DecodeIntegerValue(%s)' % arg | 1175 return 'DecodeIntegerValue(%s)' % arg |
1176 elif type == 'Type::STRING': | 1176 elif type == 'Type::STRING': |
1177 return 'new base::StringValue(%s)' % arg | 1177 return 'new base::Value(%s)' % arg |
1178 elif type == 'Type::LIST': | 1178 elif type == 'Type::LIST': |
1179 return 'DecodeStringList(%s)' % arg | 1179 return 'DecodeStringList(%s)' % arg |
1180 elif type == 'Type::DICTIONARY' or type == 'TYPE_EXTERNAL': | 1180 elif type == 'Type::DICTIONARY' or type == 'TYPE_EXTERNAL': |
1181 return 'DecodeJson(%s)' % arg | 1181 return 'DecodeJson(%s)' % arg |
1182 else: | 1182 else: |
1183 raise NotImplementedError('Unknown type %s' % type) | 1183 raise NotImplementedError('Unknown type %s' % type) |
1184 | 1184 |
1185 | 1185 |
1186 def _CreateExternalDataFetcher(type, name): | 1186 def _CreateExternalDataFetcher(type, name): |
1187 if type == 'TYPE_EXTERNAL': | 1187 if type == 'TYPE_EXTERNAL': |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 f.write('<restrictions xmlns:android="' | 1268 f.write('<restrictions xmlns:android="' |
1269 'http://schemas.android.com/apk/res/android">\n\n') | 1269 'http://schemas.android.com/apk/res/android">\n\n') |
1270 for policy in policies: | 1270 for policy in policies: |
1271 if (policy.is_supported and policy.restriction_type != 'invalid' and | 1271 if (policy.is_supported and policy.restriction_type != 'invalid' and |
1272 not policy.is_deprecated and not policy.is_future): | 1272 not policy.is_deprecated and not policy.is_future): |
1273 WriteAppRestriction(policy) | 1273 WriteAppRestriction(policy) |
1274 f.write('</restrictions>') | 1274 f.write('</restrictions>') |
1275 | 1275 |
1276 if __name__ == '__main__': | 1276 if __name__ == '__main__': |
1277 sys.exit(main()) | 1277 sys.exit(main()) |
OLD | NEW |