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

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

Issue 1372953002: Add support for the 'webview_android' policy configuration (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Address comments Created 5 years, 1 month 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
« no previous file with comments | « grit/format/policy_templates/writers/doc_writer_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 class TemplateWriter(object): 7 class TemplateWriter(object):
8 '''Abstract base class for writing policy templates in various formats. 8 '''Abstract base class for writing policy templates in various formats.
9 The methods of this class will be called by PolicyTemplateGenerator. 9 The methods of this class will be called by PolicyTemplateGenerator.
10 ''' 10 '''
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return False 84 return False
85 85
86 def CanBeRecommended(self, policy): 86 def CanBeRecommended(self, policy):
87 '''Checks if the given policy can be recommended.''' 87 '''Checks if the given policy can be recommended.'''
88 return policy.get('features', {}).get('can_be_recommended', False) 88 return policy.get('features', {}).get('can_be_recommended', False)
89 89
90 def CanBeMandatory(self, policy): 90 def CanBeMandatory(self, policy):
91 '''Checks if the given policy can be mandatory.''' 91 '''Checks if the given policy can be mandatory.'''
92 return policy.get('features', {}).get('can_be_mandatory', True) 92 return policy.get('features', {}).get('can_be_mandatory', True)
93 93
94 def IsPolicySupportedOnPlatform(self, policy, platform): 94 def IsPolicySupportedOnPlatform(self, policy, platform, product=None):
95 '''Checks if |policy| is supported on |platform|. 95 '''Checks if |policy| is supported on |product| for |platform|. If not
96 specified, only the platform support is checked.
96 97
97 Args: 98 Args:
98 policy: The dictionary of the policy. 99 policy: The dictionary of the policy.
99 platform: The platform to check; one of 'win', 'mac', 'linux' or 100 platform: The platform to check; one of 'win', 'mac', 'linux' or
100 'chrome_os'. 101 'chrome_os'.
102 product: Optional product to check; one of 'chrome', 'chrome_frame',
103 'chrome_os', 'webview'
101 ''' 104 '''
102 is_supported = lambda x: platform in x['platforms'] 105 is_supported = lambda x: (platform in x['platforms'] and
106 (not product or product in x['product']))
107
103 return any(filter(is_supported, policy['supported_on'])) 108 return any(filter(is_supported, policy['supported_on']))
104 109
105 def _GetChromiumVersionString(self): 110 def _GetChromiumVersionString(self):
106 '''Returns the Chromium version string stored in the environment variable 111 '''Returns the Chromium version string stored in the environment variable
107 version (if it is set). 112 version (if it is set).
108 113
109 Returns: The Chromium version string or None if it has not been set.''' 114 Returns: The Chromium version string or None if it has not been set.'''
110 115
111 if 'version' in self.config: 116 if 'version' in self.config:
112 return self.config['version'] 117 return self.config['version']
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 ''' 314 '''
310 is_group = policy['type'] == 'group' 315 is_group = policy['type'] == 'group'
311 if is_group: 316 if is_group:
312 # Groups are sorted by caption. 317 # Groups are sorted by caption.
313 str_key = policy['caption'] 318 str_key = policy['caption']
314 else: 319 else:
315 # Regular policies are sorted by name. 320 # Regular policies are sorted by name.
316 str_key = policy['name'] 321 str_key = policy['name']
317 # Groups come before regular policies. 322 # Groups come before regular policies.
318 return (not is_group, str_key) 323 return (not is_group, str_key)
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/doc_writer_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698