Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(626)

Side by Side Diff: components/policy/tools/template_writers/writers/adml_writer.py

Issue 2653823006: Include 'external' policies in grit output (admx, adm, doc etc.) (Closed)
Patch Set: Whitespace fix Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 from xml.dom import minidom 6 from xml.dom import minidom
7 from writers import xml_formatted_writer 7 from writers import xml_formatted_writer
8 import re 8 import re
9 9
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 else: 81 else:
82 policy_label = policy_name 82 policy_label = policy_name
83 83
84 self._AddString(policy_name, policy_caption) 84 self._AddString(policy_name, policy_caption)
85 self._AddString(policy_name + '_Explain', policy_description) 85 self._AddString(policy_name + '_Explain', policy_description)
86 presentation_elem = self.AddElement( 86 presentation_elem = self.AddElement(
87 self._presentation_table_elem, 'presentation', {'id': policy_name}) 87 self._presentation_table_elem, 'presentation', {'id': policy_name})
88 88
89 if policy_type == 'main': 89 if policy_type == 'main':
90 pass 90 pass
91 elif policy_type in ('string', 'dict'): 91 elif policy_type in ('string', 'dict', 'external'):
92 # 'dict' policies are configured as JSON-encoded strings on Windows. 92 # 'dict' and 'external' policies are configured as JSON-encoded strings on
93 # Windows.
93 textbox_elem = self.AddElement(presentation_elem, 'textBox', 94 textbox_elem = self.AddElement(presentation_elem, 'textBox',
94 {'refId': policy_name}) 95 {'refId': policy_name})
95 label_elem = self.AddElement(textbox_elem, 'label') 96 label_elem = self.AddElement(textbox_elem, 'label')
96 label_elem.appendChild(self._doc.createTextNode(policy_label)) 97 label_elem.appendChild(self._doc.createTextNode(policy_label))
97 elif policy_type == 'int': 98 elif policy_type == 'int':
98 textbox_elem = self.AddElement(presentation_elem, 'decimalTextBox', 99 textbox_elem = self.AddElement(presentation_elem, 'decimalTextBox',
99 {'refId': policy_name}) 100 {'refId': policy_name})
100 textbox_elem.appendChild(self._doc.createTextNode(policy_label + ':')) 101 textbox_elem.appendChild(self._doc.createTextNode(policy_label + ':'))
101 elif policy_type in ('int-enum', 'string-enum'): 102 elif policy_type in ('int-enum', 'string-enum'):
102 for item in policy['items']: 103 for item in policy['items']:
103 self._AddString(policy_name + "_" + item['name'], item['caption']) 104 self._AddString(policy_name + "_" + item['name'], item['caption'])
104 dropdownlist_elem = self.AddElement(presentation_elem, 'dropdownList', 105 dropdownlist_elem = self.AddElement(presentation_elem, 'dropdownList',
105 {'refId': policy_name}) 106 {'refId': policy_name})
106 dropdownlist_elem.appendChild(self._doc.createTextNode(policy_label)) 107 dropdownlist_elem.appendChild(self._doc.createTextNode(policy_label))
107 elif policy_type in ('list', 'string-enum-list'): 108 elif policy_type in ('list', 'string-enum-list'):
108 self._AddString(policy_name + 'Desc', policy_caption) 109 self._AddString(policy_name + 'Desc', policy_caption)
109 listbox_elem = self.AddElement(presentation_elem, 'listBox', 110 listbox_elem = self.AddElement(presentation_elem, 'listBox',
110 {'refId': policy_name + 'Desc'}) 111 {'refId': policy_name + 'Desc'})
111 listbox_elem.appendChild(self._doc.createTextNode(policy_label)) 112 listbox_elem.appendChild(self._doc.createTextNode(policy_label))
112 elif policy_type == 'group': 113 elif policy_type == 'group':
113 pass 114 pass
114 elif policy_type == 'external':
115 # This type can only be set through cloud policy.
116 pass
117 else: 115 else:
118 raise Exception('Unknown policy type %s.' % policy_type) 116 raise Exception('Unknown policy type %s.' % policy_type)
119 117
120 def BeginPolicyGroup(self, group): 118 def BeginPolicyGroup(self, group):
121 '''Generates ADML elements for a Policy-Group. For each Policy-Group two 119 '''Generates ADML elements for a Policy-Group. For each Policy-Group two
122 ADML "string" elements are added to the string-table. One contains the 120 ADML "string" elements are added to the string-table. One contains the
123 caption of the Policy-Group and the other a description. A Policy-Group also 121 caption of the Policy-Group and the other a description. A Policy-Group also
124 requires an ADML "presentation" element that must be added to the 122 requires an ADML "presentation" element that must be added to the
125 presentation-table. The "presentation" element is the container for the 123 presentation-table. The "presentation" element is the container for the
126 elements that define the visual presentation of the Policy-Goup's Policies. 124 elements that define the visual presentation of the Policy-Goup's Policies.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 assert len(self.platforms) == 1 175 assert len(self.platforms) == 1
178 self.winconfig = self.config['win_config'][self.platforms[0]] 176 self.winconfig = self.config['win_config'][self.platforms[0]]
179 177
180 def GetTemplateText(self): 178 def GetTemplateText(self):
181 # Using "toprettyxml()" confuses the Windows Group Policy Editor 179 # Using "toprettyxml()" confuses the Windows Group Policy Editor
182 # (gpedit.msc) because it interprets whitespace characters in text between 180 # (gpedit.msc) because it interprets whitespace characters in text between
183 # the "string" tags. This prevents gpedit.msc from displaying the category 181 # the "string" tags. This prevents gpedit.msc from displaying the category
184 # names correctly. 182 # names correctly.
185 # TODO(markusheintz): Find a better formatting that works with gpedit. 183 # TODO(markusheintz): Find a better formatting that works with gpedit.
186 return self._doc.toxml() 184 return self._doc.toxml()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698