| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 parent: A DOM element for which the list will be added. | 457 parent: A DOM element for which the list will be added. |
| 458 policy: The data structure of the policy. | 458 policy: The data structure of the policy. |
| 459 ''' | 459 ''' |
| 460 | 460 |
| 461 dl = self.AddElement(parent, 'dl') | 461 dl = self.AddElement(parent, 'dl') |
| 462 data_type = self._TYPE_MAP[policy['type']] | 462 data_type = self._TYPE_MAP[policy['type']] |
| 463 if (self.IsPolicySupportedOnPlatform(policy, 'win') and | 463 if (self.IsPolicySupportedOnPlatform(policy, 'win') and |
| 464 self._REG_TYPE_MAP.get(policy['type'], None)): | 464 self._REG_TYPE_MAP.get(policy['type'], None)): |
| 465 data_type += ' (%s)' % self._REG_TYPE_MAP[policy['type']] | 465 data_type += ' (%s)' % self._REG_TYPE_MAP[policy['type']] |
| 466 self._AddPolicyAttribute(dl, 'data_type', data_type) | 466 self._AddPolicyAttribute(dl, 'data_type', data_type) |
| 467 if self.IsPolicySupportedOnPlatform(policy, 'win'): | 467 if policy['type'] != 'external': |
| 468 self._AddPolicyAttribute( | 468 # All types except 'external' can be set through platform policy. |
| 469 dl, | 469 if self.IsPolicySupportedOnPlatform(policy, 'win'): |
| 470 'win_reg_loc', | 470 self._AddPolicyAttribute( |
| 471 self.config['win_reg_mandatory_key_name'] + '\\' + policy['name'], | 471 dl, |
| 472 ['.monospace']) | 472 'win_reg_loc', |
| 473 if (self.IsPolicySupportedOnPlatform(policy, 'linux') or | 473 self.config['win_reg_mandatory_key_name'] + '\\' + policy['name'], |
| 474 self.IsPolicySupportedOnPlatform(policy, 'mac')): | 474 ['.monospace']) |
| 475 self._AddPolicyAttribute( | 475 if (self.IsPolicySupportedOnPlatform(policy, 'linux') or |
| 476 dl, | 476 self.IsPolicySupportedOnPlatform(policy, 'mac')): |
| 477 'mac_linux_pref_name', | 477 self._AddPolicyAttribute( |
| 478 policy['name'], | 478 dl, |
| 479 ['.monospace']) | 479 'mac_linux_pref_name', |
| 480 policy['name'], |
| 481 ['.monospace']) |
| 480 dd = self._AddPolicyAttribute(dl, 'supported_on') | 482 dd = self._AddPolicyAttribute(dl, 'supported_on') |
| 481 self._AddSupportedOnList(dd, policy['supported_on']) | 483 self._AddSupportedOnList(dd, policy['supported_on']) |
| 482 dd = self._AddPolicyAttribute(dl, 'supported_features') | 484 dd = self._AddPolicyAttribute(dl, 'supported_features') |
| 483 self._AddFeatures(dd, policy) | 485 self._AddFeatures(dd, policy) |
| 484 dd = self._AddPolicyAttribute(dl, 'description') | 486 dd = self._AddPolicyAttribute(dl, 'description') |
| 485 self._AddDescription(dd, policy) | 487 self._AddDescription(dd, policy) |
| 486 if (self.IsPolicySupportedOnPlatform(policy, 'win') or | 488 if (self.IsPolicySupportedOnPlatform(policy, 'win') or |
| 487 self.IsPolicySupportedOnPlatform(policy, 'linux') or | 489 self.IsPolicySupportedOnPlatform(policy, 'linux') or |
| 488 self.IsPolicySupportedOnPlatform(policy, 'mac')): | 490 self.IsPolicySupportedOnPlatform(policy, 'mac')): |
| 489 # Don't add an example for ChromeOS-only policies. | 491 # Don't add an example for ChromeOS-only policies. |
| 490 dd = self._AddPolicyAttribute(dl, 'example_value') | 492 if policy['type'] != 'external': |
| 491 self._AddExample(dd, policy) | 493 # All types except 'external' can be set through platform policy. |
| 494 dd = self._AddPolicyAttribute(dl, 'example_value') |
| 495 self._AddExample(dd, policy) |
| 492 | 496 |
| 493 def _AddPolicyNote(self, parent, policy): | 497 def _AddPolicyNote(self, parent, policy): |
| 494 '''If a policy has an additional web page assigned with it, then add | 498 '''If a policy has an additional web page assigned with it, then add |
| 495 a link for that page. | 499 a link for that page. |
| 496 | 500 |
| 497 Args: | 501 Args: |
| 498 policy: The data structure of the policy. | 502 policy: The data structure of the policy. |
| 499 ''' | 503 ''' |
| 500 if 'problem_href' not in policy: | 504 if 'problem_href' not in policy: |
| 501 return | 505 return |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 self._FEATURE_MAP[message[12:]] = self.messages[message]['text'] | 641 self._FEATURE_MAP[message[12:]] = self.messages[message]['text'] |
| 638 # Human-readable names of types. | 642 # Human-readable names of types. |
| 639 self._TYPE_MAP = { | 643 self._TYPE_MAP = { |
| 640 'string': 'String', | 644 'string': 'String', |
| 641 'int': 'Integer', | 645 'int': 'Integer', |
| 642 'main': 'Boolean', | 646 'main': 'Boolean', |
| 643 'int-enum': 'Integer', | 647 'int-enum': 'Integer', |
| 644 'string-enum': 'String', | 648 'string-enum': 'String', |
| 645 'list': 'List of strings', | 649 'list': 'List of strings', |
| 646 'dict': 'Dictionary', | 650 'dict': 'Dictionary', |
| 651 'external': 'External data reference', |
| 647 } | 652 } |
| 648 self._REG_TYPE_MAP = { | 653 self._REG_TYPE_MAP = { |
| 649 'string': 'REG_SZ', | 654 'string': 'REG_SZ', |
| 650 'int': 'REG_DWORD', | 655 'int': 'REG_DWORD', |
| 651 'main': 'REG_DWORD', | 656 'main': 'REG_DWORD', |
| 652 'int-enum': 'REG_DWORD', | 657 'int-enum': 'REG_DWORD', |
| 653 'string-enum': 'REG_SZ', | 658 'string-enum': 'REG_SZ', |
| 654 'dict': 'REG_SZ, encoded as a JSON string', | 659 'dict': 'REG_SZ, encoded as a JSON string', |
| 655 } | 660 } |
| 656 # The CSS style-sheet used for the document. It will be used in Google | 661 # The CSS style-sheet used for the document. It will be used in Google |
| (...skipping 18 matching lines...) Expand all Loading... |
| 675 } | 680 } |
| 676 | 681 |
| 677 # A simple regexp to search for URLs. It is enough for now. | 682 # A simple regexp to search for URLs. It is enough for now. |
| 678 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') | 683 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') |
| 679 | 684 |
| 680 def GetTemplateText(self): | 685 def GetTemplateText(self): |
| 681 # Return the text representation of the main <div> tag. | 686 # Return the text representation of the main <div> tag. |
| 682 return self._main_div.toxml() | 687 return self._main_div.toxml() |
| 683 # To get a complete HTML file, use the following. | 688 # To get a complete HTML file, use the following. |
| 684 # return self._doc.toxml() | 689 # return self._doc.toxml() |
| OLD | NEW |