summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DEPS2
-rw-r--r--components/policy.gypi10
-rw-r--r--components/policy/BUILD.gn20
-rw-r--r--components/policy/resources/policy_templates.grd173
-rw-r--r--components/policy/resources/policy_templates.json4
-rwxr-xr-xcomponents/policy/tools/generate_policy_source.py80
6 files changed, 152 insertions, 137 deletions
diff --git a/DEPS b/DEPS
index 43b5d17..f7878bf 100644
--- a/DEPS
+++ b/DEPS
@@ -158,7 +158,7 @@ deps = {
Var('chromium_git') + '/external/snappy.git' + '@' + '762bb32f0c9d2f31ba4958c7c0933d22e80c20bf',
'src/tools/grit':
- Var('chromium_git') + '/external/grit-i18n.git' + '@' + '5b56593a81a883b49509e2e51a779aefd8df3148', # from svn revision 187
+ Var('chromium_git') + '/external/grit-i18n.git' + '@' + '0287c187b11ed53590254e4d817e836a44a7a1a7', # from svn revision 186
'src/tools/gyp':
Var('chromium_git') + '/external/gyp.git' + '@' + '4a9b712d5cb4a5ba7a9950128a7219569caf7263',
diff --git a/components/policy.gypi b/components/policy.gypi
index 189c01e..e6573b6 100644
--- a/components/policy.gypi
+++ b/components/policy.gypi
@@ -12,6 +12,7 @@
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome',
'policy_out_dir': '<(SHARED_INTERMEDIATE_DIR)/policy',
'protoc_out_dir': '<(SHARED_INTERMEDIATE_DIR)/protoc_out',
+ 'android_resources_out_dir': '<(policy_out_dir)/android_resources',
'generate_policy_source_script_path':
'policy/tools/generate_policy_source.py',
'policy_constant_header_path':
@@ -21,7 +22,9 @@
'protobuf_decoder_path':
'<(policy_out_dir)/policy/cloud_policy_generated.cc',
'app_restrictions_path':
- '<(policy_out_dir)/app_restrictions.xml',
+ '<(android_resources_out_dir)/xml-v21/app_restrictions.xml',
+ 'app_resources_path':
+ '<(android_resources_out_dir)/values-v21/restriction_values.xml',
# This is the "full" protobuf, which defines one protobuf message per
# policy. It is also the format currently used by the server.
'chrome_settings_proto_path':
@@ -112,6 +115,7 @@
'<(chrome_settings_proto_path)',
'<(cloud_policy_proto_path)',
'<(app_restrictions_path)',
+ '<(app_resources_path)',
],
'action_name': 'generate_policy_source',
'action': [
@@ -123,6 +127,7 @@
'--cloud-policy-protobuf=<(cloud_policy_proto_path)',
'--cloud-policy-decoder=<(protobuf_decoder_path)',
'--app-restrictions-definition=<(app_restrictions_path)',
+ '--app-restrictions-resources=<(app_resources_path)',
'<(OS)',
'<(chromeos)',
'policy/resources/policy_templates.json',
@@ -132,6 +137,7 @@
['OS!="android"', {
'outputs!': [
'<(app_restrictions_path)',
+ '<(app_resources_path)',
],
}],
],
@@ -364,7 +370,7 @@
},
],
}],
- ['OS!="ios"', {
+ ['OS=="win" or OS=="mac" or OS=="linux"', {
'targets': [
{
# policy_templates has different inputs and outputs, so it can't use
diff --git a/components/policy/BUILD.gn b/components/policy/BUILD.gn
index e6a288e..61961e50 100644
--- a/components/policy/BUILD.gn
+++ b/components/policy/BUILD.gn
@@ -47,6 +47,9 @@ if (enable_configuration_policy) {
# build puts everything into the following directory. We do the same for now.
policy_gen_dir = "$root_gen_dir/policy"
+ # Directory for generating Android App Restrictions resources
+ android_resources_gen_dir = "$policy_gen_dir/android_resources"
+
# This protobuf is equivalent to chrome_settings.proto but shares messages
# for policies of the same type, so that less classes have to be generated
# and compiled.
@@ -59,7 +62,10 @@ if (enable_configuration_policy) {
constants_header_path = "$policy_gen_dir/policy_constants.h"
constants_source_path = "$policy_gen_dir/policy_constants.cc"
protobuf_decoder_path = "$policy_gen_dir/cloud_policy_generated.cc"
- app_restrictions_path = "$policy_gen_dir/app_restrictions.xml"
+ app_restrictions_path =
+ "$android_resources_gen_dir/xml-v21/app_restrictions.xml"
+ app_resources_path =
+ "$android_resources_gen_dir/values-v21/restriction_values.xml"
action("cloud_policy_code_generate") {
script = "tools/generate_policy_source.py"
@@ -80,10 +86,14 @@ if (enable_configuration_policy) {
chrome_settings_proto_path,
cloud_policy_proto_path,
app_restrictions_path,
+ app_resources_path,
]
- if (target_os != "android") {
- outputs -= [ app_restrictions_path ]
+ if (current_os != "android") {
+ outputs -= [
+ app_restrictions_path,
+ app_resources_path,
+ ]
}
args = [
@@ -99,7 +109,9 @@ if (enable_configuration_policy) {
rebase_path(protobuf_decoder_path, root_build_dir),
"--app-restrictions-definition=" +
rebase_path(app_restrictions_path, root_build_dir),
- target_os,
+ "--app-restrictions-resources=" +
+ rebase_path(app_resources_path, root_build_dir),
+ current_os,
chromeos_flag,
rebase_path("resources/policy_templates.json", root_build_dir),
]
diff --git a/components/policy/resources/policy_templates.grd b/components/policy/resources/policy_templates.grd
index 2fb729d..cd26190 100644
--- a/components/policy/resources/policy_templates.grd
+++ b/components/policy/resources/policy_templates.grd
@@ -6,60 +6,7 @@ templates and will be translated for each locale. -->
<grit base_dir="." latest_public_release="0" current_release="1"
source_lang_id="en" enc_check="möl">
<outputs>
- <output filename="app/policy/common/html/am/chrome_policy_list.html" type="doc" lang="am" />
- <output filename="app/policy/common/html/ar/chrome_policy_list.html" type="doc" lang="ar" />
- <output filename="app/policy/common/html/bg/chrome_policy_list.html" type="doc" lang="bg" />
- <output filename="app/policy/common/html/bn/chrome_policy_list.html" type="doc" lang="bn" />
- <output filename="app/policy/common/html/ca/chrome_policy_list.html" type="doc" lang="ca" />
- <output filename="app/policy/common/html/cs/chrome_policy_list.html" type="doc" lang="cs" />
- <output filename="app/policy/common/html/da/chrome_policy_list.html" type="doc" lang="da" />
- <output filename="app/policy/common/html/de/chrome_policy_list.html" type="doc" lang="de" />
- <output filename="app/policy/common/html/el/chrome_policy_list.html" type="doc" lang="el" />
- <output filename="app/policy/common/html/en-GB/chrome_policy_list.html" type="doc" lang="en-GB" />
- <output filename="app/policy/common/html/en-US/chrome_policy_list.html" type="doc" lang="en" />
- <output filename="app/policy/common/html/es/chrome_policy_list.html" type="doc" lang="es" />
- <output filename="app/policy/common/html/es-419/chrome_policy_list.html" type="doc" lang="es-419" />
- <output filename="app/policy/common/html/et/chrome_policy_list.html" type="doc" lang="et" />
- <output filename="app/policy/common/html/fa/chrome_policy_list.html" type="doc" lang="fa" />
- <output filename="app/policy/common/html/fi/chrome_policy_list.html" type="doc" lang="fi" />
- <output filename="app/policy/common/html/fil/chrome_policy_list.html" type="doc" lang="fil" />
- <output filename="app/policy/common/html/fr/chrome_policy_list.html" type="doc" lang="fr" />
- <output filename="app/policy/common/html/gu/chrome_policy_list.html" type="doc" lang="gu" />
- <output filename="app/policy/common/html/he/chrome_policy_list.html" type="doc" lang="he" />
- <output filename="app/policy/common/html/hi/chrome_policy_list.html" type="doc" lang="hi" />
- <output filename="app/policy/common/html/hr/chrome_policy_list.html" type="doc" lang="hr" />
- <output filename="app/policy/common/html/hu/chrome_policy_list.html" type="doc" lang="hu" />
- <output filename="app/policy/common/html/id/chrome_policy_list.html" type="doc" lang="id" />
- <output filename="app/policy/common/html/it/chrome_policy_list.html" type="doc" lang="it" />
- <output filename="app/policy/common/html/ja/chrome_policy_list.html" type="doc" lang="ja" />
- <output filename="app/policy/common/html/kn/chrome_policy_list.html" type="doc" lang="kn" />
- <output filename="app/policy/common/html/ko/chrome_policy_list.html" type="doc" lang="ko" />
- <output filename="app/policy/common/html/lt/chrome_policy_list.html" type="doc" lang="lt" />
- <output filename="app/policy/common/html/lv/chrome_policy_list.html" type="doc" lang="lv" />
- <output filename="app/policy/common/html/ml/chrome_policy_list.html" type="doc" lang="ml" />
- <output filename="app/policy/common/html/mr/chrome_policy_list.html" type="doc" lang="mr" />
- <output filename="app/policy/common/html/ms/chrome_policy_list.html" type="doc" lang="ms" />
- <output filename="app/policy/common/html/nl/chrome_policy_list.html" type="doc" lang="nl" />
- <output filename="app/policy/common/html/nb/chrome_policy_list.html" type="doc" lang="no" />
- <!-- 'no' for Norwegian Bokmål. It should be 'nb'. -->
- <output filename="app/policy/common/html/pl/chrome_policy_list.html" type="doc" lang="pl" />
- <output filename="app/policy/common/html/pt-BR/chrome_policy_list.html" type="doc" lang="pt-BR" />
- <output filename="app/policy/common/html/pt-PT/chrome_policy_list.html" type="doc" lang="pt-PT" />
- <output filename="app/policy/common/html/ro/chrome_policy_list.html" type="doc" lang="ro" />
- <output filename="app/policy/common/html/ru/chrome_policy_list.html" type="doc" lang="ru" />
- <output filename="app/policy/common/html/sk/chrome_policy_list.html" type="doc" lang="sk" />
- <output filename="app/policy/common/html/sl/chrome_policy_list.html" type="doc" lang="sl" />
- <output filename="app/policy/common/html/sr/chrome_policy_list.html" type="doc" lang="sr" />
- <output filename="app/policy/common/html/sv/chrome_policy_list.html" type="doc" lang="sv" />
- <output filename="app/policy/common/html/sw/chrome_policy_list.html" type="doc" lang="sw" />
- <output filename="app/policy/common/html/ta/chrome_policy_list.html" type="doc" lang="ta" />
- <output filename="app/policy/common/html/te/chrome_policy_list.html" type="doc" lang="te" />
- <output filename="app/policy/common/html/th/chrome_policy_list.html" type="doc" lang="th" />
- <output filename="app/policy/common/html/tr/chrome_policy_list.html" type="doc" lang="tr" />
- <output filename="app/policy/common/html/uk/chrome_policy_list.html" type="doc" lang="uk" />
- <output filename="app/policy/common/html/vi/chrome_policy_list.html" type="doc" lang="vi" />
- <output filename="app/policy/common/html/zh-CN/chrome_policy_list.html" type="doc" lang="zh-CN" />
- <output filename="app/policy/common/html/zh-TW/chrome_policy_list.html" type="doc" lang="zh-TW" />
+ <output filename="app/policy/linux/examples/chrome.json" type="json" lang="en" />
<if expr="is_win">
<output filename="app/policy/windows/examples/chrome.reg" type="reg" lang="en" />
<output filename="app/policy/windows/admx/chrome.admx" type="admx" lang="en" />
@@ -174,65 +121,62 @@ templates and will be translated for each locale. -->
<output filename="app/policy/windows/adm/zh-CN/chrome.adm" type="adm" lang="zh-CN" />
<output filename="app/policy/windows/adm/zh-TW/chrome.adm" type="adm" lang="zh-TW" />
</if>
- <if expr="is_linux">
- <output filename="app/policy/linux/examples/chrome.json" type="json" lang="en" />
- </if>
- <if expr="is_android">
- <output filename="app/policy/android/values-am-v21/restriction_values.xml" type="android_policy" lang="am" />
- <output filename="app/policy/android/values-ar-v21/restriction_values.xml" type="android_policy" lang="ar" />
- <output filename="app/policy/android/values-bg-v21/restriction_values.xml" type="android_policy" lang="bg" />
- <output filename="app/policy/android/values-bn-v21/restriction_values.xml" type="android_policy" lang="bn" />
- <output filename="app/policy/android/values-ca-v21/restriction_values.xml" type="android_policy" lang="ca" />
- <output filename="app/policy/android/values-cs-v21/restriction_values.xml" type="android_policy" lang="cs" />
- <output filename="app/policy/android/values-da-v21/restriction_values.xml" type="android_policy" lang="da" />
- <output filename="app/policy/android/values-de-v21/restriction_values.xml" type="android_policy" lang="de" />
- <output filename="app/policy/android/values-el-v21/restriction_values.xml" type="android_policy" lang="el" />
- <output filename="app/policy/android/values-en-rGB-v21/restriction_values.xml" type="android_policy" lang="en-GB" />
- <output filename="app/policy/android/values-v21/restriction_values.xml" type="android_policy" lang="en" />
- <output filename="app/policy/android/values-es-rES-v21/restriction_values.xml" type="android_policy" lang="es" />
- <output filename="app/policy/android/values-es-v21/restriction_values.xml" type="android_policy" lang="es-419" />
- <output filename="app/policy/android/values-et-v21/restriction_values.xml" type="android_policy" lang="et" />
- <output filename="app/policy/android/values-fa-v21/restriction_values.xml" type="android_policy" lang="fa" />
- <output filename="app/policy/android/values-fi-v21/restriction_values.xml" type="android_policy" lang="fi" />
- <output filename="app/policy/android/values-fil-v21/restriction_values.xml" type="android_policy" lang="fil" />
- <output filename="app/policy/android/values-fr-v21/restriction_values.xml" type="android_policy" lang="fr" />
- <output filename="app/policy/android/values-gu-v21/restriction_values.xml" type="android_policy" lang="gu" />
- <output filename="app/policy/android/values-he-v21/restriction_values.xml" type="android_policy" lang="he" />
- <output filename="app/policy/android/values-hi-v21/restriction_values.xml" type="android_policy" lang="hi" />
- <output filename="app/policy/android/values-hr-v21/restriction_values.xml" type="android_policy" lang="hr" />
- <output filename="app/policy/android/values-hu-v21/restriction_values.xml" type="android_policy" lang="hu" />
- <output filename="app/policy/android/values-id-v21/restriction_values.xml" type="android_policy" lang="id" />
- <output filename="app/policy/android/values-it-v21/restriction_values.xml" type="android_policy" lang="it" />
- <output filename="app/policy/android/values-ja-v21/restriction_values.xml" type="android_policy" lang="ja" />
- <output filename="app/policy/android/values-kn-v21/restriction_values.xml" type="android_policy" lang="kn" />
- <output filename="app/policy/android/values-ko-v21/restriction_values.xml" type="android_policy" lang="ko" />
- <output filename="app/policy/android/values-lt-v21/restriction_values.xml" type="android_policy" lang="lt" />
- <output filename="app/policy/android/values-lv-v21/restriction_values.xml" type="android_policy" lang="lv" />
- <output filename="app/policy/android/values-ml-v21/restriction_values.xml" type="android_policy" lang="ml" />
- <output filename="app/policy/android/values-mr-v21/restriction_values.xml" type="android_policy" lang="mr" />
- <output filename="app/policy/android/values-ms-v21/restriction_values.xml" type="android_policy" lang="ms" />
- <output filename="app/policy/android/values-nl-v21/restriction_values.xml" type="android_policy" lang="nl" />
- <output filename="app/policy/android/values-nb-v21/restriction_values.xml" type="android_policy" lang="no" />
- <!-- 'no' for Norwegian Bokmål. It should be 'nb'. -->
- <output filename="app/policy/android/values-pl-v21/restriction_values.xml" type="android_policy" lang="pl" />
- <output filename="app/policy/android/values-pt-rBR-v21/restriction_values.xml" type="android_policy" lang="pt-BR" />
- <output filename="app/policy/android/values-pt-rPT-v21/restriction_values.xml" type="android_policy" lang="pt-PT" />
- <output filename="app/policy/android/values-ro-v21/restriction_values.xml" type="android_policy" lang="ro" />
- <output filename="app/policy/android/values-ru-v21/restriction_values.xml" type="android_policy" lang="ru" />
- <output filename="app/policy/android/values-sk-v21/restriction_values.xml" type="android_policy" lang="sk" />
- <output filename="app/policy/android/values-sl-v21/restriction_values.xml" type="android_policy" lang="sl" />
- <output filename="app/policy/android/values-sr-v21/restriction_values.xml" type="android_policy" lang="sr" />
- <output filename="app/policy/android/values-sv-v21/restriction_values.xml" type="android_policy" lang="sv" />
- <output filename="app/policy/android/values-sw-v21/restriction_values.xml" type="android_policy" lang="sw" />
- <output filename="app/policy/android/values-ta-v21/restriction_values.xml" type="android_policy" lang="ta" />
- <output filename="app/policy/android/values-te-v21/restriction_values.xml" type="android_policy" lang="te" />
- <output filename="app/policy/android/values-th-v21/restriction_values.xml" type="android_policy" lang="th" />
- <output filename="app/policy/android/values-tr-v21/restriction_values.xml" type="android_policy" lang="tr" />
- <output filename="app/policy/android/values-uk-v21/restriction_values.xml" type="android_policy" lang="uk" />
- <output filename="app/policy/android/values-vi-v21/restriction_values.xml" type="android_policy" lang="vi" />
- <output filename="app/policy/android/values-zh-rCN-v21/restriction_values.xml" type="android_policy" lang="zh-CN" />
- <output filename="app/policy/android/values-zh-rTW-v21/restriction_values.xml" type="android_policy" lang="zh-TW" />
- </if>
+
+ <output filename="app/policy/common/html/am/chrome_policy_list.html" type="doc" lang="am" />
+ <output filename="app/policy/common/html/ar/chrome_policy_list.html" type="doc" lang="ar" />
+ <output filename="app/policy/common/html/bg/chrome_policy_list.html" type="doc" lang="bg" />
+ <output filename="app/policy/common/html/bn/chrome_policy_list.html" type="doc" lang="bn" />
+ <output filename="app/policy/common/html/ca/chrome_policy_list.html" type="doc" lang="ca" />
+ <output filename="app/policy/common/html/cs/chrome_policy_list.html" type="doc" lang="cs" />
+ <output filename="app/policy/common/html/da/chrome_policy_list.html" type="doc" lang="da" />
+ <output filename="app/policy/common/html/de/chrome_policy_list.html" type="doc" lang="de" />
+ <output filename="app/policy/common/html/el/chrome_policy_list.html" type="doc" lang="el" />
+ <output filename="app/policy/common/html/en-GB/chrome_policy_list.html" type="doc" lang="en-GB" />
+ <output filename="app/policy/common/html/en-US/chrome_policy_list.html" type="doc" lang="en" />
+ <output filename="app/policy/common/html/es/chrome_policy_list.html" type="doc" lang="es" />
+ <output filename="app/policy/common/html/es-419/chrome_policy_list.html" type="doc" lang="es-419" />
+ <output filename="app/policy/common/html/et/chrome_policy_list.html" type="doc" lang="et" />
+ <output filename="app/policy/common/html/fa/chrome_policy_list.html" type="doc" lang="fa" />
+ <output filename="app/policy/common/html/fi/chrome_policy_list.html" type="doc" lang="fi" />
+ <output filename="app/policy/common/html/fil/chrome_policy_list.html" type="doc" lang="fil" />
+ <output filename="app/policy/common/html/fr/chrome_policy_list.html" type="doc" lang="fr" />
+ <output filename="app/policy/common/html/gu/chrome_policy_list.html" type="doc" lang="gu" />
+ <output filename="app/policy/common/html/he/chrome_policy_list.html" type="doc" lang="he" />
+ <output filename="app/policy/common/html/hi/chrome_policy_list.html" type="doc" lang="hi" />
+ <output filename="app/policy/common/html/hr/chrome_policy_list.html" type="doc" lang="hr" />
+ <output filename="app/policy/common/html/hu/chrome_policy_list.html" type="doc" lang="hu" />
+ <output filename="app/policy/common/html/id/chrome_policy_list.html" type="doc" lang="id" />
+ <output filename="app/policy/common/html/it/chrome_policy_list.html" type="doc" lang="it" />
+ <output filename="app/policy/common/html/ja/chrome_policy_list.html" type="doc" lang="ja" />
+ <output filename="app/policy/common/html/kn/chrome_policy_list.html" type="doc" lang="kn" />
+ <output filename="app/policy/common/html/ko/chrome_policy_list.html" type="doc" lang="ko" />
+ <output filename="app/policy/common/html/lt/chrome_policy_list.html" type="doc" lang="lt" />
+ <output filename="app/policy/common/html/lv/chrome_policy_list.html" type="doc" lang="lv" />
+ <output filename="app/policy/common/html/ml/chrome_policy_list.html" type="doc" lang="ml" />
+ <output filename="app/policy/common/html/mr/chrome_policy_list.html" type="doc" lang="mr" />
+ <output filename="app/policy/common/html/ms/chrome_policy_list.html" type="doc" lang="ms" />
+ <output filename="app/policy/common/html/nl/chrome_policy_list.html" type="doc" lang="nl" />
+ <output filename="app/policy/common/html/nb/chrome_policy_list.html" type="doc" lang="no" />
+ <!-- 'no' for Norwegian Bokmål. It should be 'nb'. -->
+ <output filename="app/policy/common/html/pl/chrome_policy_list.html" type="doc" lang="pl" />
+ <output filename="app/policy/common/html/pt-BR/chrome_policy_list.html" type="doc" lang="pt-BR" />
+ <output filename="app/policy/common/html/pt-PT/chrome_policy_list.html" type="doc" lang="pt-PT" />
+ <output filename="app/policy/common/html/ro/chrome_policy_list.html" type="doc" lang="ro" />
+ <output filename="app/policy/common/html/ru/chrome_policy_list.html" type="doc" lang="ru" />
+ <output filename="app/policy/common/html/sk/chrome_policy_list.html" type="doc" lang="sk" />
+ <output filename="app/policy/common/html/sl/chrome_policy_list.html" type="doc" lang="sl" />
+ <output filename="app/policy/common/html/sr/chrome_policy_list.html" type="doc" lang="sr" />
+ <output filename="app/policy/common/html/sv/chrome_policy_list.html" type="doc" lang="sv" />
+ <output filename="app/policy/common/html/sw/chrome_policy_list.html" type="doc" lang="sw" />
+ <output filename="app/policy/common/html/ta/chrome_policy_list.html" type="doc" lang="ta" />
+ <output filename="app/policy/common/html/te/chrome_policy_list.html" type="doc" lang="te" />
+ <output filename="app/policy/common/html/th/chrome_policy_list.html" type="doc" lang="th" />
+ <output filename="app/policy/common/html/tr/chrome_policy_list.html" type="doc" lang="tr" />
+ <output filename="app/policy/common/html/uk/chrome_policy_list.html" type="doc" lang="uk" />
+ <output filename="app/policy/common/html/vi/chrome_policy_list.html" type="doc" lang="vi" />
+ <output filename="app/policy/common/html/zh-CN/chrome_policy_list.html" type="doc" lang="zh-CN" />
+ <output filename="app/policy/common/html/zh-TW/chrome_policy_list.html" type="doc" lang="zh-TW" />
+
<if expr="is_macosx">
<output filename="app/policy/mac/app-Manifest.plist" type="plist" lang="en" />
@@ -295,7 +239,8 @@ templates and will be translated for each locale. -->
<!-- Generate the sample iOS plist when building the templates for the Mac. -->
<output filename="app/policy/ios/chrome_policy.plist" type="ios_plist" lang="en" />
- </if>
+ </if>
+
</outputs>
<translations>
<file path="policy_templates_am.xtb" lang="am" />
diff --git a/components/policy/resources/policy_templates.json b/components/policy/resources/policy_templates.json
index 2c91318..da5c833 100644
--- a/components/policy/resources/policy_templates.json
+++ b/components/policy/resources/policy_templates.json
@@ -7297,10 +7297,6 @@
'desc': '''Caption text of the field 'mac/linux preference name' in the summary chart of a policy in the generated documentation''',
'text': '''Mac/Linux preference name:'''
},
- 'doc_android_restriction_name': {
- 'desc': '''Caption text of the field 'android restriction name' in the summary chart of a policy in the generated documentation''',
- 'text': '''Android restriction name:'''
- },
'doc_supported_on': {
'desc': '''Caption text of the list of 'products, platforms and versions where this policy is supported' in the summary chart of a policy in the generated documentation''',
'text': '''Supported on:'''
diff --git a/components/policy/tools/generate_policy_source.py b/components/policy/tools/generate_policy_source.py
index b3a723b..e343e33 100755
--- a/components/policy/tools/generate_policy_source.py
+++ b/components/policy/tools/generate_policy_source.py
@@ -28,33 +28,34 @@ CHROMIUM_POLICY_KEY = 'SOFTWARE\\\\Policies\\\\Chromium'
class PolicyDetails:
"""Parses a policy template and caches all its details."""
- # Maps policy types to a tuple with 4 other types:
+ # Maps policy types to a tuple with 5 other types:
# - the equivalent base::Value::Type or 'TYPE_EXTERNAL' if the policy
# references external data
# - the equivalent Protobuf field type
# - the name of one of the protobufs for shared policy types
# - the equivalent type in Android's App Restriction Schema
+ # - whether the equivalent app restriction type needs supporting resources
# TODO(joaodasilva): refactor the 'dict' type into a more generic 'json' type
# that can also be used to represent lists of other JSON objects.
TYPE_MAP = {
'dict': ('TYPE_DICTIONARY', 'string', 'String',
- 'string'),
+ 'string', False),
'external': ('TYPE_EXTERNAL', 'string', 'String',
- 'invalid'),
+ 'invalid', False),
'int': ('TYPE_INTEGER', 'int64', 'Integer',
- 'integer'),
+ 'integer', False),
'int-enum': ('TYPE_INTEGER', 'int64', 'Integer',
- 'choice'),
+ 'choice', True),
'list': ('TYPE_LIST', 'StringList', 'StringList',
- 'string'),
+ 'string', False),
'main': ('TYPE_BOOLEAN', 'bool', 'Boolean',
- 'bool'),
+ 'bool', False),
'string': ('TYPE_STRING', 'string', 'String',
- 'string'),
+ 'string', False),
'string-enum': ('TYPE_STRING', 'string', 'String',
- 'choice'),
+ 'choice', True),
'string-enum-list': ('TYPE_LIST', 'StringList', 'StringList',
- 'multi-select'),
+ 'multi-select', True),
}
class EnumItem:
@@ -97,7 +98,8 @@ class PolicyDetails:
raise NotImplementedError('Unknown policy type for %s: %s' %
(policy['name'], policy['type']))
self.policy_type, self.protobuf_type, self.policy_protobuf_type, \
- self.restriction_type = PolicyDetails.TYPE_MAP[policy['type']]
+ self.restriction_type, self.has_restriction_resources = \
+ PolicyDetails.TYPE_MAP[policy['type']]
self.schema = policy['schema']
self.desc = '\n'.join(
@@ -152,6 +154,12 @@ def main():
help='generate an XML file as specified by '
'Android\'s App Restriction Schema',
metavar='FILE')
+ parser.add_option('--arr', '--app-restrictions-resources',
+ dest='app_resources_path',
+ help='generate an XML file with resources supporting the '
+ 'restrictions defined in --app-restrictions-definition '
+ 'parameter',
+ metavar='FILE')
(opts, args) = parser.parse_args()
@@ -183,6 +191,7 @@ def main():
if os == 'android':
GenerateFile(opts.app_restrictions_path, _WriteAppRestrictions, xml=True)
+ GenerateFile(opts.app_resources_path, _WriteResourcesForPolicies, xml=True)
return 0
@@ -998,6 +1007,14 @@ def _WriteCloudPolicyDecoder(policies, os, f):
f.write(CPP_FOOT)
+def _EscapeResourceString(raw_resource):
+ if type(raw_resource) == int:
+ return raw_resource
+ return xml_escape(raw_resource)\
+ .replace('\\', '\\\\')\
+ .replace('\"','\\\"')\
+ .replace('\'','\\\'')
+
def _WriteAppRestrictions(policies, os, f):
def WriteRestrictionCommon(key):
@@ -1014,7 +1031,7 @@ def _WriteAppRestrictions(policies, os, f):
policy_name = policy.name
WriteRestrictionCommon(policy_name)
- if policy.items is not None:
+ if policy.has_restriction_resources:
WriteItemsDefinition(policy_name)
f.write(' android:restrictionType="%s"/>' % policy.restriction_type)
@@ -1028,5 +1045,44 @@ def _WriteAppRestrictions(policies, os, f):
WriteAppRestriction(policy)
f.write('</restrictions>')
+
+def _WriteResourcesForPolicies(policies, os, f):
+
+ # TODO(knn): Update this to support i18n.
+ def WriteString(key, value):
+ f.write(' <string name="%s">%s</string>\n'
+ % (key, _EscapeResourceString(value)))
+
+ def WriteItems(key, items):
+ if items:
+ f.write(' <string-array name="%sEntries">\n' % key)
+ for item in items:
+ f.write(' <item>%s</item>\n' %
+ _EscapeResourceString(item.caption))
+ f.write(' </string-array>\n')
+ f.write(' <string-array name="%sValues">\n' % key)
+ for item in items:
+ f.write(' <item>%s</item>\n' % _EscapeResourceString(item.value))
+ f.write(' </string-array>\n')
+
+ def WriteResourceForPolicy(policy):
+ policy_name = policy.name
+ WriteString(policy_name + 'Title', policy.caption)
+
+ # Get the first line of the policy description.
+ description = policy.desc.split('\n', 1)[0]
+ WriteString(policy_name + 'Desc', description)
+
+ if policy.has_restriction_resources:
+ WriteItems(policy_name, policy.items)
+
+ # _WriteResourcesForPolicies body
+ f.write('<resources>\n\n')
+ for policy in policies:
+ if policy.is_supported and policy.restriction_type != 'invalid':
+ WriteResourceForPolicy(policy)
+ f.write('</resources>')
+
+
if __name__ == '__main__':
sys.exit(main())