| 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 | 6 |
| 7 import json | 7 import json |
| 8 | 8 |
| 9 from writers import template_writer | 9 from writers import template_writer |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 list.sort() methods to sort policies. | 47 list.sort() methods to sort policies. |
| 48 See TemplateWriter.SortPoliciesGroupsFirst for usage. | 48 See TemplateWriter.SortPoliciesGroupsFirst for usage. |
| 49 ''' | 49 ''' |
| 50 is_list = policy['type'] in ('list', 'string-enum-list') | 50 is_list = policy['type'] in ('list', 'string-enum-list') |
| 51 # Lists come after regular policies. | 51 # Lists come after regular policies. |
| 52 return (is_list, policy['name']) | 52 return (is_list, policy['name']) |
| 53 | 53 |
| 54 def _WritePolicy(self, policy, key, list): | 54 def _WritePolicy(self, policy, key, list): |
| 55 example_value = policy['example_value'] | 55 example_value = policy['example_value'] |
| 56 | 56 |
| 57 if policy['type'] == 'external': | 57 if policy['type'] in ('list', 'string-enum-list'): |
| 58 # This type can only be set through cloud policy. | |
| 59 return | |
| 60 elif policy['type'] in ('list', 'string-enum-list'): | |
| 61 self._StartBlock(key, policy['name'], list) | 58 self._StartBlock(key, policy['name'], list) |
| 62 i = 1 | 59 i = 1 |
| 63 for item in example_value: | 60 for item in example_value: |
| 64 escaped_str = self._EscapeRegString(item) | 61 escaped_str = self._EscapeRegString(item) |
| 65 list.append('"%d"="%s"' % (i, escaped_str)) | 62 list.append('"%d"="%s"' % (i, escaped_str)) |
| 66 i = i + 1 | 63 i = i + 1 |
| 67 else: | 64 else: |
| 68 self._StartBlock(key, None, list) | 65 self._StartBlock(key, None, list) |
| 69 if policy['type'] in ('string', 'string-enum', 'dict'): | 66 if policy['type'] in ('string', 'string-enum', 'dict', 'external'): |
| 70 example_value_str = json.dumps(example_value, sort_keys=True) | 67 example_value_str = json.dumps(example_value, sort_keys=True) |
| 71 if policy['type'] == 'dict': | 68 if policy['type'] in ('dict', 'external'): |
| 72 example_value_str = '"%s"' % example_value_str | 69 example_value_str = '"%s"' % example_value_str |
| 73 elif policy['type'] == 'main': | 70 elif policy['type'] == 'main': |
| 74 if example_value == True: | 71 if example_value == True: |
| 75 example_value_str = 'dword:00000001' | 72 example_value_str = 'dword:00000001' |
| 76 else: | 73 else: |
| 77 example_value_str = 'dword:00000000' | 74 example_value_str = 'dword:00000000' |
| 78 elif policy['type'] in ('int', 'int-enum'): | 75 elif policy['type'] in ('int', 'int-enum'): |
| 79 example_value_str = 'dword:%08x' % example_value | 76 example_value_str = 'dword:%08x' % example_value |
| 80 else: | 77 else: |
| 81 raise Exception('unknown policy type %s:' % policy['type']) | 78 raise Exception('unknown policy type %s:' % policy['type']) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 109 self._prefix = [] | 106 self._prefix = [] |
| 110 self._winconfig = self.config['win_config']['win'] | 107 self._winconfig = self.config['win_config']['win'] |
| 111 | 108 |
| 112 def GetTemplateText(self): | 109 def GetTemplateText(self): |
| 113 self._prefix.append('Windows Registry Editor Version 5.00') | 110 self._prefix.append('Windows Registry Editor Version 5.00') |
| 114 if self._GetChromiumVersionString() is not None: | 111 if self._GetChromiumVersionString() is not None: |
| 115 self.WriteComment(self.config['build'] + ' version: ' + \ | 112 self.WriteComment(self.config['build'] + ' version: ' + \ |
| 116 self._GetChromiumVersionString()) | 113 self._GetChromiumVersionString()) |
| 117 all = self._prefix + self._mandatory + self._recommended | 114 all = self._prefix + self._mandatory + self._recommended |
| 118 return self.NEWLINE.join(all) | 115 return self.NEWLINE.join(all) |
| OLD | NEW |