Chromium Code Reviews| 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 xml.dom import minidom | 7 from xml.dom import minidom |
| 8 from grit import lazy_re | 8 from grit import lazy_re |
| 9 from grit.format.policy_templates.writers import xml_formatted_writer | 9 from grit.format.policy_templates.writers import xml_formatted_writer |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 Args: | 172 Args: |
| 173 parent: The DOM node for which the example will be added. | 173 parent: The DOM node for which the example will be added. |
| 174 policy: A policy of type 'list', for which the Windows example value | 174 policy: A policy of type 'list', for which the Windows example value |
| 175 is generated. | 175 is generated. |
| 176 ''' | 176 ''' |
| 177 example_value = policy['example_value'] | 177 example_value = policy['example_value'] |
| 178 self.AddElement(parent, 'dt', {}, 'Windows:') | 178 self.AddElement(parent, 'dt', {}, 'Windows:') |
| 179 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) | 179 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) |
| 180 win_text = [] | 180 win_text = [] |
| 181 cnt = 1 | 181 cnt = 1 |
| 182 key_name = self.config['win_reg_mandatory_key_name'] | 182 key_name = self.config['win_reg_mandatory_key_name'] |
|
Joao da Silva
2014/09/08 09:49:55
This needs to be updated too
kaliamoorthi
2014/09/08 13:28:44
Done.
| |
| 183 for item in example_value: | 183 for item in example_value: |
| 184 win_text.append( | 184 win_text.append( |
| 185 '%s\\%s\\%d = "%s"' % | 185 '%s\\%s\\%d = "%s"' % |
| 186 (key_name, policy['name'], cnt, item)) | 186 (key_name, policy['name'], cnt, item)) |
| 187 cnt = cnt + 1 | 187 cnt = cnt + 1 |
| 188 self.AddText(win, '\n'.join(win_text)) | 188 self.AddText(win, '\n'.join(win_text)) |
| 189 | 189 |
| 190 def _AddListExampleLinux(self, parent, policy): | 190 def _AddListExampleLinux(self, parent, policy): |
| 191 '''Adds an example value for Linux of a 'list' policy to a DOM node. | 191 '''Adds an example value for Linux of a 'list' policy to a DOM node. |
| 192 | 192 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 def _AddDictionaryExampleWindows(self, parent, policy): | 279 def _AddDictionaryExampleWindows(self, parent, policy): |
| 280 '''Adds an example value for Windows of a 'dict' policy to a DOM node. | 280 '''Adds an example value for Windows of a 'dict' policy to a DOM node. |
| 281 | 281 |
| 282 Args: | 282 Args: |
| 283 parent: The DOM node for which the example will be added. | 283 parent: The DOM node for which the example will be added. |
| 284 policy: A policy of type 'dict', for which the Windows example value | 284 policy: A policy of type 'dict', for which the Windows example value |
| 285 is generated. | 285 is generated. |
| 286 ''' | 286 ''' |
| 287 self.AddElement(parent, 'dt', {}, 'Windows:') | 287 self.AddElement(parent, 'dt', {}, 'Windows:') |
| 288 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) | 288 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) |
| 289 key_name = self.config['win_reg_mandatory_key_name'] | 289 key_name = self.config['win_reg_mandatory_key_name'] |
|
Joao da Silva
2014/09/08 09:49:54
This too
kaliamoorthi
2014/09/08 13:28:44
Done.
| |
| 290 example = str(policy['example_value']) | 290 example = str(policy['example_value']) |
| 291 self.AddText(win, '%s\\%s = "%s"' % (key_name, policy['name'], example)) | 291 self.AddText(win, '%s\\%s = "%s"' % (key_name, policy['name'], example)) |
| 292 | 292 |
| 293 def _AddDictionaryExampleLinux(self, parent, policy): | 293 def _AddDictionaryExampleLinux(self, parent, policy): |
| 294 '''Adds an example value for Linux of a 'dict' policy to a DOM node. | 294 '''Adds an example value for Linux of a 'dict' policy to a DOM node. |
| 295 | 295 |
| 296 Args: | 296 Args: |
| 297 parent: The DOM node for which the example will be added. | 297 parent: The DOM node for which the example will be added. |
| 298 policy: A policy of type 'dict', for which the Linux example value | 298 policy: A policy of type 'dict', for which the Linux example value |
| 299 is generated. | 299 is generated. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 | 451 |
| 452 dl = self.AddElement(parent, 'dl') | 452 dl = self.AddElement(parent, 'dl') |
| 453 data_type = self._TYPE_MAP[policy['type']] | 453 data_type = self._TYPE_MAP[policy['type']] |
| 454 if (self.IsPolicySupportedOnPlatform(policy, 'win') and | 454 if (self.IsPolicySupportedOnPlatform(policy, 'win') and |
| 455 self._REG_TYPE_MAP.get(policy['type'], None)): | 455 self._REG_TYPE_MAP.get(policy['type'], None)): |
| 456 data_type += ' (%s)' % self._REG_TYPE_MAP[policy['type']] | 456 data_type += ' (%s)' % self._REG_TYPE_MAP[policy['type']] |
| 457 self._AddPolicyAttribute(dl, 'data_type', data_type) | 457 self._AddPolicyAttribute(dl, 'data_type', data_type) |
| 458 if policy['type'] != 'external': | 458 if policy['type'] != 'external': |
| 459 # All types except 'external' can be set through platform policy. | 459 # All types except 'external' can be set through platform policy. |
| 460 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 460 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
| 461 if self.CanBeRecommended(policy) and not self.CanBeMandatory(policy): | |
| 462 win_key = self.config['win_reg_recommended_key_name'] | |
| 463 else: | |
| 464 win_key = self.config['win_reg_mandatory_key_name'] | |
| 461 self._AddPolicyAttribute( | 465 self._AddPolicyAttribute( |
| 462 dl, | 466 dl, |
| 463 'win_reg_loc', | 467 'win_reg_loc', |
| 464 self.config['win_reg_mandatory_key_name'] + '\\' + policy['name'], | 468 win_key + '\\' + policy['name'], |
| 465 ['.monospace']) | 469 ['.monospace']) |
| 466 if (self.IsPolicySupportedOnPlatform(policy, 'linux') or | 470 if (self.IsPolicySupportedOnPlatform(policy, 'linux') or |
| 467 self.IsPolicySupportedOnPlatform(policy, 'mac')): | 471 self.IsPolicySupportedOnPlatform(policy, 'mac')): |
| 468 self._AddPolicyAttribute( | 472 self._AddPolicyAttribute( |
| 469 dl, | 473 dl, |
| 470 'mac_linux_pref_name', | 474 'mac_linux_pref_name', |
| 471 policy['name'], | 475 policy['name'], |
| 472 ['.monospace']) | 476 ['.monospace']) |
| 473 dd = self._AddPolicyAttribute(dl, 'supported_on') | 477 dd = self._AddPolicyAttribute(dl, 'supported_on') |
| 474 self._AddSupportedOnList(dd, policy['supported_on']) | 478 self._AddSupportedOnList(dd, policy['supported_on']) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 674 } | 678 } |
| 675 | 679 |
| 676 # A simple regexp to search for URLs. It is enough for now. | 680 # A simple regexp to search for URLs. It is enough for now. |
| 677 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') | 681 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') |
| 678 | 682 |
| 679 def GetTemplateText(self): | 683 def GetTemplateText(self): |
| 680 # Return the text representation of the main <div> tag. | 684 # Return the text representation of the main <div> tag. |
| 681 return self._main_div.toxml() | 685 return self._main_div.toxml() |
| 682 # To get a complete HTML file, use the following. | 686 # To get a complete HTML file, use the following. |
| 683 # return self._doc.toxml() | 687 # return self._doc.toxml() |
| OLD | NEW |