summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 09:28:26 +0000
committergfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 09:28:26 +0000
commit79ba804db1fbb75fd681e4227bda486a0d636f3c (patch)
treedeae1709f9f6989bd67352cc4853f12e88f66271
parent45b49a8073a3634fcbca08ed29f4feefb1d794e6 (diff)
downloadchromium_src-79ba804db1fbb75fd681e4227bda486a0d636f3c.zip
chromium_src-79ba804db1fbb75fd681e4227bda486a0d636f3c.tar.gz
chromium_src-79ba804db1fbb75fd681e4227bda486a0d636f3c.tar.bz2
Add list support to the policy template generator and prepare for Mac output
Refactor the policy template generator in preparation for the Mac manifest and Windows ADMX output files. Replace dictionaries with lists in the input JSON file so that sequence of elements is preserved. Add a list data type for policies, and add extension whitelist/blacklist policy. Split homepage policy group into two. Previous CL: http://codereview.chromium.org/3068012/show. BUG=49316 TEST=tools/grit/grit/format/policy_templates/policy_template_generator.py and manual testing of output .adm files Review URL: http://codereview.chromium.org/3191021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57160 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/policy/policy_templates.grd263
-rw-r--r--chrome/app/policy/policy_templates.json223
-rw-r--r--tools/grit/grit/format/policy_templates/policy_template_generator.py108
-rw-r--r--tools/grit/grit/format/policy_templates/policy_template_generator_unittest.py143
-rw-r--r--tools/grit/grit/format/policy_templates/template_formatter.py24
-rw-r--r--tools/grit/grit/format/policy_templates/writers/adm_writer.py58
-rw-r--r--tools/grit/grit/format/policy_templates/writers/mock_writer.py4
-rw-r--r--tools/grit/grit/format/policy_templates/writers/template_writer.py25
-rw-r--r--tools/grit/grit/format/policy_templates/writers/xml_formatted_writer.py40
9 files changed, 587 insertions, 301 deletions
diff --git a/chrome/app/policy/policy_templates.grd b/chrome/app/policy/policy_templates.grd
index f9086d2..ba69bff 100644
--- a/chrome/app/policy/policy_templates.grd
+++ b/chrome/app/policy/policy_templates.grd
@@ -6,128 +6,236 @@ 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>
- <!-- TODO(gfeher) set output basedir to chrome/app/policy instead of the
- current Debug/obj/global_intermediate/chrome/app/policy
- -->
- <output filename="./app/policy/windows/adm/en-US/chrome.adm" type="adm" lang="en" />
- <output filename="./app/policy/windows/adm/de/chrome.adm" type="adm" lang="de" />
- <output filename="./app/policy/windows/adm/hu/chrome.adm" type="adm" lang="hu" />
+ <output filename="app/policy/windows/adm/am/chrome.adm" type="adm" lang="am" />
+ <output filename="app/policy/windows/adm/ar/chrome.adm" type="adm" lang="ar" />
+ <output filename="app/policy/windows/adm/bg/chrome.adm" type="adm" lang="bg" />
+ <output filename="app/policy/windows/adm/bn/chrome.adm" type="adm" lang="bn" />
+ <output filename="app/policy/windows/adm/ca/chrome.adm" type="adm" lang="ca" />
+ <output filename="app/policy/windows/adm/cs/chrome.adm" type="adm" lang="cs" />
+ <output filename="app/policy/windows/adm/da/chrome.adm" type="adm" lang="da" />
+ <output filename="app/policy/windows/adm/de/chrome.adm" type="adm" lang="de" />
+ <output filename="app/policy/windows/adm/el/chrome.adm" type="adm" lang="el" />
+ <output filename="app/policy/windows/adm/en-GB/chrome.adm" type="adm" lang="en-GB" />
+ <output filename="app/policy/windows/adm/en-US/chrome.adm" type="adm" lang="en" />
+ <output filename="app/policy/windows/adm/es/chrome.adm" type="adm" lang="es" />
+ <output filename="app/policy/windows/adm/es-419/chrome.adm" type="adm" lang="es-419" />
+ <output filename="app/policy/windows/adm/et/chrome.adm" type="adm" lang="et" />
+ <output filename="app/policy/windows/adm/fi/chrome.adm" type="adm" lang="fi" />
+ <output filename="app/policy/windows/adm/fil/chrome.adm" type="adm" lang="fil" />
+ <output filename="app/policy/windows/adm/fr/chrome.adm" type="adm" lang="fr" />
+ <output filename="app/policy/windows/adm/gu/chrome.adm" type="adm" lang="gu" />
+ <output filename="app/policy/windows/adm/he/chrome.adm" type="adm" lang="he" />
+ <output filename="app/policy/windows/adm/hi/chrome.adm" type="adm" lang="hi" />
+ <output filename="app/policy/windows/adm/hr/chrome.adm" type="adm" lang="hr" />
+ <output filename="app/policy/windows/adm/hu/chrome.adm" type="adm" lang="hu" />
+ <output filename="app/policy/windows/adm/id/chrome.adm" type="adm" lang="id" />
+ <output filename="app/policy/windows/adm/it/chrome.adm" type="adm" lang="it" />
+ <output filename="app/policy/windows/adm/ja/chrome.adm" type="adm" lang="ja" />
+ <output filename="app/policy/windows/adm/kn/chrome.adm" type="adm" lang="kn" />
+ <output filename="app/policy/windows/adm/ko/chrome.adm" type="adm" lang="ko" />
+ <output filename="app/policy/windows/adm/lt/chrome.adm" type="adm" lang="lt" />
+ <output filename="app/policy/windows/adm/lv/chrome.adm" type="adm" lang="lv" />
+ <output filename="app/policy/windows/adm/ml/chrome.adm" type="adm" lang="ml" />
+ <output filename="app/policy/windows/adm/mr/chrome.adm" type="adm" lang="mr" />
+ <output filename="app/policy/windows/adm/nl/chrome.adm" type="adm" lang="nl" />
+ <!-- The translation console uses 'no' for Norwegian Bokmål. It should
+ be 'nb'. -->
+ <output filename="app/policy/windows/adm/nb/chrome.adm" type="adm" lang="no" />
+ <output filename="app/policy/windows/adm/pl/chrome.adm" type="adm" lang="pl" />
+ <output filename="app/policy/windows/adm/pt-BR/chrome.adm" type="adm" lang="pt-BR" />
+ <output filename="app/policy/windows/adm/pt-PT/chrome.adm" type="adm" lang="pt-PT" />
+ <output filename="app/policy/windows/adm/ro/chrome.adm" type="adm" lang="ro" />
+ <output filename="app/policy/windows/adm/ru/chrome.adm" type="adm" lang="ru" />
+ <output filename="app/policy/windows/adm/sk/chrome.adm" type="adm" lang="sk" />
+ <output filename="app/policy/windows/adm/sl/chrome.adm" type="adm" lang="sl" />
+ <output filename="app/policy/windows/adm/sr/chrome.adm" type="adm" lang="sr" />
+ <output filename="app/policy/windows/adm/sv/chrome.adm" type="adm" lang="sv" />
+ <output filename="app/policy/windows/adm/sw/chrome.adm" type="adm" lang="sw" />
+ <output filename="app/policy/windows/adm/ta/chrome.adm" type="adm" lang="ta" />
+ <output filename="app/policy/windows/adm/te/chrome.adm" type="adm" lang="te" />
+ <output filename="app/policy/windows/adm/th/chrome.adm" type="adm" lang="th" />
+ <output filename="app/policy/windows/adm/tr/chrome.adm" type="adm" lang="tr" />
+ <output filename="app/policy/windows/adm/uk/chrome.adm" type="adm" lang="uk" />
+ <output filename="app/policy/windows/adm/vi/chrome.adm" type="adm" lang="vi" />
+ <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" />
+
</outputs>
<translations>
- <!-- TODO(gfeher): add target languages here -->
+ <!-- TODO(gfeher): get translations into the following files -->
+<!-- <file path="resources/policy_templates_am.xtb" lang="am" />
+ <file path="resources/policy_templates_ar.xtb" lang="ar" />
+ <file path="resources/policy_templates_bg.xtb" lang="bg" />
+ <file path="resources/policy_templates_bn.xtb" lang="bn" />
+ <file path="resources/policy_templates_ca.xtb" lang="ca" />
+ <file path="resources/policy_templates_cs.xtb" lang="cs" />
+ <file path="resources/policy_templates_da.xtb" lang="da" />
+ <file path="resources/policy_templates_de.xtb" lang="de" />
+ <file path="resources/policy_templates_el.xtb" lang="el" />
+ <file path="resources/policy_templates_en-GB.xtb" lang="en-GB" />
+ <file path="resources/policy_templates_es.xtb" lang="es" />
+ <file path="resources/policy_templates_es-419.xtb" lang="es-419" />
+ <file path="resources/policy_templates_et.xtb" lang="et" />
+ <file path="resources/policy_templates_fi.xtb" lang="fi" />
+ <file path="resources/policy_templates_fil.xtb" lang="fil" />
+ <file path="resources/policy_templates_fr.xtb" lang="fr" />
+ <file path="resources/policy_templates_gu.xtb" lang="gu" />
+ <file path="resources/policy_templates_hi.xtb" lang="hi" />
+ <file path="resources/policy_templates_hr.xtb" lang="hr" />
+ <file path="resources/policy_templates_hu.xtb" lang="hu" />
+ <file path="resources/policy_templates_id.xtb" lang="id" />
+ <file path="resources/policy_templates_it.xtb" lang="it" /> -->
+ <!-- The translation console uses 'iw' for Hebrew, but we use 'he'. -->
+ <!-- <file path="resources/policy_templates_iw.xtb" lang="he" />
+ <file path="resources/policy_templates_ja.xtb" lang="ja" />
+ <file path="resources/policy_templates_kn.xtb" lang="kn" />
+ <file path="resources/policy_templates_ko.xtb" lang="ko" />
+ <file path="resources/policy_templates_lt.xtb" lang="lt" />
+ <file path="resources/policy_templates_lv.xtb" lang="lv" />
+ <file path="resources/policy_templates_ml.xtb" lang="ml" />
+ <file path="resources/policy_templates_mr.xtb" lang="mr" />
+ <file path="resources/policy_templates_nl.xtb" lang="nl" />
+ <file path="resources/policy_templates_no.xtb" lang="no" />
+ <file path="resources/policy_templates_pl.xtb" lang="pl" />
+ <file path="resources/policy_templates_pt-BR.xtb" lang="pt-BR" />
+ <file path="resources/policy_templates_pt-PT.xtb" lang="pt-PT" />
+ <file path="resources/policy_templates_ro.xtb" lang="ro" />
+ <file path="resources/policy_templates_ru.xtb" lang="ru" />
+ <file path="resources/policy_templates_sk.xtb" lang="sk" />
+ <file path="resources/policy_templates_sl.xtb" lang="sl" />
+ <file path="resources/policy_templates_sr.xtb" lang="sr" />
+ <file path="resources/policy_templates_sv.xtb" lang="sv" />
+ <file path="resources/policy_templates_sw.xtb" lang="sw" />
+ <file path="resources/policy_templates_ta.xtb" lang="ta" />
+ <file path="resources/policy_templates_te.xtb" lang="te" />
+ <file path="resources/policy_templates_th.xtb" lang="th" />
+ <file path="resources/policy_templates_tr.xtb" lang="tr" />
+ <file path="resources/policy_templates_uk.xtb" lang="uk" />
+ <file path="resources/policy_templates_vi.xtb" lang="vi" />
+ <file path="resources/policy_templates_zh-CN.xtb" lang="zh-CN" />
+ <file path="resources/policy_templates_zh-TW.xtb" lang="zh-TW" /> -->
</translations>
<!-- TODO(gfeher): set allow_pseudo="false" before release -->
<release seq="1" allow_pseudo="true">
<messages fallback_to_english="false">
- <!-- Strings for ADM/ADMX/MCX policy templates -->
- <!-- TODO(gfeher): new wording of these messages might become necessary when
- MCX/HTML output is introduced -->
- <message name="IDS_POLICY_GROUP_HOMEPAGE_CAPTION" desc="Caption of the 'homepage' policy settings page.">
- Configure default homepage
- </message>
- <message name="IDS_POLICY_GROUP_HOMEPAGE_DESC" desc="Description of the 'homepage' policy settings page.">
- Configures the default home page in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing homepage preferences.
-
- The homepage can either be set to a URL you specify or set to the New Tab Page.
-
- If you specify the New Tab Page as the homepage, the homepage URL location is ignored.
-
- If you enable this setting, users cannot change their homepage settings in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
+ <!-- Strings for ADM/ADMX/MCX policy templates -->
+
+ <message name="IDS_POLICY_GROUP_HOMEPAGELOCATION_DESC" desc="Description of the 'homepage' policy settings page.">
+ Configures the default homepage URL in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing it.
+
+ The homepage type can either be set to a URL you specify here or set to the New Tab Page.
+
+ If you specify the New Tab Page as the homepage type, then this policy is ignored.
+
+ If you enable this setting, users cannot change their homepage URL in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>, but they still can choose the New Tab Page as their homepage.
</message>
- <message name="IDS_POLICY_HOMEPAGELOCATION_CAPTION" desc="Caption of the homepage URL text field in the homepage policy settings page.">
- The homepage URL:
+ <message name="IDS_POLICY_GROUP_HOMEPAGELOCATION_CAPTION" desc="Caption of the homepage URL text field in the homepage policy settings page.">
+ Configure the homepage URL
</message>
- <message name="IDS_POLICY_HOMEPAGEISNEWTABPAGE_CAPTION" desc="Caption of the homepage type selection dropdown menu in the homepage policy settings page.">
- Homepage type:
+ <message name="IDS_POLICY_HOMEPAGELOCATION_CAPTION" desc="Caption of the homepage URL text field in the homepage policy settings page.">
+ Homepage URL
</message>
- <message name="IDS_POLICY_ENUM_HOMEPAGEISNEWTABPAGE_CAPTION" desc="Label in the 'Homepage type' dropdown menu for selecting new tab page.">
- Always use New Tab Page as homepage
+ <message name="IDS_POLICY_GROUP_HOMEPAGEISNEWTABPAGE_DESC" desc="Description of the 'Use New Tab Page as homepage' policy settings page.">
+ Configures the type of the default home page in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing homepage preferences. The homepage can either be set to a URL you specify or set to the New Tab Page.
+
+ If you enable this setting, always the New Tab Page is used for the homepage, and the homepage URL location is ignored.
+
+ If you disable this setting, the user's homepage will never be the New Tab Page, unless its URL is set to 'chrome://newtab'.
+
+ If you enable or disable this setting, users cannot change their homepage type in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
- <message name="IDS_POLICY_ENUM_HOMEPAGEISLOCATIONURL_CAPTION" desc="Label in the 'Homepage type' dropdown menu for selecting an URL.">
- Always use homepage URL as homepage
+ <message name="IDS_POLICY_GROUP_HOMEPAGEISNEWTABPAGE_CAPTION" desc="Caption of the 'homepage type' selection dropdown menu in the 'homepage type' policy settings page.">
+ Use New Tab Page as homepage
</message>
+
<message name="IDS_POLICY_GROUP_APPLICATIONLOCALE_CAPTION" desc="Caption of the 'application locale' policy settings page.">
Configure the application locale
</message>
<message name="IDS_POLICY_GROUP_APPLICATIONLOCALE_DESC" desc="Description of the 'application locale' policy settings page.">
Configures the application locale in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing the locale.
-
+
If you enable this setting, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> uses the specified locale. If the configured locale is not supported, 'en-US' is used instead.
-
+
If this setting is disabled or not configured, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> uses either the user-specified preferred locale (if configured), the system locale or the fallback locale 'en-US'.
</message>
<message name="IDS_POLICY_APPLICATIONLOCALEVALUE_CAPTION" desc="Caption of the 'application locale' text field in the 'application locale' policy settings page.">
- Application locale:
+ Application locale
</message>
+
<message name="IDS_POLICY_GROUP_ALTERNATEERRORPAGESENABLED_CAPTION" desc="Caption of the 'alternate error pages' policy settings page.">
Enable alternate error pages
</message>
<message name="IDS_POLICY_GROUP_ALTERNATEERRORPAGESENABLED_DESC" desc="Description of the 'alternate error pages' policy settings page.">
Enables the use of alternate error pages that are built into <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> (such as 'page not found') and prevents users from changing this setting.
-
+
If you enable this setting, alternate error pages are used.
-
+
If you disable this setting, alternate error pages are never used.
-
+
If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_SEARCHSUGGESTENABLED_CAPTION" desc="Caption of the 'search suggestions' policy settings page.">
Enable search suggestions
</message>
<message name="IDS_POLICY_GROUP_SEARCHSUGGESTENABLED_DESC" desc="Description of the 'search suggestions' policy settings page.">
Enables search suggestions in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>'s Omnibox and prevents users from changing this setting.
-
+
If you enable this setting, search suggestions are used.
-
+
If you disable this setting, search suggestions are never used.
-
+
If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_DNSPREFETCHINGENABLED_CAPTION" desc="Caption of the 'DNS prefetching' policy settings page.">
Enable DNS prefetching
</message>
<message name="IDS_POLICY_GROUP_DNSPREFETCHINGENABLED_DESC" desc="Description of the 'DNS prefetching' policy settings page.">
- Enables DNS prefecthing in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing this setting.
-
+ Enables DNS prefetching in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing this setting.
+
If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_SAFEBROWSINGENABLED_CAPTION" desc="Caption of the 'safe browsing' policy settings page.">
Enable Safe Browsing
</message>
<message name="IDS_POLICY_GROUP_SAFEBROWSINGENABLED_DESC" desc="Description of the 'safe browsing' policy settings page.">
Enables <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>'s Safe Browsing feature and prevents users from changing this setting.
-
+
If you enable this setting, Safe Browsing is always active.
-
+
If you disable this setting, Safe Browsing is never active.
-
+
If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_SYNCDISABLED_CAPTION" desc="Caption of the 'disable sync' policy settings page.">
Disallow synchronization of data with Google
</message>
<message name="IDS_POLICY_GROUP_SYNCDISABLED_DESC" desc="Description of the 'disable sync' policy settings page.">
Disallows data synchronization in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> using Google-hosted synchronization services and prevents users from changing this setting.
-
+
If you enable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_PROXY_CAPTION" desc="Caption of the 'proxy' policy settings page.">
Configure proxy server
</message>
<message name="IDS_POLICY_GROUP_PROXY_DESC" desc="Description of the 'proxy' policy settings page.">
Allows you to specify the proxy server used by <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing proxy settings.
-
+
If you choose to never use a proxy server and always connect directly, all other options are ignored.
-
+
If you choose to auto detect the proxy server, all other options are ignored.
-
+
For detailed examples, visit:
http://www.chromium.org/developers/design-documents/network-settings#TOC-Command-line-options-for-proxy-sett
-
+
If you enable this setting, <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> ignores all proxy-related options specified from the command line.
</message>
<message name="IDS_POLICY_PROXYSERVERMODE_CAPTION" desc="Text describing the dropdown menu for selecting proxy server mode in the 'proxy' policy settings page.">
- Choose how to specify proxy server settings:
+ Choose how to specify proxy server settings
</message>
<message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION" desc="Label in the 'proxy server mode' dropdown menu for selecting no proxy server.">
Never use a proxy
@@ -142,48 +250,81 @@ templates and will be translated for each locale. -->
Use system proxy settings
</message>
<message name="IDS_POLICY_PROXYSERVER_CAPTION" desc="The label of the 'proxy server address' text field in the 'proxy' policy settings page.">
- Address or URL of proxy server:
+ Address or URL of proxy server
</message>
<message name="IDS_POLICY_PROXYBYPASSLIST_CAPTION" desc="The label of the 'proxy bypass rules' text field in the 'proxy' policy settings page.">
- Comma-separated list of bypass rules:
+ Comma-separated list of proxy bypass rules
</message>
<message name="IDS_POLICY_PROXYPACURL_CAPTION" desc="The label of the 'proxy pac URL' text field in the 'proxy' policy settings page.">
- URL to a proxy .pac file:
+ URL to a proxy .pac file
</message>
+
<message name="IDS_POLICY_GROUP_METRICSREPORTINGENABLED_CAPTION" desc="Caption of the 'crash reporting' policy settings page.">
Enable reporting of usage and crash-related data
</message>
<message name="IDS_POLICY_GROUP_METRICSREPORTINGENABLED_DESC" desc="Description of the 'crash reporting' policy settings page.">
Enables anonymous reporting of usage and crash-related data about <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> to Google and prevents users from changing this setting.
-
+
If you enable this setting, anonymous reporting of usage and crash-related data is sent to Google.
-
+
If you disable this setting, anonymous reporting of usage and crash-related data is never sent to Google.
-
+
If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_PASSWORDMANAGERENABLED_CAPTION" desc="Caption of the 'password manager' policy settings page.">
Enable the password manager
</message>
<message name="IDS_POLICY_GROUP_PASSWORDMANAGERENABLED_DESC" desc="Description of the 'password manager' policy settings page.">
Enables saving passwords and using saved passwords in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
-
+
If you enable this setting, users can have <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> memorize passwords and provide them automatically the next time you log into a site.
-
+
If you disable this setting, users are not able to save passwords or use already saved passwords.
-
+
If you enable or disable this setting, users cannot change or override this setting in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
</message>
+
<message name="IDS_POLICY_GROUP_DISABLEDPLUGINS_CAPTION" desc="Caption of the 'disable plugins' policy settings page.">
Specify a list of plugins that are disabled
</message>
<message name="IDS_POLICY_GROUP_DISABLEDPLUGINS_DESC" desc="Description of the 'disable plugins' policy settings page.">
Specifies a list of plugins that are disabled in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing this setting. The value is a comma-separated list of the names of plugins to be disabled.
-
+
If you enable this setting, the specified list of plugins is never used in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>. The plugins are marked as disabled in 'about:plugins' and users are not able to enable them.
</message>
- <message name="IDS_POLICY_DISABLEDPLUGINSLIST_CAPTION" desc="The label of the 'list of disabled plugins' text field in the 'disabled plugins' policy settings page.">
- Comma-separated list of disabled plugins:
+ <message name="IDS_POLICY_DISABLEDPLUGINSLIST_CAPTION" desc="Label of the 'list of disabled plugins' text field in the 'disabled plugins' policy settings page.">
+ Comma-separated list of disabled plugins
+ </message>
+
+ <message name="IDS_POLICY_GROUP_EXTENSIONINSTALLBLACKLIST_CAPTION" desc="Caption of the 'extension blacklist' policy settings page.">
+ Configure extension installation blacklist
+ </message>
+ <message name="IDS_POLICY_EXTENSIONINSTALLBLACKLIST_CAPTION" desc="Label of the 'blacklisted extensions' list editor view in the 'extension blacklist' policy settings page.">
+ Extension IDs the user should be prevented from installing (or * for all)
+ </message>
+ <message name="IDS_POLICY_GROUP_EXTENSIONINSTALLBLACKLIST_DESC" desc="Description of the 'extension blacklist' policy settings page.">
+ Allows you to specify which extensions the users can NOT install.
+
+ A blacklist value of * means all extensions are blacklisted and users will only be able to install extensions listed in the whitelist.
+ </message>
+
+ <message name="IDS_POLICY_GROUP_EXTENSIONINSTALLWHITELIST_CAPTION" desc="Caption of the 'extension whitelist' policy settings page.">
+ Configure extension installation whitelist
+ </message>
+ <message name="IDS_POLICY_EXTENSIONINSTALLWHITELIST_CAPTION" desc="Label of the 'whitelisted extensions' list editor view in the 'extension whitelist' policy settings page.">
+ Extension IDs to exempt from the blacklist
+ </message>
+ <message name="IDS_POLICY_GROUP_EXTENSIONINSTALLWHITELIST_DESC" desc="Description of the 'extension whitelist' policy settings page.">
+ Allows you to specify which extensions are not subject to the blacklist.
+
+ A blacklist value of * means all extensions are blacklisted and users will only be able to install extensions listed in the whitelist.
+
+ By default, all extensions are whitelisted, but if all extensions have been blacklisted by policy, the whitelist can be used to override that policy.
+ </message>
+
+ <message name="IDS_POLICY_WIN_SUPPORTED_WINXPSP2" desc="A label specifying the oldest possible compatible version of Windows. This text will appear right next to a label containing the text 'Supported on:'.">
+ At least Microsoft Windows XP SP2
</message>
</messages>
diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json
index 7571abe..fa5190f 100644
--- a/chrome/app/policy/policy_templates.json
+++ b/chrome/app/policy/policy_templates.json
@@ -1,9 +1,12 @@
-{
+[
# policy_templates.json - Metafile for policy templates
#
# This file is used as input to generate the following policy templates:
# ADM (TODO(gfeher): MCX,ADMX,DOC)
#
+# TODO(gfeher): The format description also mentions Mac support,
+# but that functionality is not committed to the tree yet.
+#
# Policy templates are user interface definitions or documents about the
# policies that can be used to configure Chrome. Each policy is a name-value
# pair where the value has a given type. Chrome looks up the values using the
@@ -23,27 +26,43 @@
# 'enum' - the user can select its value from a collection of items
# 'main' - a boolean value with additional semantics:
# A group can have at most one main policy and it must have a value of true
-# if the policy group is enabled, false if the group is disabled or no value
-# if the policy is not specified. Chrome will see this policy no differently
-# than other policies, but depending on the platform, the GUI of the
-# templates might reflect the fact that these policies are 'main'. For
-# example on Windows this policy will be assigned to the Enable/Disable
+# if the policy group is enabled, false if the group is disabled or no
+# value if the policy is not specified. Chrome will see this policy no
+# differently than other policies, but depending on the platform, the GUI
+# of the templates might reflect the fact that these policies are 'main'.
+# For example on Windows this policy will be assigned to the Enable/Disable
# buttons of the group, and if it is set to Disabled then other policies of
# the group will not be visible to Chrome.
+# 'list' - a list of string values
+# Currently a 'list' policy has to be alone in a group for technical
+# reasons.
+# TODO(gfeher): investigate the possibility of having different KEYNAMEs
+# for different parts of an ADM policy
#
# Policy group descriptions, policy captions and similar texts are localized
# strings taken from the <message> nodes of the .grd file. Their name
# attributes are generated from the JSON keys.
-# Possible locations of localized strings in the templates:
-# Policy groups:
-# They can have both captions and descriptions.
-# Policies:
-# Policies with type 'main':
-# none (inherits them from the policy group)
-# Policies of other types:
-# Captions only.
-# Selectable item in an 'enum'-typed policy:
-# Captions only.
+# Each item (policy or group) may have a caption and/or a description. The
+# exact use of these strings depends on the platform:
+# -On Windows the user sees a list of policy groups from which the pages of
+# groups can be opened, and the values of policies can be edited on those.
+# -Mac does not know about policy groups, the user sees a list of single
+# policies and the values of policies can be edited by clicking on them.
+# The source of the one-line texts that appear in the list of policies/groups:
+# -On Windows the group caption is shown for each group in the list.
+# -On Mac also the group caption is shown by default for each policy. But
+# if a policy caption is specified then it overrides the group caption.
+# (Note that the policy caption can only be omitted for policies of type
+# 'main'.)
+# Descriptions:
+# -On Windows the user sees the group description on the page of each
+# group. In addition to this, the policy caption is shown for each
+# policy on the group page. (Except for 'main' policies, they have no
+# separate captions.)
+# -On Mac the user sees each policy on a separate page. By default the
+# group description is shown here, but if the policy description is
+# specified then it overrides the group caption.
+#
# Generated grd names:
# Each name has two parts: the second part is either CAPTION or DESC,
# and the first part identifies the item the text applies to:
@@ -60,79 +79,125 @@
# e.g. the name of the caption of ProxyServerDisabled:
# IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION
#
-# TODO(gfeher): ADMX, MCX, DOC, .h/.cc? files
-#
- 'Homepage': {
- 'policies': {
- 'HomepageLocation': {'type': 'string'},
- 'HomepageIsNewTabPage': {
- 'type': 'enum',
- 'items': {
- 'HomepageIsLocationURL': {'value': '0'},
- 'HomepageIsNewTabPage': {'value': '1'},
- }
- },
- }
+ # The homepage-related policies are split into two groups, because if they
+ # are in the same group, then Windows does not allow to set them undefined
+ # independently of each other.
+ {
+ 'name': 'HomepageLocation',
+ 'policies': [{
+ 'name': 'HomepageLocation',
+ 'type': 'string',
+ }],
+ },
+ {
+ 'name': 'HomepageIsNewTabPage',
+ 'policies': [{
+ 'name': 'HomepageIsNewTabPage',
+ 'type': 'main',
+ }],
},
- 'ApplicationLocale': {
- 'policies': {
- 'ApplicationLocaleValue': {'type': 'string'},
- }
+ {
+ 'name': 'ApplicationLocale',
+ 'policies': [{
+ 'name': 'ApplicationLocaleValue',
+ 'type': 'string',
+ }]
},
- 'AlternateErrorPagesEnabled': {
- 'policies': {
- 'AlternateErrorPagesEnabled': {'type': 'main'},
- }
+ {
+ 'name': 'AlternateErrorPagesEnabled',
+ 'policies': [{
+ 'name': 'AlternateErrorPagesEnabled',
+ 'type': 'main',
+ }]
},
- 'SearchSuggestEnabled': {
- 'policies': {
- 'SearchSuggestEnabled': {'type': 'main'},
- }
+ {
+ 'name': 'SearchSuggestEnabled',
+ 'policies': [{
+ 'name': 'SearchSuggestEnabled',
+ 'type': 'main'
+ }],
},
- 'DnsPrefetchingEnabled': {
- 'policies': {
- 'DnsPrefetchingEnabled': {'type': 'main'},
- }
+ {
+ 'name': 'DnsPrefetchingEnabled',
+ 'policies': [{
+ 'name': 'DnsPrefetchingEnabled',
+ 'type': 'main'
+ }],
},
- 'SafeBrowsingEnabled': {
- 'policies': {
- 'SafeBrowsingEnabled': {'type': 'main'},
- }
+ {
+ 'name': 'SafeBrowsingEnabled',
+ 'policies': [{
+ 'name': 'SafeBrowsingEnabled',
+ 'type': 'main',
+ }]
},
- 'MetricsReportingEnabled': {
- 'policies': {
- 'MetricsReportingEnabled': {'type': 'main'},
- }
+ {
+ 'name': 'MetricsReportingEnabled',
+ 'policies': [{
+ 'name': 'MetricsReportingEnabled',
+ 'type': 'main'
+ }],
},
- 'PasswordManagerEnabled': {
- 'policies': {
- 'PasswordManagerEnabled': {'type': 'main'},
- }
+ {
+ 'name': 'PasswordManagerEnabled',
+ 'policies': [{
+ 'name': 'PasswordManagerEnabled',
+ 'type': 'main',
+ }]
},
- 'DisabledPlugins': {
- 'policies': {
- 'DisabledPluginsList': {'type': 'string'},
- }
+ {
+ 'name': 'DisabledPlugins',
+ 'policies': [{
+ 'name': 'DisabledPluginsList',
+ 'type': 'string',
+ }]
},
- 'SyncDisabled': {
- 'policies': {
- 'SyncDisabled': {'type': 'main'},
- }
+ {
+ 'name': 'SyncDisabled',
+ 'policies': [{
+ 'name': 'SyncDisabled',
+ 'type': 'main',
+ }]
},
- 'Proxy': {
- 'policies': {
- 'ProxyServerMode': {
+ {
+ 'name': 'Proxy',
+ 'policies': [
+ {
+ 'name': 'ProxyServerMode',
'type': 'enum',
- 'items': {
- 'ProxyServerDisabled': {'value': '0'},
- 'ProxyServerAutoDetect': {'value': '1'},
- 'ProxyServerManual': {'value': '2'},
- 'ProxyServerUseSystem': {'value': '3'},
- }
+ 'items': [
+ {'name': 'ProxyServerDisabled', 'value': '0'},
+ {'name': 'ProxyServerAutoDetect', 'value': '1'},
+ {'name': 'ProxyServerManual', 'value': '2'},
+ {'name': 'ProxyServerUseSystem', 'value': '3'},
+ ],
},
- 'ProxyServer': {'type': 'string'},
- 'ProxyPacUrl': {'type': 'string'},
- 'ProxyBypassList': {'type': 'string'},
- }
+ {
+ 'name': 'ProxyServer',
+ 'type': 'string'
+ },
+ {
+ 'name': 'ProxyPacUrl',
+ 'type': 'string'
+ },
+ {
+ 'name': 'ProxyBypassList',
+ 'type': 'string'
+ },
+ ]
+ },
+ {
+ 'name': 'ExtensionInstallBlacklist',
+ 'policies': [{
+ 'name': 'ExtensionInstallBlacklist',
+ 'type': 'list',
+ }]
+ },
+ {
+ 'name': 'ExtensionInstallWhitelist',
+ 'policies': [{
+ 'name': 'ExtensionInstallWhitelist',
+ 'type': 'list',
+ }]
}
-} \ No newline at end of file
+] \ No newline at end of file
diff --git a/tools/grit/grit/format/policy_templates/policy_template_generator.py b/tools/grit/grit/format/policy_templates/policy_template_generator.py
index efbf769..165cc91 100644
--- a/tools/grit/grit/format/policy_templates/policy_template_generator.py
+++ b/tools/grit/grit/format/policy_templates/policy_template_generator.py
@@ -22,19 +22,20 @@ class PolicyTemplateGenerator:
policy_groups: The policies are organized into groups, and each policy
has a name and type. The user will see a GUI interface for assigning
values to policies, by using the templates generated here. The traversed
- data structure is a dictionary of policy group names to groups. Each
- group is a dictionary and has an embedded dictionary of policies under
- the key 'policies'. Example:
- policy_groups = {
- 'PolicyGroup1': {
- 'policies': {
- 'Policy1Name': {'type': 'string'}
- 'Policy2Name': {'type': 'main'}
- 'Policy3Name': {'type': 'enum', 'items': {...}}
- }
+ data structure is a list of policy groups. Each group is a dictionary
+ and has an embedded list of policies under the key 'policies'.
+ Example:
+ policy_groups = [
+ {
+ 'name': 'PolicyGroup1',
+ 'policies': [
+ {'name': 'Policy1Name', 'type': 'string'}
+ {'name': 'Policy2Name', 'type': 'main'}
+ {'name': 'Policy3Name', 'type': 'enum', 'items': [...]}
+ ]
},
- 'PolicyGroup2': {...}
- }
+ {'name': 'PolicyGroup2', ...}
+ ]
See chrome/app/policy.policy_templates.json for an example and more
details.
'''
@@ -44,54 +45,69 @@ class PolicyTemplateGenerator:
self._messages = messages
self._AddMessagesToPolicies()
- def _AddMessagesToItem(self, item_name, item, warn_no_desc):
+ def _AddMessagesToItem(self, item_name, item, needs_caption, needs_desc):
'''Adds localized message strings to an item of the policy data structure
(self._policy_groups).
Args:
- item_name: The name of the item.
+ item_name: The base of the grd name of the item.
item: The item which will get its message strings now.
- warn_no_desc: A boolean value. If it is True, warnings will be
- printed in case there are no description strings for item in
- self._messages.
+ needs_caption: A boolean value. If it is True, an exception will be raised
+ in case there is no caption string for item in self._messages.
+ needs_desc: A boolean value. If it is True, an exception will be raised
+ in case there is no description string for item in self._messages.
+
+ Raises:
+ Exception() if a required message string was not found.
'''
# The keys for the item's messages in self._messages:
- caption_id = 'IDS_POLICY_%s_CAPTION' % item_name
- desc_id = 'IDS_POLICY_%s_DESC' % item_name
+ caption_name = 'IDS_POLICY_%s_CAPTION' % item_name
+ desc_name = 'IDS_POLICY_%s_DESC' % item_name
# Copy the messages from self._messages to item:
- if caption_id in self._messages:
- item['caption'] = self._messages[caption_id]
+ if caption_name in self._messages:
+ item['caption'] = self._messages[caption_name]
+ elif needs_caption:
+ raise Exception('No localized caption for %s (missing %s).' %
+ (item_name, caption_name))
+ if desc_name in self._messages:
+ item['desc'] = self._messages[desc_name]
+ elif needs_desc:
+ raise Exception('No localized description for %s (missing %s).' %
+ (item_name, desc_name))
+
+ def _AddMessagesToPolicy(self, policy):
+ '''Adds localized message strings to a policy.
+
+ Args:
+ policy: The data structure of the policy that will get message strings
+ here.
+ '''
+ full_name = policy['name'].upper()
+ if policy['type'] == 'main':
+ # In this case, both caption and description are optional.
+ self._AddMessagesToItem(full_name, policy, False, False)
else:
- print 'Warning: no localized message for ' + caption_id
- if desc_id in self._messages:
- item['desc'] = self._messages[desc_id]
- elif warn_no_desc:
- print 'Warning: no localized message for ' + desc_id
+ # Add caption for this policy.
+ self._AddMessagesToItem(full_name, policy, True, False)
+ if policy['type'] == 'enum':
+ # Iterate through all the items of an enum-type policy, and add captions.
+ for item in policy['items']:
+ self._AddMessagesToItem('ENUM_' + item['name'].upper(), item,
+ True, False)
def _AddMessagesToPolicies(self):
'''Adds localized message strings to each item of the policy data structure
(self._policy_groups).
'''
# Iterate through all the policy groups.
- for group_name, group in self._policy_groups.iteritems():
+ for group in self._policy_groups:
# Get caption and description for this group.
- group_name = 'GROUP_' + group_name.upper()
- self._AddMessagesToItem(group_name, group, True)
+ group_name = 'GROUP_' + group['name'].upper()
+ self._AddMessagesToItem(group_name, group, True, True)
if 'policies' in group:
# Iterate through all the policies in the current group.
- for policy_name, policy in group['policies'].iteritems():
- if policy['type'] == 'enum':
- # Iterate through all the items of an enum-type policy.
- for item_name, item in policy['items'].iteritems():
- self._AddMessagesToItem('ENUM_' + item_name.upper(), item, False)
- elif policy['type'] == 'main':
- # In this case, messages are inherited from the group.
- policy['caption'] = group['caption']
- policy['desc'] = group['desc']
- continue
- # Get caption for this policy.
- full_name = policy_name.upper()
- self._AddMessagesToItem(full_name, policy, False)
+ for policy in group['policies']:
+ self._AddMessagesToPolicy(policy)
def GetTemplateText(self, template_writer):
'''Generates the text of the template from the arguments given
@@ -106,11 +122,11 @@ class PolicyTemplateGenerator:
'''
template_writer.Prepare()
template_writer.BeginTemplate()
- for group_name, group in self._policy_groups.iteritems():
- template_writer.BeginPolicyGroup(group_name, group)
+ for group in self._policy_groups:
+ template_writer.BeginPolicyGroup(group)
if 'policies' in group:
- for policy_name, policy in group['policies'].iteritems():
- template_writer.WritePolicy(policy_name, policy)
+ for policy in group['policies']:
+ template_writer.WritePolicy(policy)
template_writer.EndPolicyGroup()
template_writer.EndTemplate()
return template_writer.GetTemplateText()
diff --git a/tools/grit/grit/format/policy_templates/policy_template_generator_unittest.py b/tools/grit/grit/format/policy_templates/policy_template_generator_unittest.py
index 7f5923b9..61debe5 100644
--- a/tools/grit/grit/format/policy_templates/policy_template_generator_unittest.py
+++ b/tools/grit/grit/format/policy_templates/policy_template_generator_unittest.py
@@ -12,7 +12,7 @@ from writers.mock_writer import MockWriter
class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'''Unit tests for policy_template_generator.py.'''
- def do_test(self, strings, policy_groups, writer):
+ def do_test(self, messages, policy_groups, writer):
'''Executes a test case.
Creates and invokes an instance of PolicyTemplateGenerator with
@@ -30,7 +30,7 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
mock_writer.MockWriter.
'''
writer.tester = self
- policy_generator = PolicyTemplateGenerator(strings, policy_groups)
+ policy_generator = PolicyTemplateGenerator(messages, policy_groups)
res = policy_generator.GetTemplateText(writer)
writer.Test()
return res
@@ -59,7 +59,7 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
def testEmptyGroups(self):
# Test that in case of three empty policy groups, each one is passed to
# the writer.
- strings_mock = {
+ messages_mock = {
'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
'IDS_POLICY_GROUP_GROUP1_DESC': None,
'IDS_POLICY_GROUP_GROUP2_CAPTION': None,
@@ -67,18 +67,18 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'IDS_POLICY_GROUP_GROUP3_CAPTION': None,
'IDS_POLICY_GROUP_GROUP3_DESC': None,
}
- policies_mock = {
- 'Group1': {'tag': 'T1'},
- 'Group2': {'tag': 'T2'},
- 'Group3': {'tag': 'T3'},
- }
+ policies_mock = [
+ {'name': 'Group1', 'tag': 'T1'},
+ {'name': 'Group2', 'tag': 'T2'},
+ {'name': 'Group3', 'tag': 'T3'},
+ ]
class LocalMockWriter(MockWriter):
def __init__(self):
self.log = ''
self.set = set()
- def BeginPolicyGroup(self, group_name, group):
+ def BeginPolicyGroup(self, group):
self.log += '['
- self.set.add ( (group_name, group['tag']) )
+ self.set.add ( (group['name'], group['tag']) )
def EndPolicyGroup(self):
self.log += ']'
def Test(self):
@@ -86,35 +86,35 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
self.tester.assertEquals(
self.set,
set([('Group1', 'T1'), ('Group2', 'T2'), ('Group3', 'T3')]))
- self.do_test(strings_mock, policies_mock, LocalMockWriter())
+ self.do_test(messages_mock, policies_mock, LocalMockWriter())
def testGroupTexts(self):
# Test that GUI strings are assigned correctly to policy groups.
- strings_mock = {
+ messages_mock = {
'IDS_POLICY_GROUP_GROUP1_CAPTION': 'string1',
'IDS_POLICY_GROUP_GROUP1_DESC': 'string2',
'IDS_POLICY_GROUP_GROUP2_CAPTION': 'string3',
'IDS_POLICY_GROUP_GROUP2_DESC': 'string4',
}
- policies_mock = {
- 'Group1': {},
- 'Group2': {},
- }
+ policy_groups_mock = [
+ {'name': 'Group1'},
+ {'name': 'Group2'},
+ ]
class LocalMockWriter(MockWriter):
- def BeginPolicyGroup(self, group_name, group):
- if group_name == 'Group1':
+ def BeginPolicyGroup(self, group):
+ if group['name'] == 'Group1':
self.tester.assertEquals(group['caption'], 'string1')
self.tester.assertEquals(group['desc'], 'string2')
- elif group_name == 'Group2':
+ elif group['name'] == 'Group2':
self.tester.assertEquals(group['caption'], 'string3')
self.tester.assertEquals(group['desc'], 'string4')
else:
self.tester.fail()
- self.do_test(strings_mock, policies_mock, LocalMockWriter())
+ self.do_test(messages_mock, policy_groups_mock, LocalMockWriter())
def testPolicies(self):
# Test that policies are passed correctly to the writer.
- strings_mock = {
+ messages_mock = {
'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
'IDS_POLICY_GROUP_GROUP1_DESC': None,
'IDS_POLICY_GROUP_GROUP2_CAPTION': None,
@@ -123,39 +123,41 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'IDS_POLICY_GROUP1POLICY2_CAPTION': None,
'IDS_POLICY_GROUP2POLICY3_CAPTION': None,
}
- policies_mock = {
- 'Group1': {
- 'policies': {
- 'Group1Policy1': {'type': 'string'},
- 'Group1Policy2': {'type': 'string'}
- }
+ policy_groups_mock = [
+ {
+ 'name': 'Group1',
+ 'policies': [
+ {'name': 'Group1Policy1', 'type': 'string'},
+ {'name': 'Group1Policy2', 'type': 'string'},
+ ]
},
- 'Group2': {
- 'policies': {
- 'Group2Policy3': {'type': 'string'}
- }
+ {
+ 'name': 'Group2',
+ 'policies': [
+ {'name': 'Group2Policy3', 'type': 'string'},
+ ]
}
- }
+ ]
class LocalMockWriter(MockWriter):
def __init__(self):
self.policy_name = None
self.policy_set = set()
- def BeginPolicyGroup(self, group_name, group):
- self.group_name = group_name
+ def BeginPolicyGroup(self, group):
+ self.group = group;
def EndPolicyGroup(self):
- self.group_name = None
- def WritePolicy(self, group_name, group):
- self.tester.assertEquals(group_name[0:6], self.group_name)
- self.policy_set.add(group_name)
+ self.group = None
+ def WritePolicy(self, group):
+ self.tester.assertEquals(group['name'][0:6], self.group['name'])
+ self.policy_set.add(group['name'])
def Test(self):
self.tester.assertEquals(
self.policy_set,
set(['Group1Policy1', 'Group1Policy2', 'Group2Policy3']))
- self.do_test(strings_mock, policies_mock, LocalMockWriter())
+ self.do_test(messages_mock, policy_groups_mock, LocalMockWriter())
def testPolicyTexts(self):
# Test that GUI strings are assigned correctly to policies.
- strings_mock = {
+ messages_mock = {
'IDS_POLICY_POLICY1_CAPTION': 'string1',
'IDS_POLICY_POLICY1_DESC': 'string2',
'IDS_POLICY_POLICY2_CAPTION': 'string3',
@@ -163,30 +165,31 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
'IDS_POLICY_GROUP_GROUP1_DESC': None,
}
- policies_mock = {
- 'Group1': {
- 'policies': {
- 'Policy1': {'type': 'string'},
- 'Policy2': {'type': 'string'}
- }
+ policy_groups_mock = [
+ {
+ 'name': 'Group1',
+ 'policies': [
+ {'name': 'Policy1', 'type': 'string'},
+ {'name': 'Policy2', 'type': 'string'}
+ ]
}
- }
+ ]
class LocalMockWriter(MockWriter):
- def WritePolicy(self, policy_name, policy):
- if policy_name == 'Policy1':
+ def WritePolicy(self, policy):
+ if policy['name'] == 'Policy1':
self.tester.assertEquals(policy['caption'], 'string1')
self.tester.assertEquals(policy['desc'], 'string2')
- elif policy_name == 'Policy2':
+ elif policy['name'] == 'Policy2':
self.tester.assertEquals(policy['caption'], 'string3')
self.tester.assertEquals(policy['desc'], 'string4')
else:
self.tester.fail()
- self.do_test(strings_mock, policies_mock, LocalMockWriter())
+ self.do_test(messages_mock, policy_groups_mock, LocalMockWriter())
def testEnumTexts(self):
# Test that GUI strings are assigned correctly to enums
# (aka dropdown menus).
- strings_mock = {
+ messages_mock = {
'IDS_POLICY_ENUM_ITEM1_CAPTION': 'string1',
'IDS_POLICY_ENUM_ITEM2_CAPTION': 'string2',
'IDS_POLICY_ENUM_ITEM3_CAPTION': 'string3',
@@ -194,26 +197,26 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
'IDS_POLICY_GROUP_GROUP1_DESC': None,
}
- policies_mock = {
- 'Group1': {
- 'policies': {
- 'Policy1': {
- 'type': 'enum',
- 'items': {
- 'item1': {'value': '0'},
- 'item2': {'value': '1'},
- 'item3': {'value': '3'},
- }
- }
- }
+ policy_groups_mock = [
+ {
+ 'name': 'Group1',
+ 'policies': [{
+ 'name': 'Policy1',
+ 'type': 'enum',
+ 'items': [
+ {'name': 'item1', 'value': '0'},
+ {'name': 'item2', 'value': '1'},
+ {'name': 'item3', 'value': '3'},
+ ]
+ }]
}
- }
+ ]
class LocalMockWriter(MockWriter):
- def WritePolicy(self, policy_name, policy):
- self.tester.assertEquals(policy['items']['item1']['caption'], 'string1')
- self.tester.assertEquals(policy['items']['item2']['caption'], 'string2')
- self.tester.assertEquals(policy['items']['item3']['caption'], 'string3')
- self.do_test(strings_mock, policies_mock, LocalMockWriter())
+ def WritePolicy(self, policy):
+ self.tester.assertEquals(policy['items'][0]['caption'], 'string1')
+ self.tester.assertEquals(policy['items'][1]['caption'], 'string2')
+ self.tester.assertEquals(policy['items'][2]['caption'], 'string3')
+ self.do_test(messages_mock, policy_groups_mock, LocalMockWriter())
if __name__ == '__main__':
diff --git a/tools/grit/grit/format/policy_templates/template_formatter.py b/tools/grit/grit/format/policy_templates/template_formatter.py
index 47fd474..2e5633a 100644
--- a/tools/grit/grit/format/policy_templates/template_formatter.py
+++ b/tools/grit/grit/format/policy_templates/template_formatter.py
@@ -58,7 +58,7 @@ class TemplateFormatter(interface.ItemFormatter):
return ''
self._lang = lang
- self._SetBranding(item)
+ self._GetFlags(item)
self._policy_groups = None
self._messages = {}
self._ParseGritNodes(item)
@@ -74,24 +74,28 @@ class TemplateFormatter(interface.ItemFormatter):
'''
policy_generator = \
PolicyTemplateGenerator(self._messages, self._policy_groups)
- writer = self._writer_module.GetWriter(self._build)
+ writer = self._writer_module.GetWriter(self._info, self._messages)
str = policy_generator.GetTemplateText(writer)
return str
- def _SetBranding(self, item):
- '''Sets self._branding and self._build based on the -D_chromium or
- -D_google_chrome command line switch of grit.
+ def _GetFlags(self, item):
+ '''Sets values in self._info based on the -D flags
+ passed to grit.
Args:
item: The <grit> root node of the grit tree.
'''
defines = item.defines
+
+ self._info = {}
+ if 'mac_bundle_id' in defines:
+ self._info['mac_bundle_id'] = defines['mac_bundle_id']
if '_chromium' in defines:
- self._branding = 'Chromium'
- self._build = 'chromium'
+ self._info['app_name'] = 'Chromium'
+ self._info['build'] = 'chromium'
elif '_google_chrome' in defines:
- self._branding = 'Google Chrome'
- self._build = 'chrome'
+ self._info['app_name'] = 'Google Chrome'
+ self._info['build'] = 'chrome'
else:
raise Exception('Unknown build')
@@ -104,7 +108,7 @@ class TemplateFormatter(interface.ItemFormatter):
'''
msg_name = message.GetTextualIds()[0]
msg_txt = message.Translate(self._lang)
- msg_txt = msg_txt.replace('$1', self._branding)
+ msg_txt = msg_txt.replace('$1', self._info['app_name'])
lines = msg_txt.split('\n')
lines = [line.strip() for line in lines]
msg_txt = "\\n".join(lines)
diff --git a/tools/grit/grit/format/policy_templates/writers/adm_writer.py b/tools/grit/grit/format/policy_templates/writers/adm_writer.py
index e7b7c36..51dea06 100644
--- a/tools/grit/grit/format/policy_templates/writers/adm_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/adm_writer.py
@@ -6,8 +6,8 @@
from template_writer import TemplateWriter
-def GetWriter(build):
- return AdmWriter(build)
+def GetWriter(info, messages):
+ return AdmWriter(info, messages)
class AdmWriter(TemplateWriter):
@@ -17,7 +17,8 @@ class AdmWriter(TemplateWriter):
TYPE_TO_INPUT = {
'string': 'EDITTEXT',
- 'enum': 'DROPDOWNLIST'}
+ 'enum': 'DROPDOWNLIST',
+ 'list': 'LISTBOX'}
NEWLINE = '\r\n'
def _AddGuiString(self, name, value):
@@ -45,9 +46,10 @@ class AdmWriter(TemplateWriter):
self._PrintLine('SUPPORTED !!SUPPORTED_WINXPSP2')
self._PrintLine('#endif', -1)
- def WritePolicy(self, policy_name, policy):
- type = policy['type']
- if type == 'main':
+ def WritePolicy(self, policy):
+ policy_type = policy['type']
+ policy_name = policy['name']
+ if policy_type == 'main':
self._PrintLine('VALUENAME "%s"' % policy_name )
self._PrintLine('VALUEON NUMERIC 1')
self._PrintLine('VALUEOFF NUMERIC 0')
@@ -57,25 +59,31 @@ class AdmWriter(TemplateWriter):
self._AddGuiString(policy_part_name, policy['caption'])
self._PrintLine()
+ if policy_type == 'list':
+ self._PrintLine('KEYNAME "%s\\%s"' % (self._key_name, policy_name))
+ # Print the PART ... END PART section:
self._PrintLine(
- 'PART !!%s %s' % (policy_part_name, self.TYPE_TO_INPUT[type]),
+ 'PART !!%s %s' % (policy_part_name, self.TYPE_TO_INPUT[policy_type]),
1)
- self._PrintLine('VALUENAME "%s"' % policy_name)
- if type == 'enum':
+ if policy_type == 'list':
+ self._PrintLine('VALUEPREFIX ""')
+ else:
+ self._PrintLine('VALUENAME "%s"' % policy_name)
+ if policy_type == 'enum':
self._PrintLine('ITEMLIST', 1)
- for item_name, item in policy['items'].iteritems():
- self._PrintLine(
- 'NAME !!%s_DropDown VALUE NUMERIC %s' % (item_name, item['value']))
- self._AddGuiString(item_name + '_DropDown', item['caption'])
+ for item in policy['items']:
+ self._PrintLine('NAME !!%s_DropDown VALUE NUMERIC %s' %
+ (item['name'], item['value']))
+ self._AddGuiString(item['name'] + '_DropDown', item['caption'])
self._PrintLine('END ITEMLIST', -1)
self._PrintLine('END PART', -1)
- def BeginPolicyGroup(self, group_name, group):
- group_explain_name = group_name + '_Explain'
- self._AddGuiString(group_name + '_Policy', group['caption'])
+ def BeginPolicyGroup(self, group):
+ group_explain_name = group['name'] + '_Explain'
+ self._AddGuiString(group['name'] + '_Policy', group['caption'])
self._AddGuiString(group_explain_name, group['desc'])
- self._PrintLine('POLICY !!%s_Policy' % group_name, 1)
+ self._PrintLine('POLICY !!%s_Policy' % group['name'], 1)
self._WriteSupported()
self._PrintLine('EXPLAIN !!' + group_explain_name)
@@ -84,28 +92,28 @@ class AdmWriter(TemplateWriter):
self._PrintLine()
def BeginTemplate(self):
- # TODO(gfeher): Move this string to .grd.
self._AddGuiString('SUPPORTED_WINXPSP2',
- 'At least Microsoft Windows XP SP2')
+ self.messages['IDS_POLICY_WIN_SUPPORTED_WINXPSP2'])
self._PrintLine('CLASS MACHINE', 1)
- if self.build == 'chrome':
+ if self.info['build'] == 'chrome':
self._AddGuiString('google', 'Google')
self._AddGuiString('googlechrome', 'Google Chrome')
self._PrintLine('CATEGORY !!google', 1)
self._PrintLine('CATEGORY !!googlechrome', 1)
- self._PrintLine('KEYNAME "Software\\Policies\\Google\\Google Chrome"')
- elif self.build == 'chromium':
+ self._key_name = 'Software\\Policies\\Google\\Google Chrome'
+ elif self.info['build'] == 'chromium':
self._AddGuiString('chromium', 'Chromium')
self._PrintLine('CATEGORY !!chromium', 1)
- self._PrintLine('KEYNAME "Software\\Policies\\Chromium"')
+ self._key_name = 'Software\\Policies\\Chromium'
+ self._PrintLine('KEYNAME "%s"' % self._key_name)
self._PrintLine()
def EndTemplate(self):
- if self.build == 'chrome':
+ if self.info['build'] == 'chrome':
self._PrintLine('END CATEGORY', -1)
self._PrintLine('END CATEGORY', -1)
self._PrintLine('', -1)
- elif self.build == 'chromium':
+ elif self.info['build'] == 'chromium':
self._PrintLine('END CATEGORY', -1)
self._PrintLine('', -1)
diff --git a/tools/grit/grit/format/policy_templates/writers/mock_writer.py b/tools/grit/grit/format/policy_templates/writers/mock_writer.py
index 8700b68..fd1f8c9 100644
--- a/tools/grit/grit/format/policy_templates/writers/mock_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/mock_writer.py
@@ -13,10 +13,10 @@ class MockWriter(TemplateWriter):
def __init__(self):
pass
- def WritePolicy(self, policy_name, policy):
+ def WritePolicy(self, policy):
pass
- def BeginPolicyGroup(self, group_name, group):
+ def BeginPolicyGroup(self, group):
pass
def EndPolicyGroup(self):
diff --git a/tools/grit/grit/format/policy_templates/writers/template_writer.py b/tools/grit/grit/format/policy_templates/writers/template_writer.py
index cb80fb2..b853b7d 100644
--- a/tools/grit/grit/format/policy_templates/writers/template_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/template_writer.py
@@ -8,14 +8,25 @@ class TemplateWriter(object):
The methods of this class will be called by PolicyTemplateGenerator.
'''
- def __init__(self, build):
+ def __init__(self, info, messages):
'''Initializes a TemplateWriter object.
Args:
- build: 'chrome' or 'chromium'
+ info: A dictionary of extra information required to generate the template.
+ Currently it contains three keys:
+ 'build': 'chrome' or 'chromium'
+ 'branding': 'Google Chrome' or 'Chromium'
+ 'mac_bundle_id': The Mac bundle id of Chrome. (Only set when building
+ for Mac.)
+ messages: List of all the message strings from the grd file. Most of them
+ are also present in the policy data structures that are passed to
+ methods. That is the preferred way of accessing them, this should only
+ be used in exceptional cases. An example for its use is the
+ IDS_POLICY_WIN_SUPPORTED_WINXPSP2 message in ADM files, because that
+ can not be associated with any policy or group.
'''
- assert build in ['chrome', 'chromium']
- self.build = build
+ self.info = info
+ self.messages = messages
def Prepare(self):
'''Initializes the internal buffer where the template will be
@@ -23,22 +34,20 @@ class TemplateWriter(object):
'''
raise NotImplementedError()
- def WritePolicy(self, policy_name, policy):
+ def WritePolicy(self, policy):
'''Appends the template text corresponding to a policy into the
internal buffer.
Args:
- policy_name: The name of the policy that has to be written.
policy: The policy as it is found in the JSON file.
'''
raise NotImplementedError()
- def BeginPolicyGroup(self, group_name, group):
+ def BeginPolicyGroup(self, group):
'''Appends the template text corresponding to the beginning of a
policy group into the internal buffer.
Args:
- group_name: The name of the policy group that has to be written.
group: The policy group as it is found in the JSON file.
'''
raise NotImplementedError()
diff --git a/tools/grit/grit/format/policy_templates/writers/xml_formatted_writer.py b/tools/grit/grit/format/policy_templates/writers/xml_formatted_writer.py
new file mode 100644
index 0000000..6b9a475
--- /dev/null
+++ b/tools/grit/grit/format/policy_templates/writers/xml_formatted_writer.py
@@ -0,0 +1,40 @@
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+from xml.dom.minidom import Document
+from xml.dom.minidom import Node
+from template_writer import TemplateWriter
+
+
+class XMLFormattedWriter(TemplateWriter):
+ '''Helper class for generating XML-based templates.
+ '''
+
+ def AddElement(self, parent, name, attrs = {}, text = None):
+ '''
+ Adds a new XML Element as a child to an existing element or the Document.
+
+ Args:
+ parent: An XML element or the document, where the new element will be
+ added.
+ name: The name of the new element.
+ attrs: A dictionary of the attributes' names and values for the new
+ element.
+ text: Text content for the new element.
+
+ Returns:
+ The created new element.
+ '''
+ if isinstance(parent, Document):
+ doc = parent
+ else:
+ doc = parent.ownerDocument
+ element = doc.createElement(name)
+ for key, value in attrs.iteritems():
+ element.attributes[key] = value
+ if text:
+ element.appendChild( doc.createTextNode(text) )
+ parent.appendChild(element)
+ return element