| 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 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 | 8 |
| 9 | 9 |
| 10 def GetWriter(config): | 10 def GetWriter(config): |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 category_elem = self.AddElement(parent, 'category', attributes) | 120 category_elem = self.AddElement(parent, 'category', attributes) |
| 121 if parent_category_name: | 121 if parent_category_name: |
| 122 attributes = {'ref': parent_category_name} | 122 attributes = {'ref': parent_category_name} |
| 123 self.AddElement(category_elem, 'parentCategory', attributes) | 123 self.AddElement(category_elem, 'parentCategory', attributes) |
| 124 | 124 |
| 125 def _AddCategories(self, categories): | 125 def _AddCategories(self, categories): |
| 126 '''Generates the ADMX "categories" element and adds it to the categories | 126 '''Generates the ADMX "categories" element and adds it to the categories |
| 127 main node. The "categories" element defines the category for the policies | 127 main node. The "categories" element defines the category for the policies |
| 128 defined in this ADMX document. Here is an example of an ADMX "categories" | 128 defined in this ADMX document. Here is an example of an ADMX "categories" |
| 129 element on Windows: | 129 element: |
| 130 | 130 |
| 131 <categories> | 131 <categories> |
| 132 <category displayName="$(string.googlechrome)" name="googlechrome"> | 132 <category displayName="$(string.googlechrome)" name="googlechrome"> |
| 133 <parentCategory ref="Google:Cat_Google"/> | 133 <parentCategory ref="Google:Cat_Google"/> |
| 134 </category> | 134 </category> |
| 135 </categories> | 135 </categories> |
| 136 | 136 |
| 137 Args: | 137 Args: |
| 138 categories_path: The categories path e.g. ['google', 'googlechrome']. For | 138 categories_path: The categories path e.g. ['google', 'googlechrome']. For |
| 139 each level in the path a "category" element will be generated, unless | 139 each level in the path a "category" element will be generated, unless |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 raise Exception('There is supposed to be only one "elements" node but' | 264 raise Exception('There is supposed to be only one "elements" node but' |
| 265 ' there are %s.' % str(len(elements_list))) | 265 ' there are %s.' % str(len(elements_list))) |
| 266 | 266 |
| 267 def _WritePolicy(self, policy, name, key, parent): | 267 def _WritePolicy(self, policy, name, key, parent): |
| 268 '''Generates AMDX elements for a Policy. There are four different policy | 268 '''Generates AMDX elements for a Policy. There are four different policy |
| 269 types: Main-Policy, String-Policy, Enum-Policy and List-Policy. | 269 types: Main-Policy, String-Policy, Enum-Policy and List-Policy. |
| 270 ''' | 270 ''' |
| 271 policies_elem = self._active_policies_elem | 271 policies_elem = self._active_policies_elem |
| 272 policy_type = policy['type'] | 272 policy_type = policy['type'] |
| 273 policy_name = policy['name'] | 273 policy_name = policy['name'] |
| 274 if policy_type == 'external': | |
| 275 # This type can only be set through cloud policy. | |
| 276 return | |
| 277 | 274 |
| 278 attributes = { | 275 attributes = { |
| 279 'name': name, | 276 'name': name, |
| 280 'class': self.GetClass(policy), | 277 'class': self.GetClass(policy), |
| 281 'displayName': self._AdmlString(policy_name), | 278 'displayName': self._AdmlString(policy_name), |
| 282 'explainText': self._AdmlStringExplain(policy_name), | 279 'explainText': self._AdmlStringExplain(policy_name), |
| 283 'presentation': self._AdmlPresentation(policy_name), | 280 'presentation': self._AdmlPresentation(policy_name), |
| 284 'key': key, | 281 'key': key, |
| 285 } | 282 } |
| 286 # Store the current "policy" AMDX element in self for later use by the | 283 # Store the current "policy" AMDX element in self for later use by the |
| 287 # WritePolicy method. | 284 # WritePolicy method. |
| 288 policy_elem = self.AddElement(policies_elem, 'policy', | 285 policy_elem = self.AddElement(policies_elem, 'policy', |
| 289 attributes) | 286 attributes) |
| 290 self.AddElement(policy_elem, 'parentCategory', | 287 self.AddElement(policy_elem, 'parentCategory', |
| 291 {'ref': parent}) | 288 {'ref': parent}) |
| 292 self.AddElement(policy_elem, 'supportedOn', | 289 self.AddElement(policy_elem, 'supportedOn', |
| 293 {'ref': self.config['win_supported_os']}) | 290 {'ref': self.config['win_supported_os']}) |
| 294 if policy_type == 'main': | 291 if policy_type == 'main': |
| 295 self.AddAttribute(policy_elem, 'valueName', policy_name) | 292 self.AddAttribute(policy_elem, 'valueName', policy_name) |
| 296 self._AddMainPolicy(policy_elem) | 293 self._AddMainPolicy(policy_elem) |
| 297 elif policy_type in ('string', 'dict'): | 294 elif policy_type in ('string', 'dict', 'external'): |
| 298 # 'dict' policies are configured as JSON-encoded strings on Windows. | 295 # 'dict' and 'external' policies are configured as JSON-encoded strings on |
| 296 # Windows. |
| 299 parent = self._GetElements(policy_elem) | 297 parent = self._GetElements(policy_elem) |
| 300 self._AddStringPolicy(parent, policy_name) | 298 self._AddStringPolicy(parent, policy_name) |
| 301 elif policy_type == 'int': | 299 elif policy_type == 'int': |
| 302 parent = self._GetElements(policy_elem) | 300 parent = self._GetElements(policy_elem) |
| 303 self._AddIntPolicy(parent, policy_name) | 301 self._AddIntPolicy(parent, policy_name) |
| 304 elif policy_type in ('int-enum', 'string-enum'): | 302 elif policy_type in ('int-enum', 'string-enum'): |
| 305 parent = self._GetElements(policy_elem) | 303 parent = self._GetElements(policy_elem) |
| 306 self._AddEnumPolicy(parent, policy) | 304 self._AddEnumPolicy(parent, policy) |
| 307 elif policy_type in ('list', 'string-enum-list'): | 305 elif policy_type in ('list', 'string-enum-list'): |
| 308 parent = self._GetElements(policy_elem) | 306 parent = self._GetElements(policy_elem) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 self._active_mandatory_policy_group_name = \ | 389 self._active_mandatory_policy_group_name = \ |
| 392 self.winconfig['mandatory_category_path'][-1] | 390 self.winconfig['mandatory_category_path'][-1] |
| 393 self._active_recommended_policy_group_name = \ | 391 self._active_recommended_policy_group_name = \ |
| 394 self.winconfig['recommended_category_path'][-1] | 392 self.winconfig['recommended_category_path'][-1] |
| 395 | 393 |
| 396 def GetTemplateText(self): | 394 def GetTemplateText(self): |
| 397 return self.ToPrettyXml(self._doc) | 395 return self.ToPrettyXml(self._doc) |
| 398 | 396 |
| 399 def GetClass(self, policy): | 397 def GetClass(self, policy): |
| 400 return 'Both' | 398 return 'Both' |
| OLD | NEW |