Add support for the Android WebView policy configuration (issue 1372953002 by dgn@chromium.org)

1 view
Skip to first unread message

d...@chromium.org

unread,
Sep 29, 2015, 6:42:25 AM9/29/15
to bar...@chromium.org, grit-de...@googlegroups.com, baue...@chromium.org
Reviewers: bartfab,

Description:
Add support for the Android WebView policy configuration

Webview has the platform 'android' and the product 'webview',
its description specifies that the name is the same as the one
for android but prefixed with $android_webview_restriction_prefix

BUG=536733

Please review this at https://codereview.chromium.org/1372953002/

Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master

Affected files (+42, -9 lines):
A grit/format/policy_templates/OWNERS
M grit/format/policy_templates/policy_template_generator.py
M grit/format/policy_templates/writer_configuration.py
M grit/format/policy_templates/writers/doc_writer.py
M grit/format/policy_templates/writers/doc_writer_unittest.py
M grit/format/policy_templates/writers/template_writer.py


Index: grit/format/policy_templates/OWNERS
diff --git a/grit/format/policy_templates/OWNERS
b/grit/format/policy_templates/OWNERS
new file mode 100644
index
0000000000000000000000000000000000000000..9f1793d7520ecf3daabb457c1c88026a48d9023c
--- /dev/null
+++ b/grit/format/policy_templates/OWNERS
@@ -0,0 +1 @@
+bar...@chromium.org
Index: grit/format/policy_templates/policy_template_generator.py
diff --git a/grit/format/policy_templates/policy_template_generator.py
b/grit/format/policy_templates/policy_template_generator.py
index
a1eb123ddda0d5560dbd729ac0add2dc61bb1e99..b338f99f5aab22b627913b14caedcdf2a54e1a8e
100644
--- a/grit/format/policy_templates/policy_template_generator.py
+++ b/grit/format/policy_templates/policy_template_generator.py
@@ -63,12 +63,12 @@ class PolicyTemplateGenerator:
supported_on: The list with its items converted to dictionaries.
E.g.:
[{
'product': 'chrome',
- 'platform': 'win',
+ 'platforms': 'win',
'since_version': '8',
'until_version': '10'
}, {
'product': 'chrome_frame',
- 'platform': 'win',
+ 'platforms': 'win',
'since_version': '10',
'until_version': ''
}]
@@ -88,10 +88,11 @@ class PolicyTemplateGenerator:
else:
# e.g.: 'chrome_frame:7-'
product, platform = {
- 'android': ('chrome', 'android'),
- 'chrome_os': ('chrome_os', 'chrome_os'),
- 'chrome_frame': ('chrome_frame', 'win'),
- 'ios': ('chrome', 'ios'),
+ 'android': ('chrome', 'android'),
+ 'webview_android': ('webview', 'android'),
+ 'chrome_os': ('chrome_os', 'chrome_os'),
+ 'chrome_frame': ('chrome_frame', 'win'),
+ 'ios': ('chrome', 'ios'),
}[product_platform_part]
platforms = [platform]
since_version, until_version = version_part.split('-')
Index: grit/format/policy_templates/writer_configuration.py
diff --git a/grit/format/policy_templates/writer_configuration.py
b/grit/format/policy_templates/writer_configuration.py
index
db9613b2eca0d71a9feaad870526b549f2b7f8be..b1eb2483fab46565a447f40ea2690fa9ab1e8f12
100644
--- a/grit/format/policy_templates/writer_configuration.py
+++ b/grit/format/policy_templates/writer_configuration.py
@@ -26,6 +26,7 @@ def GetConfigurationForBuild(defines):
'app_name': 'Chromium',
'frame_name': 'Chromium Frame',
'os_name': 'Chromium OS',
+ 'webview_name': 'Chromium WebView',
'win_reg_mandatory_key_name': 'Software\\Policies\\Chromium',
'win_reg_recommended_key_name':
'Software\\Policies\\Chromium\\Recommended',
@@ -41,6 +42,7 @@ def GetConfigurationForBuild(defines):
'app_name': 'Google Chrome',
'frame_name': 'Google Chrome Frame',
'os_name': 'Google Chrome OS',
+ 'webview_name': 'System WebView Google',
'win_reg_mandatory_key_name': 'Software\\Policies\\Google\\Chrome',
'win_reg_recommended_key_name':
'Software\\Policies\\Google\\Chrome\\Recommended',
@@ -58,4 +60,5 @@ def GetConfigurationForBuild(defines):
config['win_supported_os'] = 'SUPPORTED_WINXPSP2'
if 'mac_bundle_id' in defines:
config['mac_bundle_id'] = defines['mac_bundle_id']
+ config['android_webview_restriction_prefix'] = 'com.android.browser:'
return config
Index: grit/format/policy_templates/writers/doc_writer.py
diff --git a/grit/format/policy_templates/writers/doc_writer.py
b/grit/format/policy_templates/writers/doc_writer.py
index
ed6d06073be34c1f20a6ce0acc70fc337228dae7..e167d90b7613aab46fbb1f6fa5ee27e2636fb4f5
100644
--- a/grit/format/policy_templates/writers/doc_writer.py
+++ b/grit/format/policy_templates/writers/doc_writer.py
@@ -519,12 +519,19 @@ class
DocWriter(xml_formatted_writer.XMLFormattedWriter):
'mac_linux_pref_name',
policy['name'],
['.monospace'])
- if self.IsPolicySupportedOnPlatform(policy, 'android'):
+ if self.IsPolicySupportedOnPlatform(policy, 'android', 'chrome'):
self._AddPolicyAttribute(
dl,
'android_restriction_name',
policy['name'],
['.monospace'])
+ if self.IsPolicySupportedOnPlatform(policy, 'android', 'webview'):
+ restriction_prefix =
self.config['android_webview_restriction_prefix']
+ self._AddPolicyAttribute(
+ dl,
+ 'android_webview_restriction_name',
+ restriction_prefix + policy['name'],
+ ['.monospace'])
dd = self._AddPolicyAttribute(dl, 'supported_on')
self._AddSupportedOnList(dd, policy['supported_on'])
dd = self._AddPolicyAttribute(dl, 'supported_features')
@@ -685,6 +692,7 @@ class
DocWriter(xml_formatted_writer.XMLFormattedWriter):
'chrome': self.config['app_name'],
'chrome_frame': self.config['frame_name'],
'chrome_os': self.config['os_name'],
+ 'webview': self.config['webview_name'],
}
# Human-readable names of supported features. Each supported feature
has
# a 'doc_feature_X' entry in |self.messages|.
Index: grit/format/policy_templates/writers/doc_writer_unittest.py
diff --git a/grit/format/policy_templates/writers/doc_writer_unittest.py
b/grit/format/policy_templates/writers/doc_writer_unittest.py
index
e51f9f0352ec47cf983d1c0cd8f667b6749403a9..515a08d5d406f0795418755361242c20c2ae39c3
100644
--- a/grit/format/policy_templates/writers/doc_writer_unittest.py
+++ b/grit/format/policy_templates/writers/doc_writer_unittest.py
@@ -37,6 +37,8 @@ class
DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'app_name': 'Chrome',
'frame_name': 'Chrome Frame',
'os_name': 'Chrome OS',
+ 'webview_name': 'WebView',
+ 'android_webview_restriction_prefix': 'mock.prefix:',
'win_reg_mandatory_key_name': 'MockKey',
'win_reg_recommended_key_name': 'MockKeyRec',
'build': 'test_product',
@@ -58,6 +60,9 @@ class
DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'doc_android_restriction_name': {
'text': '_test_android_restriction_name'
},
+ 'doc_android_webview_restriction_name': {
+ 'text': '_test_android_webview_restriction_name'
+ },
'doc_note': {'text': '_test_note'},
'doc_name_column_title': {'text': '_test_name_column_title'},
'doc_not_supported': {'text': '_test_not_supported'},
@@ -418,6 +423,11 @@ See <a
href="http://policy-explanation.example.com">http://policy-explanation.ex
'since_version': '30',
'until_version': '',
}, {
+ 'product': 'webview',
+ 'platforms': ['android'],
+ 'since_version': '47',
+ 'until_version': '',
+ }, {
'product': 'chrome',
'platforms': ['ios'],
'since_version': '34',
@@ -439,11 +449,14 @@ See <a
href="http://policy-explanation.example.com">http://policy-explanation.ex
'<dd style="style_.monospace;">TestPolicyName</dd>'
'<dt style="style_dt;">_test_android_restriction_name</dt>'
'<dd style="style_.monospace;">TestPolicyName</dd>'
+ '<dt style="style_dt;">_test_android_webview_restriction_name</dt>'
+ '<dd style="style_.monospace;">mock.prefix:TestPolicyName</dd>'
'<dt style="style_dt;">_test_supported_on</dt>'
'<dd>'
'<ul style="style_ul;">'
'<li>Chrome (Windows, Mac, Linux) ...8...</li>'
'<li>Chrome (Android) ...30...</li>'
+ '<li>WebView (Android) ...47...</li>'
'<li>Chrome (iOS) ...34...</li>'
'</ul>'
'</dd>'
Index: grit/format/policy_templates/writers/template_writer.py
diff --git a/grit/format/policy_templates/writers/template_writer.py
b/grit/format/policy_templates/writers/template_writer.py
index
d489d648c3767e9a1d94e57e851745abf52b4d76..4a23ff5a606553e08c46468f384b8df28da17fe4
100644
--- a/grit/format/policy_templates/writers/template_writer.py
+++ b/grit/format/policy_templates/writers/template_writer.py
@@ -91,7 +91,7 @@ class TemplateWriter(object):
'''Checks if the given policy can be mandatory.'''
return policy.get('features', {}).get('can_be_mandatory', True)

- def IsPolicySupportedOnPlatform(self, policy, platform):
+ def IsPolicySupportedOnPlatform(self, policy, platform, product=None):
'''Checks if |policy| is supported on |platform|.

Args:
@@ -99,7 +99,14 @@ class TemplateWriter(object):
platform: The platform to check; one of 'win', 'mac', 'linux' or
'chrome_os'.
'''
- is_supported = lambda x: platform in x['platforms']
+
+ def is_supported(supported_on):
+ if not platform in supported_on['platforms']:
+ return None
+ if product and not product in supported_on['product']:
+ return None
+ return supported_on
+
return any(filter(is_supported, policy['supported_on']))

def _GetChromiumVersionString(self):


bau...@chromium.org

unread,
Sep 29, 2015, 8:27:42 AM9/29/15
to d...@chromium.org, bar...@chromium.org, grit-de...@googlegroups.com
lgtm




https://codereview.chromium.org/1372953002/diff/20001/grit/format/policy_templates/writer_configuration.py
File grit/format/policy_templates/writer_configuration.py (right):

https://codereview.chromium.org/1372953002/diff/20001/grit/format/policy_templates/writer_configuration.py#newcode45
grit/format/policy_templates/writer_configuration.py:45: 'webview_name':
'System WebView Google',
The official name (according to
https://play.google.com/store/apps/details?id=com.google.android.webview)
is "Android System WebView".

https://codereview.chromium.org/1372953002/

d...@chromium.org

unread,
Sep 29, 2015, 11:52:59 AM9/29/15
to bar...@chromium.org, bauerb+...@chromium.org, grit-de...@googlegroups.com, bauerb+...@chromium.org
Thanks!


https://codereview.chromium.org/1372953002/diff/20001/grit/format/policy_templates/writer_configuration.py
File grit/format/policy_templates/writer_configuration.py (right):

https://codereview.chromium.org/1372953002/diff/20001/grit/format/policy_templates/writer_configuration.py#newcode45
grit/format/policy_templates/writer_configuration.py:45: 'webview_name':
'System WebView Google',
On 2015/09/29 12:27:41, Bernhard Bauer wrote:
> The official name (according to

https://play.google.com/store/apps/details?id=com.google.android.webview)
is
> "Android System WebView".

Done.

https://codereview.chromium.org/1372953002/
Reply all
Reply to author
Forward
0 new messages