| 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 from grit.format.policy_templates.writers import plist_helper | 7 from grit.format.policy_templates.writers import plist_helper |
| 8 from grit.format.policy_templates.writers import template_writer | 8 from grit.format.policy_templates.writers import template_writer |
| 9 | 9 |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 '''Add strings to the stringtable corresponding a given policy. | 45 '''Add strings to the stringtable corresponding a given policy. |
| 46 | 46 |
| 47 Args: | 47 Args: |
| 48 policy: The policy for which the strings will be added to the | 48 policy: The policy for which the strings will be added to the |
| 49 string table. | 49 string table. |
| 50 ''' | 50 ''' |
| 51 desc = policy['desc'] | 51 desc = policy['desc'] |
| 52 if policy['type'] == 'external': | 52 if policy['type'] == 'external': |
| 53 # This type can only be set through cloud policy. | 53 # This type can only be set through cloud policy. |
| 54 return | 54 return |
| 55 elif policy['type'] in ('int-enum','string-enum'): | 55 elif policy['type'] in ('int-enum','string-enum', 'string-enum-list'): |
| 56 # Append the captions of enum items to the description string. | 56 # Append the captions of enum items to the description string. |
| 57 item_descs = [] | 57 item_descs = [] |
| 58 for item in policy['items']: | 58 for item in policy['items']: |
| 59 item_descs.append(str(item['value']) + ' - ' + item['caption']) | 59 item_descs.append(str(item['value']) + ' - ' + item['caption']) |
| 60 desc = '\n'.join(item_descs) + '\n' + desc | 60 desc = '\n'.join(item_descs) + '\n' + desc |
| 61 | 61 |
| 62 self._AddToStringTable(policy['name'], policy['label'], desc) | 62 self._AddToStringTable(policy['name'], policy['label'], desc) |
| 63 | 63 |
| 64 def BeginTemplate(self): | 64 def BeginTemplate(self): |
| 65 app_name = plist_helper.GetPlistFriendlyName(self.config['app_name']) | 65 app_name = plist_helper.GetPlistFriendlyName(self.config['app_name']) |
| 66 self._AddToStringTable( | 66 self._AddToStringTable( |
| 67 app_name, | 67 app_name, |
| 68 self.config['app_name'], | 68 self.config['app_name'], |
| 69 self.messages['mac_chrome_preferences']['text']) | 69 self.messages['mac_chrome_preferences']['text']) |
| 70 | 70 |
| 71 def Init(self): | 71 def Init(self): |
| 72 # A buffer for the lines of the string table being generated. | 72 # A buffer for the lines of the string table being generated. |
| 73 self._out = [] | 73 self._out = [] |
| 74 | 74 |
| 75 def GetTemplateText(self): | 75 def GetTemplateText(self): |
| 76 return '\n'.join(self._out) | 76 return '\n'.join(self._out) |
| OLD | NEW |