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

Side by Side Diff: grit/format/policy_templates/writers/ios_plist_writer.py

Issue 631223003: Include chromium version number in policy templates (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2014 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 import base64 7 import base64
8 8
9 from xml.dom import minidom 9 from xml.dom import minidom
10 from grit.format.policy_templates.writers import plist_writer 10 from grit.format.policy_templates.writers import plist_writer
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 for dict in [self._dict, self._encoded_dict]: 90 for dict in [self._dict, self._encoded_dict]:
91 self.AddElement(dict, 'key', {}, policy['name']) 91 self.AddElement(dict, 'key', {}, policy['name'])
92 self._WriteValue(dict, policy['example_value']) 92 self._WriteValue(dict, policy['example_value'])
93 93
94 # Overridden. 94 # Overridden.
95 # |self._plist| is created in super.Init(). 95 # |self._plist| is created in super.Init().
96 def BeginTemplate(self): 96 def BeginTemplate(self):
97 self._plist.attributes['version'] = '1.0' 97 self._plist.attributes['version'] = '1.0'
98 self._root_dict = self.AddElement(self._plist, 'dict') 98 self._root_dict = self.AddElement(self._plist, 'dict')
99 self.AddComment(self._root_dict, CHROME_POLICY_COMMENT) 99 self.AddComment(self._root_dict, CHROME_POLICY_COMMENT)
100 if self._GetChromiumVersionString() is not None:
101 self.AddComment(self._root_dict, ' ' + self.config['build'] + \
102 ' version: ' + self._GetChromiumVersionString() + ' ')
100 self._dict = self._AddKeyValuePair(self._root_dict, 'ChromePolicy', 'dict') 103 self._dict = self._AddKeyValuePair(self._root_dict, 'ChromePolicy', 'dict')
101 104
102 self._encoded_plist.attributes['version'] = '1.0' 105 self._encoded_plist.attributes['version'] = '1.0'
103 self._encoded_dict = self.AddElement(self._encoded_plist, 'dict') 106 self._encoded_dict = self.AddElement(self._encoded_plist, 'dict')
104 107
105 # Overridden. 108 # Overridden.
106 def EndTemplate(self): 109 def EndTemplate(self):
107 # Add the "EncodedChromePolicy" entry. 110 # Add the "EncodedChromePolicy" entry.
108 encoded = base64.b64encode(self._encoded_doc.toxml()) 111 encoded = base64.b64encode(self._encoded_doc.toxml())
109 self.AddComment(self._root_dict, ENCODED_CHROME_POLICY_COMMENT) 112 self.AddComment(self._root_dict, ENCODED_CHROME_POLICY_COMMENT)
110 self._AddStringKeyValuePair(self._root_dict, 'EncodedChromePolicy', encoded) 113 self._AddStringKeyValuePair(self._root_dict, 'EncodedChromePolicy', encoded)
111 114
112 # Overridden. 115 # Overridden.
113 def Init(self): 116 def Init(self):
114 super(IOSPlistWriter, self).Init() 117 super(IOSPlistWriter, self).Init()
115 # Create a secondary DOM for the EncodedChromePolicy Plist, which will be 118 # Create a secondary DOM for the EncodedChromePolicy Plist, which will be
116 # serialized and encoded in EndTemplate. 119 # serialized and encoded in EndTemplate.
117 self._encoded_doc = self.CreatePlistDocument() 120 self._encoded_doc = self.CreatePlistDocument()
118 self._encoded_plist = self._encoded_doc.documentElement 121 self._encoded_plist = self._encoded_doc.documentElement
119 122
120 # Overridden. 123 # Overridden.
121 def GetTemplateText(self): 124 def GetTemplateText(self):
122 return self.ToPrettyXml(self._doc, encoding='UTF-8') 125 return self.ToPrettyXml(self._doc, encoding='UTF-8')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698