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

Unified Diff: grit/format/policy_templates/writers/plist_writer.py

Issue 544113002: Add optional mandatory policy setting for template generation (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: rebase Created 6 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 side-by-side diff with in-line comments
Download patch
Index: grit/format/policy_templates/writers/plist_writer.py
diff --git a/grit/format/policy_templates/writers/plist_writer.py b/grit/format/policy_templates/writers/plist_writer.py
index 6ca905b9c5dccd81bd2728e7b11852d72774fbbc..6d929d6542687720a1dd3cde095a7886773600e3 100644
--- a/grit/format/policy_templates/writers/plist_writer.py
+++ b/grit/format/policy_templates/writers/plist_writer.py
@@ -67,7 +67,7 @@ class PListWriter(xml_formatted_writer.XMLFormattedWriter):
self.AddElement(parent, 'key', {}, key_string)
self.AddElement(parent, 'string', {}, value_string)
- def _AddTargets(self, parent):
+ def _AddTargets(self, parent, policy):
'''Adds the following XML snippet to an XML element:
<key>pfm_targets</key>
<array>
@@ -78,7 +78,10 @@ class PListWriter(xml_formatted_writer.XMLFormattedWriter):
parent: The parent XML element where the snippet will be added.
'''
array = self._AddKeyValuePair(parent, 'pfm_targets', 'array')
- self.AddElement(array, 'string', {}, 'user-managed')
+ if self.CanBeRecommended(policy):
+ self.AddElement(array, 'string', {}, 'user')
+ if self.CanBeMandatory(policy):
+ self.AddElement(array, 'string', {}, 'user-managed')
def PreprocessPolicies(self, policy_list):
return self.FlattenGroupsAndSortPolicies(policy_list)
@@ -97,7 +100,7 @@ class PListWriter(xml_formatted_writer.XMLFormattedWriter):
# Those files are generated by plist_strings_writer.
self._AddStringKeyValuePair(dict, 'pfm_description', '')
self._AddStringKeyValuePair(dict, 'pfm_title', '')
- self._AddTargets(dict)
+ self._AddTargets(dict, policy)
self._AddStringKeyValuePair(dict, 'pfm_type',
self.TYPE_TO_INPUT[policy_type])
if policy_type in ('int-enum', 'string-enum'):

Powered by Google App Engine
This is Rietveld 408576698