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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 # Maps policy types to a tuple with 4 other types: | 32 # Maps policy types to a tuple with 4 other types: |
33 # - the equivalent base::Value::Type or 'TYPE_EXTERNAL' if the policy | 33 # - the equivalent base::Value::Type or 'TYPE_EXTERNAL' if the policy |
34 # references external data | 34 # references external data |
35 # - the equivalent Protobuf field type | 35 # - the equivalent Protobuf field type |
36 # - the name of one of the protobufs for shared policy types | 36 # - the name of one of the protobufs for shared policy types |
37 # - the equivalent type in Android's App Restriction Schema | 37 # - the equivalent type in Android's App Restriction Schema |
38 # TODO(joaodasilva): refactor the 'dict' type into a more generic 'json' type | 38 # TODO(joaodasilva): refactor the 'dict' type into a more generic 'json' type |
39 # that can also be used to represent lists of other JSON objects. | 39 # that can also be used to represent lists of other JSON objects. |
40 TYPE_MAP = { | 40 TYPE_MAP = { |
41 'dict': ('TYPE_DICTIONARY', 'string', 'String', | 41 'dict': ('Type::DICTIONARY', 'string', 'String', |
42 'string'), | 42 'string'), |
43 'external': ('TYPE_EXTERNAL', 'string', 'String', | 43 'external': ('TYPE_EXTERNAL', 'string', 'String', |
44 'invalid'), | 44 'invalid'), |
45 'int': ('TYPE_INTEGER', 'int64', 'Integer', | 45 'int': ('Type::INTEGER', 'int64', 'Integer', |
46 'integer'), | 46 'integer'), |
47 'int-enum': ('TYPE_INTEGER', 'int64', 'Integer', | 47 'int-enum': ('Type::INTEGER', 'int64', 'Integer', |
48 'choice'), | 48 'choice'), |
49 'list': ('TYPE_LIST', 'StringList', 'StringList', | 49 'list': ('Type::LIST', 'StringList', 'StringList', |
50 'string'), | 50 'string'), |
51 'main': ('TYPE_BOOLEAN', 'bool', 'Boolean', | 51 'main': ('Type::BOOLEAN', 'bool', 'Boolean', |
52 'bool'), | 52 'bool'), |
53 'string': ('TYPE_STRING', 'string', 'String', | 53 'string': ('Type::STRING', 'string', 'String', |
54 'string'), | 54 'string'), |
55 'string-enum': ('TYPE_STRING', 'string', 'String', | 55 'string-enum': ('Type::STRING', 'string', 'String', |
56 'choice'), | 56 'choice'), |
57 'string-enum-list': ('TYPE_LIST', 'StringList', 'StringList', | 57 'string-enum-list': ('Type::LIST', 'StringList', 'StringList', |
58 'multi-select'), | 58 'multi-select'), |
59 } | 59 } |
60 | 60 |
61 class EnumItem: | 61 class EnumItem: |
62 def __init__(self, item): | 62 def __init__(self, item): |
63 self.caption = PolicyDetails._RemovePlaceholders(item['caption']) | 63 self.caption = PolicyDetails._RemovePlaceholders(item['caption']) |
64 self.value = item['value'] | 64 self.value = item['value'] |
65 | 65 |
66 def __init__(self, policy, chrome_major_version, os, is_chromium_os, | 66 def __init__(self, policy, chrome_major_version, os, is_chromium_os, |
67 valid_tags): | 67 valid_tags): |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 f.write('extern const char k' + policy.name + '[];\n') | 341 f.write('extern const char k' + policy.name + '[];\n') |
342 f.write('\n} // namespace key\n\n' | 342 f.write('\n} // namespace key\n\n' |
343 '} // namespace policy\n\n' | 343 '} // namespace policy\n\n' |
344 '#endif // CHROME_COMMON_POLICY_CONSTANTS_H_\n') | 344 '#endif // CHROME_COMMON_POLICY_CONSTANTS_H_\n') |
345 | 345 |
346 | 346 |
347 #------------------ policy constants source ------------------------# | 347 #------------------ policy constants source ------------------------# |
348 | 348 |
349 # A mapping of the simple schema types to base::Value::Types. | 349 # A mapping of the simple schema types to base::Value::Types. |
350 SIMPLE_SCHEMA_NAME_MAP = { | 350 SIMPLE_SCHEMA_NAME_MAP = { |
351 'boolean': 'TYPE_BOOLEAN', | 351 'boolean': 'Type::BOOLEAN', |
352 'integer': 'TYPE_INTEGER', | 352 'integer': 'Type::INTEGER', |
353 'null' : 'TYPE_NULL', | 353 'null' : 'Type::NONE', |
354 'number' : 'TYPE_DOUBLE', | 354 'number' : 'Type::DOUBLE', |
355 'string' : 'TYPE_STRING', | 355 'string' : 'Type::STRING', |
356 } | 356 } |
357 | 357 |
358 class SchemaNodesGenerator: | 358 class SchemaNodesGenerator: |
359 """Builds the internal structs to represent a JSON schema.""" | 359 """Builds the internal structs to represent a JSON schema.""" |
360 | 360 |
361 def __init__(self, shared_strings): | 361 def __init__(self, shared_strings): |
362 """Creates a new generator. | 362 """Creates a new generator. |
363 | 363 |
364 |shared_strings| is a map of strings to a C expression that evaluates to | 364 |shared_strings| is a map of strings to a C expression that evaluates to |
365 that string at runtime. This mapping can be used to reuse existing string | 365 that string at runtime. This mapping can be used to reuse existing string |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 if self.simple_types[name] == None: | 405 if self.simple_types[name] == None: |
406 self.simple_types[name] = self.AppendSchema( | 406 self.simple_types[name] = self.AppendSchema( |
407 SIMPLE_SCHEMA_NAME_MAP[name], | 407 SIMPLE_SCHEMA_NAME_MAP[name], |
408 -1, | 408 -1, |
409 'simple type: ' + name) | 409 'simple type: ' + name) |
410 return self.simple_types[name] | 410 return self.simple_types[name] |
411 | 411 |
412 def GetStringList(self): | 412 def GetStringList(self): |
413 if self.stringlist_type == None: | 413 if self.stringlist_type == None: |
414 self.stringlist_type = self.AppendSchema( | 414 self.stringlist_type = self.AppendSchema( |
415 'TYPE_LIST', | 415 'Type::LIST', |
416 self.GetSimpleType('string'), | 416 self.GetSimpleType('string'), |
417 'simple type: stringlist') | 417 'simple type: stringlist') |
418 return self.stringlist_type | 418 return self.stringlist_type |
419 | 419 |
420 def SchemaHaveRestriction(self, schema): | 420 def SchemaHaveRestriction(self, schema): |
421 return any(keyword in schema for keyword in | 421 return any(keyword in schema for keyword in |
422 ['minimum', 'maximum', 'enum', 'pattern']) | 422 ['minimum', 'maximum', 'enum', 'pattern']) |
423 | 423 |
424 def IsConsecutiveInterval(self, seq): | 424 def IsConsecutiveInterval(self, seq): |
425 sortedSeq = sorted(seq) | 425 sortedSeq = sorted(seq) |
426 return all(sortedSeq[i] + 1 == sortedSeq[i + 1] | 426 return all(sortedSeq[i] + 1 == sortedSeq[i + 1] |
427 for i in xrange(len(sortedSeq) - 1)) | 427 for i in xrange(len(sortedSeq) - 1)) |
428 | 428 |
429 def GetEnumIntegerType(self, schema, name): | 429 def GetEnumIntegerType(self, schema, name): |
430 assert all(type(x) == int for x in schema['enum']) | 430 assert all(type(x) == int for x in schema['enum']) |
431 possible_values = schema['enum'] | 431 possible_values = schema['enum'] |
432 if self.IsConsecutiveInterval(possible_values): | 432 if self.IsConsecutiveInterval(possible_values): |
433 index = self.AppendRestriction(max(possible_values), min(possible_values)) | 433 index = self.AppendRestriction(max(possible_values), min(possible_values)) |
434 return self.AppendSchema('TYPE_INTEGER', index, | 434 return self.AppendSchema('Type::INTEGER', index, |
435 'integer with enumeration restriction (use range instead): %s' % name) | 435 'integer with enumeration restriction (use range instead): %s' % name) |
436 offset_begin = len(self.int_enums) | 436 offset_begin = len(self.int_enums) |
437 self.int_enums += possible_values | 437 self.int_enums += possible_values |
438 offset_end = len(self.int_enums) | 438 offset_end = len(self.int_enums) |
439 return self.AppendSchema('TYPE_INTEGER', | 439 return self.AppendSchema('Type::INTEGER', |
440 self.AppendRestriction(offset_begin, offset_end), | 440 self.AppendRestriction(offset_begin, offset_end), |
441 'integer with enumeration restriction: %s' % name) | 441 'integer with enumeration restriction: %s' % name) |
442 | 442 |
443 def GetEnumStringType(self, schema, name): | 443 def GetEnumStringType(self, schema, name): |
444 assert all(type(x) == str for x in schema['enum']) | 444 assert all(type(x) == str for x in schema['enum']) |
445 offset_begin = len(self.string_enums) | 445 offset_begin = len(self.string_enums) |
446 self.string_enums += schema['enum'] | 446 self.string_enums += schema['enum'] |
447 offset_end = len(self.string_enums) | 447 offset_end = len(self.string_enums) |
448 return self.AppendSchema('TYPE_STRING', | 448 return self.AppendSchema('Type::STRING', |
449 self.AppendRestriction(offset_begin, offset_end), | 449 self.AppendRestriction(offset_begin, offset_end), |
450 'string with enumeration restriction: %s' % name) | 450 'string with enumeration restriction: %s' % name) |
451 | 451 |
452 def GetEnumType(self, schema, name): | 452 def GetEnumType(self, schema, name): |
453 if len(schema['enum']) == 0: | 453 if len(schema['enum']) == 0: |
454 raise RuntimeError('Empty enumeration in %s' % name) | 454 raise RuntimeError('Empty enumeration in %s' % name) |
455 elif schema['type'] == 'integer': | 455 elif schema['type'] == 'integer': |
456 return self.GetEnumIntegerType(schema, name) | 456 return self.GetEnumIntegerType(schema, name) |
457 elif schema['type'] == 'string': | 457 elif schema['type'] == 'string': |
458 return self.GetEnumStringType(schema, name) | 458 return self.GetEnumStringType(schema, name) |
459 else: | 459 else: |
460 raise RuntimeError('Unknown enumeration type in %s' % name) | 460 raise RuntimeError('Unknown enumeration type in %s' % name) |
461 | 461 |
462 def GetPatternType(self, schema, name): | 462 def GetPatternType(self, schema, name): |
463 if schema['type'] != 'string': | 463 if schema['type'] != 'string': |
464 raise RuntimeError('Unknown pattern type in %s' % name) | 464 raise RuntimeError('Unknown pattern type in %s' % name) |
465 pattern = schema['pattern'] | 465 pattern = schema['pattern'] |
466 # Try to compile the pattern to validate it, note that the syntax used | 466 # Try to compile the pattern to validate it, note that the syntax used |
467 # here might be slightly different from re2. | 467 # here might be slightly different from re2. |
468 # TODO(binjin): Add a python wrapper of re2 and use it here. | 468 # TODO(binjin): Add a python wrapper of re2 and use it here. |
469 re.compile(pattern) | 469 re.compile(pattern) |
470 index = len(self.string_enums); | 470 index = len(self.string_enums); |
471 self.string_enums.append(pattern); | 471 self.string_enums.append(pattern); |
472 return self.AppendSchema('TYPE_STRING', | 472 return self.AppendSchema('Type::STRING', |
473 self.AppendRestriction(index, index), | 473 self.AppendRestriction(index, index), |
474 'string with pattern restriction: %s' % name); | 474 'string with pattern restriction: %s' % name); |
475 | 475 |
476 def GetRangedType(self, schema, name): | 476 def GetRangedType(self, schema, name): |
477 if schema['type'] != 'integer': | 477 if schema['type'] != 'integer': |
478 raise RuntimeError('Unknown ranged type in %s' % name) | 478 raise RuntimeError('Unknown ranged type in %s' % name) |
479 min_value_set, max_value_set = False, False | 479 min_value_set, max_value_set = False, False |
480 if 'minimum' in schema: | 480 if 'minimum' in schema: |
481 min_value = int(schema['minimum']) | 481 min_value = int(schema['minimum']) |
482 min_value_set = True | 482 min_value_set = True |
483 if 'maximum' in schema: | 483 if 'maximum' in schema: |
484 max_value = int(schema['minimum']) | 484 max_value = int(schema['minimum']) |
485 max_value_set = True | 485 max_value_set = True |
486 if min_value_set and max_value_set and min_value > max_value: | 486 if min_value_set and max_value_set and min_value > max_value: |
487 raise RuntimeError('Invalid ranged type in %s' % name) | 487 raise RuntimeError('Invalid ranged type in %s' % name) |
488 index = self.AppendRestriction( | 488 index = self.AppendRestriction( |
489 str(max_value) if max_value_set else 'INT_MAX', | 489 str(max_value) if max_value_set else 'INT_MAX', |
490 str(min_value) if min_value_set else 'INT_MIN') | 490 str(min_value) if min_value_set else 'INT_MIN') |
491 return self.AppendSchema('TYPE_INTEGER', | 491 return self.AppendSchema('Type::INTEGER', |
492 index, | 492 index, |
493 'integer with ranged restriction: %s' % name) | 493 'integer with ranged restriction: %s' % name) |
494 | 494 |
495 def Generate(self, schema, name): | 495 def Generate(self, schema, name): |
496 """Generates the structs for the given schema. | 496 """Generates the structs for the given schema. |
497 | 497 |
498 |schema|: a valid JSON schema in a dictionary. | 498 |schema|: a valid JSON schema in a dictionary. |
499 |name|: the name of the current node, for the generated comments.""" | 499 |name|: the name of the current node, for the generated comments.""" |
500 if schema.has_key('$ref'): | 500 if schema.has_key('$ref'): |
501 if schema.has_key('id'): | 501 if schema.has_key('id'): |
(...skipping 10 matching lines...) Expand all Loading... |
512 elif 'pattern' in schema: | 512 elif 'pattern' in schema: |
513 return self.GetPatternType(schema, name) | 513 return self.GetPatternType(schema, name) |
514 else: | 514 else: |
515 return self.GetRangedType(schema, name) | 515 return self.GetRangedType(schema, name) |
516 | 516 |
517 if schema['type'] == 'array': | 517 if schema['type'] == 'array': |
518 # Special case for lists of strings, which is a common policy type. | 518 # Special case for lists of strings, which is a common policy type. |
519 # The 'type' may be missing if the schema has a '$ref' attribute. | 519 # The 'type' may be missing if the schema has a '$ref' attribute. |
520 if schema['items'].get('type', '') == 'string': | 520 if schema['items'].get('type', '') == 'string': |
521 return self.GetStringList() | 521 return self.GetStringList() |
522 return self.AppendSchema('TYPE_LIST', | 522 return self.AppendSchema('Type::LIST', |
523 self.GenerateAndCollectID(schema['items'], 'items of ' + name)) | 523 self.GenerateAndCollectID(schema['items'], 'items of ' + name)) |
524 elif schema['type'] == 'object': | 524 elif schema['type'] == 'object': |
525 # Reserve an index first, so that dictionaries come before their | 525 # Reserve an index first, so that dictionaries come before their |
526 # properties. This makes sure that the root node is the first in the | 526 # properties. This makes sure that the root node is the first in the |
527 # SchemaNodes array. | 527 # SchemaNodes array. |
528 index = self.AppendSchema('TYPE_DICTIONARY', -1) | 528 index = self.AppendSchema('Type::DICTIONARY', -1) |
529 | 529 |
530 if 'additionalProperties' in schema: | 530 if 'additionalProperties' in schema: |
531 additionalProperties = self.GenerateAndCollectID( | 531 additionalProperties = self.GenerateAndCollectID( |
532 schema['additionalProperties'], | 532 schema['additionalProperties'], |
533 'additionalProperties of ' + name) | 533 'additionalProperties of ' + name) |
534 else: | 534 else: |
535 additionalProperties = -1 | 535 additionalProperties = -1 |
536 | 536 |
537 # Properties must be sorted by name, for the binary search lookup. | 537 # Properties must be sorted by name, for the binary search lookup. |
538 # Note that |properties| must be evaluated immediately, so that all the | 538 # Note that |properties| must be evaluated immediately, so that all the |
(...skipping 17 matching lines...) Expand all Loading... |
556 | 556 |
557 if index == 0: | 557 if index == 0: |
558 self.root_properties_begin = begin | 558 self.root_properties_begin = begin |
559 self.root_properties_end = end | 559 self.root_properties_end = end |
560 | 560 |
561 extra = len(self.properties_nodes) | 561 extra = len(self.properties_nodes) |
562 self.properties_nodes.append((begin, end, pattern_end, | 562 self.properties_nodes.append((begin, end, pattern_end, |
563 additionalProperties, name)) | 563 additionalProperties, name)) |
564 | 564 |
565 # Set the right data at |index| now. | 565 # Set the right data at |index| now. |
566 self.schema_nodes[index] = ('TYPE_DICTIONARY', extra, name) | 566 self.schema_nodes[index] = ('Type::DICTIONARY', extra, name) |
567 return index | 567 return index |
568 else: | 568 else: |
569 assert False | 569 assert False |
570 | 570 |
571 def GenerateAndCollectID(self, schema, name): | 571 def GenerateAndCollectID(self, schema, name): |
572 """A wrapper of Generate(), will take the return value, check and add 'id' | 572 """A wrapper of Generate(), will take the return value, check and add 'id' |
573 attribute to self.id_map. The wrapper needs to be used for every call to | 573 attribute to self.id_map. The wrapper needs to be used for every call to |
574 Generate(). | 574 Generate(). |
575 """ | 575 """ |
576 index = self.Generate(schema, name) | 576 index = self.Generate(schema, name) |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 730 |
731 f.write('const internal::SchemaData* GetChromeSchemaData() {\n' | 731 f.write('const internal::SchemaData* GetChromeSchemaData() {\n' |
732 ' return &kChromeSchemaData;\n' | 732 ' return &kChromeSchemaData;\n' |
733 '}\n\n') | 733 '}\n\n') |
734 | 734 |
735 f.write('#if defined (OS_CHROMEOS)\n' | 735 f.write('#if defined (OS_CHROMEOS)\n' |
736 'void SetEnterpriseUsersDefaults(PolicyMap* policy_map) {\n') | 736 'void SetEnterpriseUsersDefaults(PolicyMap* policy_map) {\n') |
737 | 737 |
738 for policy in policies: | 738 for policy in policies: |
739 if policy.has_enterprise_default: | 739 if policy.has_enterprise_default: |
740 if policy.policy_type == 'TYPE_BOOLEAN': | 740 if policy.policy_type == 'Type::BOOLEAN': |
741 creation_expression = 'new base::FundamentalValue(%s)' %\ | 741 creation_expression = 'new base::FundamentalValue(%s)' %\ |
742 ('true' if policy.enterprise_default else 'false') | 742 ('true' if policy.enterprise_default else 'false') |
743 elif policy.policy_type == 'TYPE_INTEGER': | 743 elif policy.policy_type == 'Type::INTEGER': |
744 creation_expression = 'new base::FundamentalValue(%s)' %\ | 744 creation_expression = 'new base::FundamentalValue(%s)' %\ |
745 policy.enterprise_default | 745 policy.enterprise_default |
746 elif policy.policy_type == 'TYPE_STRING': | 746 elif policy.policy_type == 'Type::STRING': |
747 creation_expression = 'new base::StringValue("%s")' %\ | 747 creation_expression = 'new base::StringValue("%s")' %\ |
748 policy.enterprise_default | 748 policy.enterprise_default |
749 else: | 749 else: |
750 raise RuntimeError('Type %s of policy %s is not supported at ' | 750 raise RuntimeError('Type %s of policy %s is not supported at ' |
751 'enterprise defaults' % (policy.policy_type, | 751 'enterprise defaults' % (policy.policy_type, |
752 policy.name)) | 752 policy.name)) |
753 f.write(' if (!policy_map->Get(key::k%s)) {\n' | 753 f.write(' if (!policy_map->Get(key::k%s)) {\n' |
754 ' policy_map->Set(key::k%s,\n' | 754 ' policy_map->Set(key::k%s,\n' |
755 ' POLICY_LEVEL_MANDATORY,\n' | 755 ' POLICY_LEVEL_MANDATORY,\n' |
756 ' POLICY_SCOPE_USER,\n' | 756 ' POLICY_SCOPE_USER,\n' |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 # Field IDs [1..RESERVED_IDS] will not be used in the wrapping protobuf. | 948 # Field IDs [1..RESERVED_IDS] will not be used in the wrapping protobuf. |
949 RESERVED_IDS = 2 | 949 RESERVED_IDS = 2 |
950 | 950 |
951 | 951 |
952 def _WritePolicyProto(f, policy, fields): | 952 def _WritePolicyProto(f, policy, fields): |
953 _OutputComment(f, policy.caption + '\n\n' + policy.desc) | 953 _OutputComment(f, policy.caption + '\n\n' + policy.desc) |
954 if policy.items is not None: | 954 if policy.items is not None: |
955 _OutputComment(f, '\nValid values:') | 955 _OutputComment(f, '\nValid values:') |
956 for item in policy.items: | 956 for item in policy.items: |
957 _OutputComment(f, ' %s: %s' % (str(item.value), item.caption)) | 957 _OutputComment(f, ' %s: %s' % (str(item.value), item.caption)) |
958 if policy.policy_type == 'TYPE_DICTIONARY': | 958 if policy.policy_type == 'Type::DICTIONARY': |
959 _OutputComment(f, '\nValue schema:\n%s' % | 959 _OutputComment(f, '\nValue schema:\n%s' % |
960 json.dumps(policy.schema, sort_keys=True, indent=4, | 960 json.dumps(policy.schema, sort_keys=True, indent=4, |
961 separators=(',', ': '))) | 961 separators=(',', ': '))) |
962 _OutputComment(f, '\nSupported on: %s' % ', '.join(policy.platforms)) | 962 _OutputComment(f, '\nSupported on: %s' % ', '.join(policy.platforms)) |
963 if policy.can_be_recommended and not policy.can_be_mandatory: | 963 if policy.can_be_recommended and not policy.can_be_mandatory: |
964 _OutputComment(f, '\nNote: this policy must have a RECOMMENDED ' +\ | 964 _OutputComment(f, '\nNote: this policy must have a RECOMMENDED ' +\ |
965 'PolicyMode set in PolicyOptions.') | 965 'PolicyMode set in PolicyOptions.') |
966 f.write('message %sProto {\n' % policy.name) | 966 f.write('message %sProto {\n' % policy.name) |
967 f.write(' optional PolicyOptions policy_options = 1;\n') | 967 f.write(' optional PolicyOptions policy_options = 1;\n') |
968 f.write(' optional %s %s = 2;\n' % (policy.protobuf_type, policy.name)) | 968 f.write(' optional %s %s = 2;\n' % (policy.protobuf_type, policy.name)) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 ''' | 1066 ''' |
1067 | 1067 |
1068 | 1068 |
1069 CPP_FOOT = '''} | 1069 CPP_FOOT = '''} |
1070 | 1070 |
1071 } // namespace policy | 1071 } // namespace policy |
1072 ''' | 1072 ''' |
1073 | 1073 |
1074 | 1074 |
1075 def _CreateValue(type, arg): | 1075 def _CreateValue(type, arg): |
1076 if type == 'TYPE_BOOLEAN': | 1076 if type == 'Type::BOOLEAN': |
1077 return 'new base::FundamentalValue(%s)' % arg | 1077 return 'new base::FundamentalValue(%s)' % arg |
1078 elif type == 'TYPE_INTEGER': | 1078 elif type == 'Type::INTEGER': |
1079 return 'DecodeIntegerValue(%s)' % arg | 1079 return 'DecodeIntegerValue(%s)' % arg |
1080 elif type == 'TYPE_STRING': | 1080 elif type == 'Type::STRING': |
1081 return 'new base::StringValue(%s)' % arg | 1081 return 'new base::StringValue(%s)' % arg |
1082 elif type == 'TYPE_LIST': | 1082 elif type == 'Type::LIST': |
1083 return 'DecodeStringList(%s)' % arg | 1083 return 'DecodeStringList(%s)' % arg |
1084 elif type == 'TYPE_DICTIONARY' or type == 'TYPE_EXTERNAL': | 1084 elif type == 'Type::DICTIONARY' or type == 'TYPE_EXTERNAL': |
1085 return 'DecodeJson(%s)' % arg | 1085 return 'DecodeJson(%s)' % arg |
1086 else: | 1086 else: |
1087 raise NotImplementedError('Unknown type %s' % type) | 1087 raise NotImplementedError('Unknown type %s' % type) |
1088 | 1088 |
1089 | 1089 |
1090 def _CreateExternalDataFetcher(type, name): | 1090 def _CreateExternalDataFetcher(type, name): |
1091 if type == 'TYPE_EXTERNAL': | 1091 if type == 'TYPE_EXTERNAL': |
1092 return 'new ExternalDataFetcher(external_data_manager, key::k%s)' % name | 1092 return 'new ExternalDataFetcher(external_data_manager, key::k%s)' % name |
1093 return 'nullptr' | 1093 return 'nullptr' |
1094 | 1094 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 f.write('<restrictions xmlns:android="' | 1172 f.write('<restrictions xmlns:android="' |
1173 'http://schemas.android.com/apk/res/android">\n\n') | 1173 'http://schemas.android.com/apk/res/android">\n\n') |
1174 for policy in policies: | 1174 for policy in policies: |
1175 if (policy.is_supported and policy.restriction_type != 'invalid' and | 1175 if (policy.is_supported and policy.restriction_type != 'invalid' and |
1176 not policy.is_deprecated and not policy.is_future): | 1176 not policy.is_deprecated and not policy.is_future): |
1177 WriteAppRestriction(policy) | 1177 WriteAppRestriction(policy) |
1178 f.write('</restrictions>') | 1178 f.write('</restrictions>') |
1179 | 1179 |
1180 if __name__ == '__main__': | 1180 if __name__ == '__main__': |
1181 sys.exit(main()) | 1181 sys.exit(main()) |
OLD | NEW |