| 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 writers import template_writer | 7 from writers import template_writer |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 NEWLINE = '\r\n' | 10 NEWLINE = '\r\n' |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 builder.AddLine('END POLICY', -1) | 162 builder.AddLine('END POLICY', -1) |
| 163 builder.AddLine() | 163 builder.AddLine() |
| 164 | 164 |
| 165 def WriteComment(self, comment): | 165 def WriteComment(self, comment): |
| 166 self.lines.AddLine('; ' + comment) | 166 self.lines.AddLine('; ' + comment) |
| 167 | 167 |
| 168 def WritePolicy(self, policy): | 168 def WritePolicy(self, policy): |
| 169 if self.CanBeMandatory(policy): | 169 if self.CanBeMandatory(policy): |
| 170 self._WritePolicy(policy, | 170 self._WritePolicy(policy, |
| 171 self.config['win_reg_mandatory_key_name'], | 171 self.winconfig['reg_mandatory_key_name'], |
| 172 self.policies) | 172 self.policies) |
| 173 | 173 |
| 174 def WriteRecommendedPolicy(self, policy): | 174 def WriteRecommendedPolicy(self, policy): |
| 175 self._WritePolicy(policy, | 175 self._WritePolicy(policy, |
| 176 self.config['win_reg_recommended_key_name'], | 176 self.winconfig['reg_recommended_key_name'], |
| 177 self.recommended_policies) | 177 self.recommended_policies) |
| 178 | 178 |
| 179 def BeginPolicyGroup(self, group): | 179 def BeginPolicyGroup(self, group): |
| 180 category_name = self._Escape(group['name'] + '_Category') | 180 category_name = self._Escape(group['name'] + '_Category') |
| 181 self._AddGuiString(category_name, group['caption']) | 181 self._AddGuiString(category_name, group['caption']) |
| 182 self.policies.AddLine('CATEGORY !!' + category_name, 1) | 182 self.policies.AddLine('CATEGORY !!' + category_name, 1) |
| 183 | 183 |
| 184 def EndPolicyGroup(self): | 184 def EndPolicyGroup(self): |
| 185 self.policies.AddLine('END CATEGORY', -1) | 185 self.policies.AddLine('END CATEGORY', -1) |
| 186 self.policies.AddLine('') | 186 self.policies.AddLine('') |
| (...skipping 29 matching lines...) Expand all Loading... |
| 216 lines.AddLine() | 216 lines.AddLine() |
| 217 | 217 |
| 218 return lines | 218 return lines |
| 219 | 219 |
| 220 def BeginTemplate(self): | 220 def BeginTemplate(self): |
| 221 if self._GetChromiumVersionString() is not None: | 221 if self._GetChromiumVersionString() is not None: |
| 222 self.WriteComment(self.config['build'] + ' version: ' + \ | 222 self.WriteComment(self.config['build'] + ' version: ' + \ |
| 223 self._GetChromiumVersionString()) | 223 self._GetChromiumVersionString()) |
| 224 self._AddGuiString(self.config['win_supported_os'], | 224 self._AddGuiString(self.config['win_supported_os'], |
| 225 self.messages['win_supported_winxpsp2']['text']) | 225 self.messages['win_supported_winxpsp2']['text']) |
| 226 categories = self.config['win_mandatory_category_path'] + \ | 226 categories = self.winconfig['mandatory_category_path'] + \ |
| 227 self.config['win_recommended_category_path'] | 227 self.winconfig['recommended_category_path'] |
| 228 strings = self.config['win_category_path_strings'].copy() | 228 strings = self.winconfig['category_path_strings'].copy() |
| 229 if 'adm_category_path_strings' in self.config: | 229 if 'adm_category_path_strings' in self.config: |
| 230 strings.update(self.config['adm_category_path_strings']) | 230 strings.update(self.config['adm_category_path_strings']) |
| 231 for category in categories: | 231 for category in categories: |
| 232 if (category in strings): | 232 if (category in strings): |
| 233 # Replace {...} by localized messages. | 233 # Replace {...} by localized messages. |
| 234 string = re.sub(r"\{(\w+)\}", \ | 234 string = re.sub(r"\{(\w+)\}", \ |
| 235 lambda m: self.messages[m.group(1)]['text'], \ | 235 lambda m: self.messages[m.group(1)]['text'], \ |
| 236 strings[category]) | 236 strings[category]) |
| 237 self._AddGuiString(category, string) | 237 self._AddGuiString(category, string) |
| 238 # All the policies will be written into self.policies. | 238 # All the policies will be written into self.policies. |
| 239 # The final template text will be assembled into self.lines by | 239 # The final template text will be assembled into self.lines by |
| 240 # self.EndTemplate(). | 240 # self.EndTemplate(). |
| 241 | 241 |
| 242 def EndTemplate(self): | 242 def EndTemplate(self): |
| 243 # Copy policies into self.lines. | 243 # Copy policies into self.lines. |
| 244 policy_class = self.config['win_group_policy_class'].upper() | 244 policy_class = self.GetClass().upper(); |
| 245 for class_name in ['MACHINE', 'USER']: | 245 for class_name in ['MACHINE', 'USER']: |
| 246 if policy_class != 'BOTH' and policy_class != class_name: | 246 if policy_class != 'BOTH' and policy_class != class_name: |
| 247 continue | 247 continue |
| 248 self.lines.AddLine('CLASS ' + class_name, 1) | 248 self.lines.AddLine('CLASS ' + class_name, 1) |
| 249 self.lines.AddLines(self._CreateTemplate( | 249 self.lines.AddLines(self._CreateTemplate( |
| 250 self.config['win_mandatory_category_path'], | 250 self.winconfig['mandatory_category_path'], |
| 251 self.config['win_reg_mandatory_key_name'], | 251 self.winconfig['reg_mandatory_key_name'], |
| 252 self.policies)) | 252 self.policies)) |
| 253 self.lines.AddLines(self._CreateTemplate( | 253 self.lines.AddLines(self._CreateTemplate( |
| 254 self.config['win_recommended_category_path'], | 254 self.winconfig['recommended_category_path'], |
| 255 self.config['win_reg_recommended_key_name'], | 255 self.winconfig['reg_recommended_key_name'], |
| 256 self.recommended_policies)) | 256 self.recommended_policies)) |
| 257 self.lines.AddLine('', -1) | 257 self.lines.AddLine('', -1) |
| 258 # Copy user strings into self.lines. | 258 # Copy user strings into self.lines. |
| 259 self.lines.AddLine('[Strings]') | 259 self.lines.AddLine('[Strings]') |
| 260 self.lines.AddLines(self.strings) | 260 self.lines.AddLines(self.strings) |
| 261 | 261 |
| 262 def Init(self): | 262 def Init(self): |
| 263 # String buffer for building the whole ADM file. | 263 # String buffer for building the whole ADM file. |
| 264 self.lines = IndentedStringBuilder() | 264 self.lines = IndentedStringBuilder() |
| 265 # String buffer for building the strings section of the ADM file. | 265 # String buffer for building the strings section of the ADM file. |
| 266 self.strings = IndentedStringBuilder() | 266 self.strings = IndentedStringBuilder() |
| 267 # Map of strings seen, to avoid duplicates. | 267 # Map of strings seen, to avoid duplicates. |
| 268 self.strings_seen = {} | 268 self.strings_seen = {} |
| 269 # String buffer for building the policies of the ADM file. | 269 # String buffer for building the policies of the ADM file. |
| 270 self.policies = IndentedStringBuilder() | 270 self.policies = IndentedStringBuilder() |
| 271 # String buffer for building the recommended policies of the ADM file. | 271 # String buffer for building the recommended policies of the ADM file. |
| 272 self.recommended_policies = IndentedStringBuilder() | 272 self.recommended_policies = IndentedStringBuilder() |
| 273 # Shortcut to platform-specific ADMX/ADM specific configuration. |
| 274 assert len(self.platforms) == 1 |
| 275 self.winconfig = self.config['win_config'][self.platforms[0]] |
| 273 | 276 |
| 274 def GetTemplateText(self): | 277 def GetTemplateText(self): |
| 275 return self.lines.ToString() | 278 return self.lines.ToString() |
| 279 |
| 280 def GetClass(self): |
| 281 return 'Both'; |
| OLD | NEW |