summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/policy/policy_templates.grd167
-rw-r--r--chrome/app/policy/policy_templates.json339
-rw-r--r--tools/grit/grit/format/policy_templates/policy_template_generator.py122
-rw-r--r--tools/grit/grit/format/policy_templates/policy_template_generator_unittest.py130
-rw-r--r--tools/grit/grit/format/policy_templates/template_formatter.py2
-rw-r--r--tools/grit/grit/format/policy_templates/writers/adm_writer.py31
-rw-r--r--tools/grit/grit/format/policy_templates/writers/adm_writer_unittest.py88
-rw-r--r--tools/grit/grit/format/policy_templates/writers/doc_writer.py28
-rw-r--r--tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py15
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py24
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py41
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py33
-rw-r--r--tools/grit/grit/format/policy_templates/writers/template_writer.py21
13 files changed, 469 insertions, 572 deletions
diff --git a/chrome/app/policy/policy_templates.grd b/chrome/app/policy/policy_templates.grd
index ad81774..464e1a3 100644
--- a/chrome/app/policy/policy_templates.grd
+++ b/chrome/app/policy/policy_templates.grd
@@ -139,52 +139,61 @@ templates and will be translated for each locale. -->
<!-- Strings for ADM/ADMX/MCX policy templates: -->
- <message name="IDS_POLICY_GROUP_HOMEPAGELOCATION_DESC" desc="Description of the 'homepage' policy settings page.">
+ <message name="IDS_POLICY_HOMEPAGE_CAPTION" desc="Caption of the group of homepage-related policies.">
+ Configure the default home page
+ </message>
+ <message name="IDS_POLICY_HOMEPAGE_DESC" desc="Description of the group of homepage-related policies.">
+ Configure the default home page in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing it.
+
+ The user's home page settings are only completely locked down, if you either select the home page to be the new tab page, or set it to be a URL and specify a home page URL. If you don't specify the home page URL, then the user is still able to set the home page to the new tab page by specifying 'chrome://newtab'.
+ </message>
+ <message name="IDS_POLICY_HOMEPAGELOCATION_DESC" desc="Description of the 'homepage location' policy.">
Configures the default home page 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.
+ The home page type can either be set to a URL you specify here or set to the New Tab Page.
If you select the New Tab Page, then this policy is ignored.
If you enable this setting, users cannot change their home page URL in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>, but they can still can choose the New Tab Page as their home page.
</message>
- <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 name="IDS_POLICY_HOMEPAGELOCATION_CAPTION" desc="Caption of the homepage URL policy">
+ Configure the home page URL
</message>
- <message name="IDS_POLICY_HOMEPAGELOCATION_CAPTION" desc="Caption of the homepage URL text field in the homepage policy settings page.">
- Homepage URL
+ <message name="IDS_POLICY_HOMEPAGELOCATION_LABEL" desc="Caption of the homepage URL text field in the homepage policy settings page.">
+ Home page URL
</message>
- <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.
+ <message name="IDS_POLICY_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 home page preferences. The home page 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 home page, and the home page 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_GROUP_HOMEPAGEISNEWTABPAGE_CAPTION" desc="Caption of the 'homepage type' selection dropdown menu in the 'homepage type' policy settings page.">
+ <message name="IDS_POLICY_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.">
+ <message name="IDS_POLICY_APPLICATIONLOCALEVALUE_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.">
+ <message name="IDS_POLICY_APPLICATIONLOCALEVALUE_LABEL" desc="Caption of the text entry field of the 'application locale' policy.">
+ Application locale
+ </message>
+ <message name="IDS_POLICY_APPLICATIONLOCALEVALUE_DESC" desc="Description of the 'application locale' policy.">
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
- </message>
- <message name="IDS_POLICY_GROUP_ALTERNATEERRORPAGESENABLED_CAPTION" desc="Caption of the 'alternate error pages' policy settings page.">
+ <message name="IDS_POLICY_ALTERNATEERRORPAGESENABLED_CAPTION" desc="Caption of the 'alternate error pages' policy.">
Enable alternate error pages
</message>
- <message name="IDS_POLICY_GROUP_ALTERNATEERRORPAGESENABLED_DESC" desc="Description of the 'alternate error pages' policy settings page.">
+ <message name="IDS_POLICY_ALTERNATEERRORPAGESENABLED_DESC" desc="Description of the 'alternate error pages' policy.">
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.
@@ -194,10 +203,10 @@ templates and will be translated for each locale. -->
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.">
+ <message name="IDS_POLICY_SEARCHSUGGESTENABLED_CAPTION" desc="Caption of the 'search suggestions' policy.">
Enable search suggestions
</message>
- <message name="IDS_POLICY_GROUP_SEARCHSUGGESTENABLED_DESC" desc="Description of the 'search suggestions' policy settings page.">
+ <message name="IDS_POLICY_SEARCHSUGGESTENABLED_DESC" desc="Description of the 'search suggestions' policy.">
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.
@@ -207,19 +216,19 @@ templates and will be translated for each locale. -->
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.">
+ <message name="IDS_POLICY_DNSPREFETCHINGENABLED_CAPTION" desc="Caption of the 'DNS prefetching' policy.">
Enable DNS prefetching
</message>
- <message name="IDS_POLICY_GROUP_DNSPREFETCHINGENABLED_DESC" desc="Description of the 'DNS prefetching' policy settings page.">
+ <message name="IDS_POLICY_DNSPREFETCHINGENABLED_DESC" desc="Description of the 'DNS prefetching' policy.">
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_JAVASCRIPTENABLED_CAPTION" desc="Caption of the 'JavaScript enabled' policy settings page.">
+ <message name="IDS_POLICY_JAVASCRIPTENABLED_CAPTION" desc="Caption of the 'JavaScript enabled' policy settings page.">
Enable JavaScript
</message>
- <message name="IDS_POLICY_GROUP_JAVASCRIPTENABLED_DESC" desc="Description of the 'JavaScript enabled' policy settings page.">
+ <message name="IDS_POLICY_JAVASCRIPTENABLED_DESC" desc="Description of the 'JavaScript enabled' policy settings page.">
Enables JavaScript in <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> and prevents users from changing this setting.
If this setting is enabled or not configured, web pages can use JavaScript.
@@ -227,12 +236,10 @@ templates and will be translated for each locale. -->
If this setting is disabled, web pages cannot use JavaScript.
</message>
- <message name="IDS_POLICY_GROUP_AUTOFILLENABLED_CAPTION" desc="Caption of
- the 'autofill' policy settings page.">
- Enable AutoFill
+ <message name="IDS_POLICY_AUTOFILLENABLED_CAPTION" desc="Caption of the 'autofill' policy.">
+ Enable AutoFill
</message>
- <message name="IDS_POLICY_GROUP_AUTOFILLENABLED_DESC" desc="Description of
- the 'autofill' policy settings page.">
+ <message name="IDS_POLICY_AUTOFILLENABLED_DESC" desc="Description of the 'autofill' policy.">
Enables <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>'s AutoFill
feature and allows users to auto complete web forms using previously stored
information such as address or credit card information.
@@ -244,12 +251,10 @@ templates and will be translated for each locale. -->
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_SHOWHOMEBUTTON_CAPTION" desc="Caption of
- the 'show Home button' policy settings page.">
+ <message name="IDS_POLICY_SHOWHOMEBUTTON_CAPTION" desc="Caption of the 'show Home button' policy.">
Show Home button on toolbar
</message>
- <message name="IDS_POLICY_GROUP_SHOWHOMEBUTTON_DESC" desc="Description of
- the 'show Home button' policy settings page.">
+ <message name="IDS_POLICY_SHOWHOMEBUTTON_DESC" desc="Description of the 'show Home button' policy.">
Shows the Home button on <ph name="PRODUCT_NAME">$1<ex>Google
Chrome</ex></ph>'s toolbar.
@@ -261,10 +266,10 @@ templates and will be translated for each locale. -->
</message>
- <message name="IDS_POLICY_GROUP_SAFEBROWSINGENABLED_CAPTION" desc="Caption of the 'safe browsing' policy settings page.">
+ <message name="IDS_POLICY_SAFEBROWSINGENABLED_CAPTION" desc="Caption of the 'safe browsing' policy.">
Enable Safe Browsing
</message>
- <message name="IDS_POLICY_GROUP_SAFEBROWSINGENABLED_DESC" desc="Description of the 'safe browsing' policy settings page.">
+ <message name="IDS_POLICY_SAFEBROWSINGENABLED_DESC" desc="Description of the 'safe browsing' policy.">
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.
@@ -274,19 +279,19 @@ templates and will be translated for each locale. -->
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.">
+ <message name="IDS_POLICY_SYNCDISABLED_CAPTION" desc="Caption of the 'disable sync' policy.">
Disable synchronization of data with Google
</message>
- <message name="IDS_POLICY_GROUP_SYNCDISABLED_DESC" desc="Description of the 'disable sync' policy settings page.">
+ <message name="IDS_POLICY_SYNCDISABLED_DESC" desc="Description of the 'disable sync' policy.">
Disables 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.">
+ <message name="IDS_POLICY_PROXY_CAPTION" desc="Caption of the 'proxy' policy group.">
Configure proxy server
</message>
- <message name="IDS_POLICY_GROUP_PROXY_DESC" desc="Description of the 'proxy' policy settings page.">
+ <message name="IDS_POLICY_PROXY_DESC" desc="Description of the 'proxy' policy group.">
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.
@@ -317,6 +322,9 @@ templates and will be translated for each locale. -->
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.">
+ Proxy bypass rules
+ </message>
+ <message name="IDS_POLICY_PROXYBYPASSLIST_LABEL" desc="The label of the 'proxy bypass rules' text field in the 'proxy' policy settings page.">
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.">
@@ -361,10 +369,10 @@ templates and will be translated for each locale. -->
<ph name="PROXY_HELP_URL">$2<ex>http://www.chromium.org/developers/design-documents/network-settings#TOC-Command-line-options-for-proxy-sett</ex></ph>
</message>
- <message name="IDS_POLICY_GROUP_METRICSREPORTINGENABLED_CAPTION" desc="Caption of the 'crash reporting' policy settings page.">
+ <message name="IDS_POLICY_METRICSREPORTINGENABLED_CAPTION" desc="Caption of the 'crash reporting' policy.">
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.">
+ <message name="IDS_POLICY_METRICSREPORTINGENABLED_DESC" desc="Description of the 'crash reporting' policy.">
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.
@@ -374,10 +382,17 @@ templates and will be translated for each locale. -->
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.">
+ <message name="IDS_POLICY_PASSWORDMANAGER_CAPTION" desc="Caption of the group of 'password manager' related policies.">
+ Configure the password manager
+ </message>
+ <message name="IDS_POLICY_PASSWORDMANAGER_DESC" desc="Description of the group of 'password manager' related policies.">
+ Configures the password manager. If the password manager is enabled, then you can choose to enable or disable whether the user may show stored passwords in clear text.
+ </message>
+
+ <message name="IDS_POLICY_PASSWORDMANAGERENABLED_CAPTION" desc="Caption of the 'password manager' policy.">
Enable the password manager
</message>
- <message name="IDS_POLICY_GROUP_PASSWORDMANAGERENABLED_DESC" desc="Description of the 'password manager' policy settings page.">
+ <message name="IDS_POLICY_PASSWORDMANAGERENABLED_DESC" desc="Description of the 'password manager' policy.">
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 they log in to a site.
@@ -387,10 +402,10 @@ templates and will be translated for each locale. -->
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_PASSWORDMANAGERALLOWSHOWPASSWORDS_CAPTION" desc="Caption of the 'allow show passwords in password manager' policy settings page.">
+ <message name="IDS_POLICY_PASSWORDMANAGERALLOWSHOWPASSWORDS_CAPTION" desc="Caption of the 'allow show passwords in password manager' policy.">
Allow users to show passwords in Password Manager
</message>
- <message name="IDS_POLICY_GROUP_PASSWORDMANAGERALLOWSHOWPASSWORDS_DESC" desc="Description of the 'allow show passwords in password manager' policy settings page.">
+ <message name="IDS_POLICY_PASSWORDMANAGERALLOWSHOWPASSWORDS_DESC" desc="Description of the 'allow show passwords in password manager' policy.">
Controls whether the user may show passwords in clear text in the password manager.
If you disable this setting, the password manager does not allow showing stored passwords in clear text in the password manager window.
@@ -398,37 +413,46 @@ templates and will be translated for each locale. -->
If you enable or do not configure this setting, users can view their passwords in clear text in the password manager.
</message>
- <message name="IDS_POLICY_GROUP_DISABLEDPLUGINS_CAPTION" desc="Caption of the 'disable plugins' policy settings page.">
+ <message name="IDS_POLICY_DISABLEDPLUGINS_CAPTION" desc="Caption of the 'disable plugins' policy.">
Specify a list of disabled plugins
</message>
- <message name="IDS_POLICY_GROUP_DISABLEDPLUGINS_DESC" desc="Description of the 'disable plugins' policy settings page.">
+ <message name="IDS_POLICY_DISABLEDPLUGINS_DESC" desc="Description of the 'disable plugins' policy.">
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.
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 cannot enable them.
</message>
- <message name="IDS_POLICY_DISABLEDPLUGINS_CAPTION" desc="Label of the 'list of disabled plugins' text field in the 'disabled plugins' policy settings page.">
+ <message name="IDS_POLICY_DISABLEDPLUGINS_LABEL" desc="Label of the 'list of disabled plugins' text field in the 'disabled plugins' policy settings page.">
List of disabled plugins
</message>
- <message name="IDS_POLICY_GROUP_EXTENSIONINSTALLBLACKLIST_CAPTION" desc="Caption of the 'extension blacklist' policy settings page.">
+ <message name="IDS_POLICY_EXTENSIONS_CAPTION" desc="Caption of the group of extension-related policies.">
+ Configure allowed extensions
+ </message>
+ <message name="IDS_POLICY_EXTENSIONS_DESC" desc="Description of the group of extension-related policies.">
+ Configures extension installation blacklist and whitelist. The user is not allowed to install blacklisted extensions. If you add an already installed extension to the blacklist, then it gets automatically uninstalled from the user's machine.
+
+ A blacklist value of * means all extensions are blacklisted unless they are explicitly listed in the whitelist.
+ </message>
+
+ <message name="IDS_POLICY_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.">
+ <message name="IDS_POLICY_EXTENSIONINSTALLBLACKLIST_LABEL" 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.">
+ <message name="IDS_POLICY_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 unless they are explicitly listed in the whitelist.
</message>
- <message name="IDS_POLICY_GROUP_EXTENSIONINSTALLWHITELIST_CAPTION" desc="Caption of the 'extension whitelist' policy settings page.">
+ <message name="IDS_POLICY_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.">
+ <message name="IDS_POLICY_EXTENSIONINSTALLWHITELIST_LABEL" 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.">
+ <message name="IDS_POLICY_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 can only install extensions listed in the whitelist.
@@ -443,21 +467,15 @@ templates and will be translated for each locale. -->
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> preferences
</message>
- <message name="IDS_POLICY_GROUP_RESTOREONSTARTUP_CAPTION" desc="Caption of
+ <message name="IDS_POLICY_RESTOREONSTARTUPGROUP_CAPTION" desc="Caption of
the 'restore on startup' policy settings page">
Configure startup pages
</message>
- <message name="IDS_POLICY_GROUP_RESTOREONSTARTUP_DESC" desc="Description of
+ <message name="IDS_POLICY_RESTOREONSTARTUPGROUP_DESC" desc="Description of
the 'restore on startup' policy settings page.">
Allows you to configure the pages that are loaded on startup.
- If you choose 'open home page on startup' the home page will always be opened when you start <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
-
- If you choose 'Reopen the URLs that were open last', the URLs that were open last time <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> was closed will be reopened.
-
- If you choose 'Open a list of URLs on startup', the list of 'URLs to open on startup' will be opened when a user starts <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
-
- 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>.
+ The contents of the list 'URLs to open at startup' are ignored unless you select 'Open a list of URLs' in 'Action on startup'.
</message>
<message name="IDS_POLICY_RESTOREONSTARTUP_CAPTION" desc="Caption of the dropbox 'restore on startup mode' of the policy settings page 'restore on startup'.">
@@ -465,6 +483,14 @@ templates and will be translated for each locale. -->
</message>
<message name="IDS_POLICY_RESTOREONSTARTUP_DESC" desc="Description of the dropbox 'restore on startup mode' of the policy settings page 'restore on startup'">
Allows you to specify the behavior on startup.
+
+ If you choose 'Open home page' the home page will always be opened when you start <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
+
+ If you choose 'Reopen the URLs that were open last', the URLs that were open last time <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> was closed will be reopened.
+
+ If you choose 'Open a list of URLs', the list of 'URLs to open on startup' will be opened when a user starts <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph>.
+
+ 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_ENUM_RESTOREONSTARTUPISNONE_CAPTION" desc="Label in the dropdown menu 'restore on startup mode' for opening the home page on startup.">
@@ -491,7 +517,7 @@ templates and will be translated for each locale. -->
Google Chrome Frame</ex></ph>
</message>
<message name="IDS_POLICY_GROUP_CHROMEFRAMERENDERERSETTINGS_DESC"
- desc="Description of the 'Chrome Frame renderer' policy settings page. TODO(gfeher): This text is only visible on Mac, but the corresponding policy is not supported on Mac.">
+ desc="Description of the 'Chrome Frame renderer' policy settings page.">
Configure the default HTML renderer when <ph name="PRODUCT_FRAME_NAME">
$3<ex>Google Chrome Frame</ex>
</ph> is installed.
@@ -505,6 +531,10 @@ templates and will be translated for each locale. -->
desc="Caption of Chrome Frame renderer policy settings page">
Configure the default HTML renderer for <ph name="PRODUCT_FRAME_NAME">$3<ex>Google Chrome Frame</ex></ph>
</message>
+ <message name="IDS_POLICY_CHROMEFRAMERENDERERSETTINGS_VALUE_APTION"
+ desc="Caption of Chrome Frame renderer policy settings page">
+ Default HTML renderer for <ph name="PRODUCT_FRAME_NAME">$3<ex>Google Chrome Frame</ex></ph>
+ </message>
<message name="IDS_POLICY_CHROMEFRAMERENDERERSETTINGS_DESC"
desc="Description of the 'Chrome Frame renderer' policy settings page.">
Allows you to configure the default HTML renderer when <ph name="PRODUCT_FRAME_NAME">$3<ex>Google Chrome Frame</ex>
@@ -528,11 +558,22 @@ templates and will be translated for each locale. -->
desc="Caption for list of URLs that should always be displayed in Chrome Frame">
Always render the following URL patterns in <ph name="PRODUCT_FRAME_NAME">$3<ex>Google Chrome Frame</ex></ph>
</message>
+ <message name="IDS_POLICY_RENDERINCHROMEFRAMELIST_DESC"
+ desc="Description for list of URLs that should always be displayed in Chrome Frame">
+ Customize the list of URL patterns that should always be rendered by <ph name="PRODUCT_FRAME_NAME">$3<ex>Google Chrome Frame</ex></ph>.
+
+ For example patterns see http://www.chromium.org/developers/how-tos/chrome-frame-getting-started.
+ </message>
<message name="IDS_POLICY_RENDERINHOSTLIST_CAPTION"
desc="Caption for list of URLs that should always be displayed in the host browser">
Always render the following URL patterns in the host browser
</message>
+ <message name="IDS_POLICY_RENDERINHOSTLIST_DESC"
+ desc="Description for list of URLs that should always be displayed in the host browser">
+ Customize the list of URL patterns that should always be rendered by the host browser.
+ For example patterns see http://www.chromium.org/developers/how-tos/chrome-frame-getting-started.
+ </message>
<!-- End Chrome Frame messages -->
<!-- Generated documentation messages -->
diff --git a/chrome/app/policy/policy_templates.json b/chrome/app/policy/policy_templates.json
index 7b986ce..0d4a7b4 100644
--- a/chrome/app/policy/policy_templates.json
+++ b/chrome/app/policy/policy_templates.json
@@ -1,6 +1,8 @@
{
# policy_templates.json - Metafile for policy templates
#
+# The content of this file is evaluated as a Python expression.
+#
# This file is used as input to generate the following policy templates:
# ADM,ADMX+ADML,MCX/plist
#
@@ -11,63 +13,45 @@
# related policies might appear together in policy groups. The grouping is not
# visible to Chrome.
#
-# This file contains a list of policy groups. Each group contains a list
-# of policies under the key 'policies'. If a policy does not belong to
-# any groups then it should be placed in its own separate group. All the
-# policies and all the groups must have unique names but it is not a problem
-# to have a group and policy with the same name. Group names are in fact
-# not exposed to Chrome at all.
+# This file contains a list of policies and groups. Each group contains a list
+# of policies under the key 'policies'. All the policies and groups must have
+# unique names. Group names are not exposed to Chrome at all.
#
# Each policy has a type. The currently implemented types:
+# 'group': - not a real policy, contains a list of policies
+# NOTE: Currently nesting groups inside other groups is not supported.
# 'string' - a string value
# '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 and not
-# configured (not visible to Chrome at all) if the rest of the group is
-# not configured. 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.
+# 'main' - a boolean value
# 'list' - a list of string values
#
# 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.
-# 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.
+# Each item (policy or group) may have the following messages:
+# - description:
+# Describes the item it applies to.
+# - caption
+# A short, one-line summary of the item it applies to. This can appear
+# both in policy or group listings or on title bars of policy-setting
+# windows.
+# - label (Optional, defaults to caption if not specified.)
+# A short, one-line summary of the item it applies to. The difference
+# from caption is that label always appears next to the entry field
+# where the value of the policy can be entered. 'main' policies on
+# Windows ignore this. Policies on Mac are using this instead of 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:
# -For policy groups:
-# IDS_POLICY_GROUP_<NAME OF THE GROUP>
-# e.g. the name of the description of group Homepage:
-# IDS_POLICY_GROUP_HOMEPAGE_DESC
-# -For policies:
-# IDS_POLICY_<NAME OF THE POLICY>
+# -For policies and groups:
+# IDS_POLICY_<NAME OF THE POLICY OR GROUP>
# e.g. the name of the caption of policy HomepageLocation:
# IDS_POLICY_HOMEPAGELOCATION_CAPTION
+# or other messages of the policy HomepageLocation:
+# IDS_POLICY_HOMEPAGELOCATION_VALUE_CAPTION
+# IDS_POLICY_HOMEPAGELOCATION_DESC
# -For enum items:
# IDS_POLICY_ENUM_<NAME OF THE ITEM>
# e.g. the name of the caption of ProxyServerDisabled:
@@ -82,132 +66,109 @@
# Windows: ADM,ADMX,ADML
# Mac: plist,plist_strings
#
- 'policy_groups': [
- # 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.
+ 'policy_definitions': [
{
- 'name': 'HomepageLocation',
- 'policies': [{
- 'name': 'HomepageLocation',
- 'type': 'string',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': 'http://chromium.org',
- }
- }],
- },
- {
- 'name': 'HomepageIsNewTabPage',
- 'policies': [{
- 'name': 'HomepageIsNewTabPage',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': True,
+ 'name': 'Homepage',
+ 'type': 'group',
+ 'policies': [
+ {
+ 'name': 'HomepageLocation',
+ 'type': 'string',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': 'http://chromium.org',
+ }
+ },
+ {
+ 'name': 'HomepageIsNewTabPage',
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': True,
+ }
}
- }],
+ ]
},
{
- 'name': 'ApplicationLocale',
- 'policies': [{
- 'name': 'ApplicationLocaleValue',
- 'type': 'string',
- 'annotations': {
- 'platforms': ['win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 0},
- 'example_value': 'en',
- },
- }]
+ 'name': 'ApplicationLocaleValue',
+ 'type': 'string',
+ 'annotations': {
+ 'platforms': ['win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 0},
+ 'example_value': 'en',
+ },
},
{
'name': 'AlternateErrorPagesEnabled',
- 'policies': [{
- 'name': 'AlternateErrorPagesEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': True,
- },
- }]
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': True,
+ },
},
{
'name': 'SearchSuggestEnabled',
- 'policies': [{
- 'name': 'SearchSuggestEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': True,
- }
- }],
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': True,
+ }
},
{
'name': 'DnsPrefetchingEnabled',
- 'policies': [{
- 'name': 'DnsPrefetchingEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 0},
- 'example_value': True,
- }
- }],
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 0},
+ 'example_value': True,
+ }
},
{
'name': 'JavascriptEnabled',
- 'policies': [{
- 'name': 'JavascriptEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 0},
- 'example_value': True,
- }
- }],
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 0},
+ 'example_value': True,
+ }
},
{
'name': 'SafeBrowsingEnabled',
- 'policies': [{
- 'name': 'SafeBrowsingEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 0},
- 'example_value': True,
- }
- }]
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 0},
+ 'example_value': True,
+ }
},
{
'name': 'MetricsReportingEnabled',
- 'policies': [{
- 'name': 'MetricsReportingEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 0},
- 'example_value': True,
- 'problem_href':
- 'http://www.chromium.org/administrators/'
- 'policy-list-3/metrics-reporting-enabled',
- }
- }],
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 0},
+ 'example_value': True,
+ 'problem_href':
+ 'http://www.chromium.org/administrators/'
+ 'policy-list-3/metrics-reporting-enabled',
+ }
},
{
- 'name': 'PasswordManagerEnabled',
+ 'name': 'PasswordManager',
+ 'type': 'group',
'policies': [{
'name': 'PasswordManagerEnabled',
'type': 'main',
@@ -217,11 +178,8 @@
'features': {'dynamic_refresh': 1},
'example_value': True,
}
- }]
- },
- {
- 'name': 'PasswordManagerAllowShowPasswords',
- 'policies': [{
+ },
+ {
'name': 'PasswordManagerAllowShowPasswords',
'type': 'main',
'annotations': {
@@ -233,46 +191,38 @@
}]
},
{
- 'name' : 'AutoFillEnabled',
- 'policies': [{
- 'name': 'AutoFillEnabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': False,
- }
- }]
+ 'name': 'AutoFillEnabled',
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': False,
+ }
},
{
'name': 'DisabledPlugins',
- 'policies': [{
- 'name': 'DisabledPlugins',
- 'type': 'list',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': ['Java', 'Shockwave Flash', 'Chrome PDF Viewer'],
- }
- }]
+ 'type': 'list',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': ['Java', 'Shockwave Flash', 'Chrome PDF Viewer'],
+ }
},
{
'name': 'SyncDisabled',
- 'policies': [{
- 'name': 'SyncDisabled',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': True,
- }
- }]
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': True,
+ }
},
{
'name': 'Proxy',
+ 'type': 'group',
'policies': [
{
'name': 'ProxyServerMode',
@@ -323,7 +273,8 @@
]
},
{
- 'name': 'ExtensionInstallBlacklist',
+ 'name': 'Extensions',
+ 'type': 'group',
'policies': [{
'name': 'ExtensionInstallBlacklist',
'type': 'list',
@@ -333,11 +284,8 @@
'features': {'dynamic_refresh': 1},
'example_value': ['extension_id1', 'extension_id2']
}
- }]
- },
- {
- 'name': 'ExtensionInstallWhitelist',
- 'policies': [{
+ },
+ {
'name': 'ExtensionInstallWhitelist',
'type': 'list',
'annotations': {
@@ -350,19 +298,17 @@
},
{
'name': 'ShowHomeButton',
- 'policies': [{
- 'name': 'ShowHomeButton',
- 'type': 'main',
- 'annotations': {
- 'platforms': ['linux', 'mac', 'win'],
- 'products': ['chrome'],
- 'features': {'dynamic_refresh': 1},
- 'example_value': True
- }
- }]
+ 'type': 'main',
+ 'annotations': {
+ 'platforms': ['linux', 'mac', 'win'],
+ 'products': ['chrome'],
+ 'features': {'dynamic_refresh': 1},
+ 'example_value': True
+ }
},
{
- 'name': 'RestoreOnStartup',
+ 'name': 'RestoreOnStartupGroup',
+ 'type': 'group',
'policies': [{
'name': 'RestoreOnStartup',
'type': 'enum',
@@ -390,6 +336,7 @@
},
{
'name': 'ChromeFrameRendererSettings',
+ 'type': 'group',
'policies': [{
'name': 'ChromeFrameRendererSettings',
'type': 'enum',
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 bcf5b8f..8c02d96 100644
--- a/tools/grit/grit/format/policy_templates/policy_template_generator.py
+++ b/tools/grit/grit/format/policy_templates/policy_template_generator.py
@@ -12,107 +12,81 @@ class PolicyTemplateGenerator:
this data to policy template files using TemplateWriter objects.
'''
- def __init__(self, messages, policy_groups):
+ def __init__(self, messages, policy_definitions):
'''Initializes this object with all the data necessary to output a
policy template.
Args:
messages: An identifier to string dictionary of all the localized
messages that might appear in the policy template.
- 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 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': [...]}
- ]
- },
- {'name': 'PolicyGroup2', ...}
- ]
- See chrome/app/policy.policy_templates.json for an example and more
- details.
+ policy_definitions: The list of defined policies and groups, as
+ parsed from the polify metafile.
+ See chrome/app/policy.policy_templates.json for description and
+ content.
'''
# List of all the policies:
- self._policy_groups = policy_groups
+ self._policy_definitions = policy_definitions
# Localized messages to be inserted to the policy_groups structure:
self._messages = messages
- self._AddMessagesToPolicies()
+ self._AddMessagesToPolicyList(self._policy_definitions)
- 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).
+ def _AddMessageToItem(self, item_name, item, message_name, default=None):
+ '''Adds a localized message strings to an item of the policy data structure
Args:
item_name: The base of the grd name of the item.
- item: The item which will get its message strings now.
- 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.
+ item: The policy, group, or enum item.
+ message_name: Identifier of the message: 'desc', 'caption' or 'label'.
+ default: If this is specified and the message is not found for item,
+ then this string will be added to the item.
Raises:
- Exception() if a required message string was not found.
+ Exception() if the message string was not found and no default was
+ specified..
'''
# The keys for the item's messages in self._messages:
- caption_name = 'IDS_POLICY_%s_CAPTION' % item_name
- desc_name = 'IDS_POLICY_%s_DESC' % item_name
+ long_message_name = ('IDS_POLICY_%s_%s' %
+ (item_name.upper(), message_name.upper()))
# Copy the messages from self._messages to item:
- 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))
+ if long_message_name in self._messages:
+ item[message_name] = self._messages[long_message_name]
+ elif default != None:
+ item[message_name] = default
+ else:
+ raise Exception('No localized message for %s (missing %s).' %
+ (item_name, long_message_name))
def _AddMessagesToPolicy(self, policy):
- '''Adds localized message strings to a policy.
+ '''Adds localized message strings to a policy or group.
Args:
- policy: The data structure of the policy that will get message strings
- here.
+ policy: The data structure of the policy or group, 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:
- # Add caption for this policy.
- self._AddMessagesToItem(full_name, policy, True, False)
- if policy['type'] == 'enum':
+ self._AddMessageToItem(policy['name'], policy, 'caption')
+ self._AddMessageToItem(policy['name'], policy, 'desc')
+ if policy['type'] != 'group':
+ # Real policies (that are not groups) might also have an optional
+ # 'label', that defaults to 'caption'.
+ self._AddMessageToItem(
+ policy['name'], policy, 'label', policy['caption'])
+ if policy['type'] == 'group':
+ self._AddMessagesToPolicyList(policy['policies'])
+ elif 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)
+ self._AddMessageToItem('ENUM_' + item['name'], item, 'caption')
- def _AddMessagesToPolicies(self):
- '''Adds localized message strings to each item of the policy data structure
- (self._policy_groups).
+ def _AddMessagesToPolicyList(self, policy_list):
+ '''Adds localized message strings to each item in a list of policies and
+ groups.
+
+ Args:
+ policy_list: A list of policies and groups. Message strings will be added
+ for each item and to their child items, recursively.
'''
- # Iterate through all the policy groups.
- 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, True)
- if 'policies' in group:
- # Iterate through all the policies in the current group.
- for policy in group['policies']:
- # Add messages to the policy.
- self._AddMessagesToPolicy(policy)
- # Store a reference to the group of the policy. This makes
- # it easier to look up messages of the group when we have
- # a policy, like in PListStringsWriter and DocWriter.
- policy['parent'] = group
+ for policy in policy_list:
+ self._AddMessagesToPolicy(policy)
def GetTemplateText(self, template_writer):
'''Generates the text of the template from the arguments given
@@ -125,4 +99,4 @@ class PolicyTemplateGenerator:
Returns:
The text of the generated template.
'''
- return template_writer.WriteTemplate(self._policy_groups)
+ return template_writer.WriteTemplate(self._policy_definitions)
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 f2f6c66..7a07077 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
@@ -67,17 +67,17 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
def testEmptyGroups(self):
# Test that empty policy groups are not passed to the writer.
messages_mock = {
- 'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_DESC': None,
- 'IDS_POLICY_GROUP_GROUP2_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP2_DESC': None,
- 'IDS_POLICY_GROUP_GROUP3_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP3_DESC': None,
+ 'IDS_POLICY_GROUP1_CAPTION': '',
+ 'IDS_POLICY_GROUP1_DESC': '',
+ 'IDS_POLICY_GROUP2_CAPTION': '',
+ 'IDS_POLICY_GROUP2_DESC': '',
+ 'IDS_POLICY_GROUP3_CAPTION': '',
+ 'IDS_POLICY_GROUP3_DESC': '',
}
policies_mock = [
- {'name': 'Group1', 'policies': []},
- {'name': 'Group2', 'policies': []},
- {'name': 'Group3', 'policies': []},
+ {'name': 'Group1', 'type': 'group', 'policies': []},
+ {'name': 'Group2', 'type': 'group', 'policies': []},
+ {'name': 'Group3', 'type': 'group', 'policies': []},
]
class LocalMockWriter(mock_writer.MockWriter):
def __init__(self):
@@ -93,20 +93,23 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
def testGroups(self):
# Test that policy groups are passed to the writer in the correct order.
messages_mock = {
- 'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_DESC': None,
- 'IDS_POLICY_GROUP_GROUP2_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP2_DESC': None,
- 'IDS_POLICY_GROUP_GROUP3_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP3_DESC': None,
- 'IDS_POLICY_TAG1_CAPTION': None,
- 'IDS_POLICY_TAG2_CAPTION': None,
- 'IDS_POLICY_TAG3_CAPTION': None,
+ 'IDS_POLICY_GROUP1_CAPTION': '',
+ 'IDS_POLICY_GROUP1_DESC': '',
+ 'IDS_POLICY_GROUP2_CAPTION': '',
+ 'IDS_POLICY_GROUP2_DESC': '',
+ 'IDS_POLICY_GROUP3_CAPTION': '',
+ 'IDS_POLICY_GROUP3_DESC': '',
+ 'IDS_POLICY_TAG1_CAPTION': '',
+ 'IDS_POLICY_TAG1_DESC': '',
+ 'IDS_POLICY_TAG2_CAPTION': '',
+ 'IDS_POLICY_TAG2_DESC': '',
+ 'IDS_POLICY_TAG3_CAPTION': '',
+ 'IDS_POLICY_TAG3_DESC': '',
}
policies_mock = [
- {'name': 'Group1', 'policies': [{'name': 'TAG1', 'type': 'mock'}]},
- {'name': 'Group2', 'policies': [{'name': 'TAG2', 'type': 'mock'}]},
- {'name': 'Group3', 'policies': [{'name': 'TAG3', 'type': 'mock'}]},
+ {'name': 'Group1', 'type': 'group', 'policies': [{'name': 'TAG1', 'type': 'mock'}]},
+ {'name': 'Group2', 'type': 'group', 'policies': [{'name': 'TAG2', 'type': 'mock'}]},
+ {'name': 'Group3', 'type': 'group', 'policies': [{'name': 'TAG3', 'type': 'mock'}]},
]
class LocalMockWriter(mock_writer.MockWriter):
def __init__(self):
@@ -122,14 +125,14 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
def testGroupTexts(self):
# Test that GUI strings are assigned correctly to policy groups.
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',
+ 'IDS_POLICY_GROUP1_CAPTION': 'string1',
+ 'IDS_POLICY_GROUP1_DESC': 'string2',
+ 'IDS_POLICY_GROUP2_CAPTION': 'string3',
+ 'IDS_POLICY_GROUP2_DESC': 'string4',
}
policy_groups_mock = [
- {'name': 'Group1'},
- {'name': 'Group2'},
+ {'name': 'Group1', 'type': 'group', 'policies': []},
+ {'name': 'Group2', 'type': 'group', 'policies': []},
]
class LocalMockWriter(mock_writer.MockWriter):
def BeginPolicyGroup(self, group):
@@ -146,17 +149,21 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
def testPolicies(self):
# Test that policies are passed to the writer in the correct order.
messages_mock = {
- 'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_DESC': None,
- 'IDS_POLICY_GROUP_GROUP2_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP2_DESC': None,
- 'IDS_POLICY_GROUP1POLICY1_CAPTION': None,
- 'IDS_POLICY_GROUP1POLICY2_CAPTION': None,
- 'IDS_POLICY_GROUP2POLICY3_CAPTION': None,
+ 'IDS_POLICY_GROUP1_CAPTION': '',
+ 'IDS_POLICY_GROUP1_DESC': '',
+ 'IDS_POLICY_GROUP2_CAPTION': '',
+ 'IDS_POLICY_GROUP2_DESC': '',
+ 'IDS_POLICY_GROUP1POLICY1_CAPTION': '',
+ 'IDS_POLICY_GROUP1POLICY1_DESC': '',
+ 'IDS_POLICY_GROUP1POLICY2_CAPTION': '',
+ 'IDS_POLICY_GROUP1POLICY2_DESC': '',
+ 'IDS_POLICY_GROUP2POLICY3_CAPTION': '',
+ 'IDS_POLICY_GROUP2POLICY3_DESC': '',
}
policy_groups_mock = [
{
'name': 'Group1',
+ 'type': 'group',
'policies': [
{'name': 'Group1Policy1', 'type': 'string'},
{'name': 'Group1Policy2', 'type': 'string'},
@@ -164,6 +171,7 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
},
{
'name': 'Group2',
+ 'type': 'group',
'policies': [
{'name': 'Group2Policy3', 'type': 'string'},
]
@@ -193,12 +201,13 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'IDS_POLICY_POLICY1_DESC': 'string2',
'IDS_POLICY_POLICY2_CAPTION': 'string3',
'IDS_POLICY_POLICY2_DESC': 'string4',
- 'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_DESC': None,
+ 'IDS_POLICY_GROUP1_CAPTION': '',
+ 'IDS_POLICY_GROUP1_DESC': '',
}
policy_groups_mock = [
{
'name': 'Group1',
+ 'type': 'group',
'policies': [
{'name': 'Policy1', 'type': 'string'},
{'name': 'Policy2', 'type': 'string'}
@@ -224,24 +233,20 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
'IDS_POLICY_ENUM_ITEM1_CAPTION': 'string1',
'IDS_POLICY_ENUM_ITEM2_CAPTION': 'string2',
'IDS_POLICY_ENUM_ITEM3_CAPTION': 'string3',
- 'IDS_POLICY_POLICY1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_DESC': None,
+ 'IDS_POLICY_POLICY1_CAPTION': '',
+ 'IDS_POLICY_POLICY1_DESC': '',
+
}
- policy_groups_mock = [
- {
- 'name': 'Group1',
- 'policies': [{
- 'name': 'Policy1',
- 'type': 'enum',
- 'items': [
- {'name': 'item1', 'value': '0'},
- {'name': 'item2', 'value': '1'},
- {'name': 'item3', 'value': '3'},
- ]
- }]
- }
- ]
+ policy_groups_mock = [{
+ 'name': 'Policy1',
+ 'type': 'enum',
+ 'items': [
+ {'name': 'item1', 'value': '0'},
+ {'name': 'item2', 'value': '1'},
+ {'name': 'item3', 'value': '3'},
+ ]
+ }]
+
class LocalMockWriter(mock_writer.MockWriter):
def WritePolicy(self, policy):
self.tester.assertEquals(policy['items'][0]['caption'], 'string1')
@@ -252,16 +257,20 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
def testPolicyFiltering(self):
# Test that policies are filtered correctly based on their annotations.
messages_mock = {
- 'IDS_POLICY_GROUP_GROUP1_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP1_DESC': None,
- 'IDS_POLICY_GROUP_GROUP2_CAPTION': None,
- 'IDS_POLICY_GROUP_GROUP2_DESC': None,
- 'IDS_POLICY_GROUP1POLICY1_CAPTION': None,
- 'IDS_POLICY_GROUP1POLICY2_CAPTION': None,
- 'IDS_POLICY_GROUP2POLICY3_CAPTION': None,
+ 'IDS_POLICY_GROUP1_CAPTION': '',
+ 'IDS_POLICY_GROUP1_DESC': '',
+ 'IDS_POLICY_GROUP2_CAPTION': '',
+ 'IDS_POLICY_GROUP2_DESC': '',
+ 'IDS_POLICY_GROUP1POLICY1_CAPTION': '',
+ 'IDS_POLICY_GROUP1POLICY1_DESC': '',
+ 'IDS_POLICY_GROUP1POLICY2_CAPTION': '',
+ 'IDS_POLICY_GROUP1POLICY2_DESC': '',
+ 'IDS_POLICY_GROUP2POLICY3_CAPTION': '',
+ 'IDS_POLICY_GROUP2POLICY3_DESC': '',
}
policy_groups_mock = [{
'name': 'Group1',
+ 'type': 'group',
'policies': [
{
'name': 'Group1Policy1',
@@ -276,6 +285,7 @@ class PolicyTemplateGeneratorUnittest(unittest.TestCase):
]
},{
'name': 'Group2',
+ 'type': 'group',
'policies': [
{
'name': 'Group2Policy3',
diff --git a/tools/grit/grit/format/policy_templates/template_formatter.py b/tools/grit/grit/format/policy_templates/template_formatter.py
index 8e03aac..4fd28eb 100644
--- a/tools/grit/grit/format/policy_templates/template_formatter.py
+++ b/tools/grit/grit/format/policy_templates/template_formatter.py
@@ -76,7 +76,7 @@ class TemplateFormatter(interface.ItemFormatter):
'''
policy_generator = policy_template_generator.PolicyTemplateGenerator(
self._messages,
- self._policy_data['policy_groups'])
+ self._policy_data['policy_definitions'])
writer = self._writer_module.GetWriter(self._config, self._messages)
str = policy_generator.GetTemplateText(writer)
return str
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 bea1e38..23df695 100644
--- a/tools/grit/grit/format/policy_templates/writers/adm_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/adm_writer.py
@@ -25,27 +25,6 @@ class AdmWriter(template_writer.TemplateWriter):
'list': 'LISTBOX'}
NEWLINE = '\r\n'
- # TODO(gfeher): Get rid of this logic by renaming the messages in the .grd
- # file. Before that, all the writers should switch to using
- # this logic.
- def _GetLocalizedPolicyMessage(self, policy, msg_id):
- '''Looks up localized caption or description for a policy.
- If the policy does not have the required message, then it is
- inherited from the group.
-
- Args:
- policy: The data structure of the policy.
- msg_id: Either 'caption' or 'desc'.
-
- Returns:
- The corresponding message for the policy.
- '''
- if msg_id in policy:
- msg = policy[msg_id]
- else:
- msg = policy['parent'][msg_id]
- return msg
-
def _AddGuiString(self, name, value):
# Escape newlines in the value.
value = value.replace('\n','\\n')
@@ -82,9 +61,8 @@ class AdmWriter(template_writer.TemplateWriter):
Args:
policy: The policy to write to the output.
'''
- policy_caption = self._GetLocalizedPolicyMessage(policy, 'caption')
policy_part_name = policy['name'] + '_Part'
- self._AddGuiString(policy_part_name, policy_caption)
+ self._AddGuiString(policy_part_name, policy['label'])
# Print the PART ... END PART section:
self._PrintLine()
@@ -108,14 +86,11 @@ class AdmWriter(template_writer.TemplateWriter):
self._PrintLine('END PART', -1)
def WritePolicy(self, policy):
- policy_desc = self._GetLocalizedPolicyMessage(policy, 'desc')
- policy_caption = self._GetLocalizedPolicyMessage(policy, 'caption')
-
- self._AddGuiString(policy['name'] + '_Policy', policy_caption)
+ self._AddGuiString(policy['name'] + '_Policy', policy['caption'])
self._PrintLine('POLICY !!%s_Policy' % policy['name'], 1)
self._WriteSupported()
policy_explain_name = policy['name'] + '_Explain'
- self._AddGuiString(policy_explain_name, policy_desc)
+ self._AddGuiString(policy_explain_name, policy['desc'])
self._PrintLine('EXPLAIN !!' + policy_explain_name)
if policy['type'] == 'main':
diff --git a/tools/grit/grit/format/policy_templates/writers/adm_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/adm_writer_unittest.py
index 1fa1b01..6c75d2b 100644
--- a/tools/grit/grit/format/policy_templates/writers/adm_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/adm_writer_unittest.py
@@ -42,7 +42,7 @@ class AdmWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# Test PListWriter in case of empty polices.
grd = self.PrepareTest('''
{
- 'policy_groups': [],
+ 'policy_definitions': [],
'placeholders': [],
}''', '''
<messages>
@@ -65,21 +65,18 @@ chromium="Chromium"'''
# Tests a policy group with a single policy of type 'main'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
- 'name': 'MainGroup',
- 'policies': [{
- 'name': 'MainPolicy',
- 'type': 'main',
- 'annotations': {'platforms': ['win']}
- }],
+ 'name': 'MainPolicy',
+ 'type': 'main',
+ 'annotations': {'platforms': ['win']}
},
],
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_MAINGROUP_CAPTION">Caption of main.</message>
- <message name="IDS_POLICY_GROUP_MAINGROUP_DESC">Description of main.</message>
+ <message name="IDS_POLICY_MAINPOLICY_CAPTION">Caption of main.</message>
+ <message name="IDS_POLICY_MAINPOLICY_DESC">Description of main.</message>
<message name="IDS_POLICY_WIN_SUPPORTED_WINXPSP2">At least Windows 3.12</message>
</messages>
''' )
@@ -114,23 +111,19 @@ MainPolicy_Explain="Description of main."'''
# Tests a policy group with a single policy of type 'string'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
- 'name': 'StringGroup',
- 'policies': [{
- 'name': 'StringPolicy',
- 'type': 'string',
- 'annotations': {'platforms': ['win']}
- }],
+ 'name': 'StringPolicy',
+ 'type': 'string',
+ 'annotations': {'platforms': ['win']}
},
],
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_STRINGGROUP_CAPTION">Caption of group.</message>
- <message name="IDS_POLICY_GROUP_STRINGGROUP_DESC">Description of group.
-With a newline.</message>
<message name="IDS_POLICY_STRINGPOLICY_CAPTION">Caption of policy.</message>
+ <message name="IDS_POLICY_STRINGPOLICY_DESC">Description of group.
+With a newline.</message>
<message name="IDS_POLICY_WIN_SUPPORTED_WINXPSP2">At least Windows 3.13</message>
</messages>
''' )
@@ -165,25 +158,20 @@ StringPolicy_Part="Caption of policy."
# Tests a policy group with a single policy of type 'enum'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
- 'name': 'EnumGroup',
- 'policies': [{
- 'name': 'EnumPolicy',
- 'type': 'enum',
- 'items': [
- {'name': 'ProxyServerDisabled', 'value': '0'},
- {'name': 'ProxyServerAutoDetect', 'value': '1'},
- ],
- 'annotations': {'platforms': ['win']}
- }],
+ 'name': 'EnumPolicy',
+ 'type': 'enum',
+ 'items': [
+ {'name': 'ProxyServerDisabled', 'value': '0'},
+ {'name': 'ProxyServerAutoDetect', 'value': '1'},
+ ],
+ 'annotations': {'platforms': ['win']}
},
],
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_ENUMGROUP_CAPTION">Caption of group.</message>
- <message name="IDS_POLICY_GROUP_ENUMGROUP_DESC">Description of group.</message>
<message name="IDS_POLICY_ENUMPOLICY_CAPTION">Caption of policy.</message>
<message name="IDS_POLICY_ENUMPOLICY_DESC">Description of policy.</message>
<message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">Option1</message>
@@ -231,23 +219,20 @@ ProxyServerAutoDetect_DropDown="Option2"
# Tests a policy group with a single policy of type 'list'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
- 'name': 'ListGroup',
- 'policies': [{
- 'name': 'ListPolicy',
- 'type': 'list',
- 'annotations': {'platforms': ['win']}
- }],
+ 'name': 'ListPolicy',
+ 'type': 'list',
+ 'annotations': {'platforms': ['win']}
},
],
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_LISTGROUP_CAPTION">Caption of list group.</message>
- <message name="IDS_POLICY_GROUP_LISTGROUP_DESC">Description of list group.
+ <message name="IDS_POLICY_LISTPOLICY_DESC">Description of list policy.
With a newline.</message>
<message name="IDS_POLICY_LISTPOLICY_CAPTION">Caption of list policy.</message>
+ <message name="IDS_POLICY_LISTPOLICY_LABEL">Value caption of list policy.</message>
<message name="IDS_POLICY_WIN_SUPPORTED_WINXPSP2">At least Windows 3.15</message>
</messages>
''')
@@ -274,8 +259,8 @@ With a newline.</message>
SUPPORTED_WINXPSP2="At least Windows 3.15"
chromium="Chromium"
ListPolicy_Policy="Caption of list policy."
-ListPolicy_Explain="Description of list group.\\nWith a newline."
-ListPolicy_Part="Caption of list policy."
+ListPolicy_Explain="Description of list policy.\\nWith a newline."
+ListPolicy_Part="Value caption of list policy."
'''
self.CompareOutputs(output, expected_output)
@@ -284,9 +269,10 @@ ListPolicy_Part="Caption of list policy."
# be included in the ADM file.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'NonWinGroup',
+ 'type': 'group',
'policies': [{
'name': 'NonWinPolicy',
'type': 'list',
@@ -297,9 +283,10 @@ ListPolicy_Part="Caption of list policy."
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_NONWINGROUP_CAPTION">Group caption.</message>
- <message name="IDS_POLICY_GROUP_NONWINGROUP_DESC">Group description.</message>
+ <message name="IDS_POLICY_NONWINGROUP_CAPTION">Group caption.</message>
+ <message name="IDS_POLICY_NONWINGROUP_DESC">Group description.</message>
<message name="IDS_POLICY_NONWINPOLICY_CAPTION">Caption of list policy.</message>
+ <message name="IDS_POLICY_NONWINPOLICY_DESC">Desc of list policy.</message>
<message name="IDS_POLICY_WIN_SUPPORTED_WINXPSP2">At least Windows 3.16</message>
</messages>
''')
@@ -320,9 +307,10 @@ chromium="Chromium"
# Tests a policy group that has more than one policies.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'Group1',
+ 'type': 'group',
'policies': [{
'name': 'Policy1',
'type': 'list',
@@ -337,8 +325,8 @@ chromium="Chromium"
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_GROUP1_CAPTION">Caption of group.</message>
- <message name="IDS_POLICY_GROUP_GROUP1_DESC">Description of group.</message>
+ <message name="IDS_POLICY_GROUP1_CAPTION">Caption of group.</message>
+ <message name="IDS_POLICY_GROUP1_DESC">Description of group.</message>
<message name="IDS_POLICY_POLICY1_DESC">Description of policy1.
With a newline.</message>
<message name="IDS_POLICY_POLICY2_DESC">Description of policy2.
diff --git a/tools/grit/grit/format/policy_templates/writers/doc_writer.py b/tools/grit/grit/format/policy_templates/writers/doc_writer.py
index ad28ace..cde4227 100644
--- a/tools/grit/grit/format/policy_templates/writers/doc_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/doc_writer.py
@@ -32,25 +32,6 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter):
files.
'''
- # TODO(gfeher): This function is duplicated in PListWriter.
- def _GetLocalizedPolicyMessage(self, policy, msg_id):
- '''Looks up localized caption or description for a policy.
- If the policy does not have the required message, then it is
- inherited from the group.
-
- Args:
- policy: The data structure of the policy.
- msg_id: Either 'caption' or 'desc'.
-
- Returns:
- The corresponding message for the policy.
- '''
- if msg_id in policy:
- msg = policy[msg_id]
- else:
- msg = policy['parent'][msg_id]
- return msg
-
def _GetLocalizedMessage(self, msg_id):
'''Returns a localized message for this writer.
@@ -131,9 +112,8 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter):
parent: The DOM node for which the feature list will be added.
policy: The data structure of a policy.
'''
- desc = self._GetLocalizedPolicyMessage(policy, 'desc')
# Replace URLs with links in the description.
- self._AddTextWithLinks(parent, desc)
+ self._AddTextWithLinks(parent, policy['desc'])
# Add list of enum items.
if policy['type'] == 'enum':
ul = self.AddElement(parent, 'ul')
@@ -370,13 +350,12 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter):
parent: The DOM node of the summary table.
policy: The data structure of the policy.
'''
- caption = self._GetLocalizedPolicyMessage(policy, 'caption')
tr = self._AddStyledElement(parent, 'tr', ['tr'])
name_td = self._AddStyledElement(tr, 'td', ['td', 'td.left'])
self.AddElement(
name_td, 'a',
{'href': '#' + policy['name']}, policy['name'])
- self._AddStyledElement(tr, 'td', ['td', 'td.right'], {}, caption)
+ self._AddStyledElement(tr, 'td', ['td', 'td.right'], {}, policy['caption'])
def _AddPolicySection(self, parent, policy):
'''Adds a section about the policy in the detailed policy listing.
@@ -386,10 +365,9 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter):
policy: The data structure of the policy.
'''
h2 = self.AddElement(parent, 'h2')
- caption = self._GetLocalizedPolicyMessage(policy, 'caption')
self.AddElement(h2, 'a', {'name': policy['name']})
self.AddText(h2, policy['name'])
- self.AddElement(parent, 'span', {}, caption)
+ self.AddElement(parent, 'span', {}, policy['caption'])
self._AddPolicyNote(parent, policy)
self._AddPolicyDetails(parent, policy)
diff --git a/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
index 2166916..a394db7 100644
--- a/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py
@@ -104,21 +104,6 @@ class DocWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'<div/>'
'</div>')
- def testGetLocalizedPolicyMessage(self):
- # Test if the message inheritance logic works well in
- # DocWriter.GetLocalizedPolicyMessage()
- policy = {'message_id1': '1hello, world'}
- self.assertEquals(
- self.writer._GetLocalizedPolicyMessage(policy, 'message_id1'),
- '1hello, world')
- self.assertRaises(
- KeyError,
- self.writer._GetLocalizedPolicyMessage, policy, 'message_id2')
- policy['parent'] = {'message_id3': '3hello, world'}
- self.assertEquals(
- self.writer._GetLocalizedPolicyMessage(policy, 'message_id3'),
- '3hello, world')
-
def testGetLocalizedMessage(self):
# Test if localized messages are retrieved correctly.
self.writer.messages = {
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py
index 47b1816..e85d85e 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py
@@ -20,25 +20,6 @@ class PListStringsWriter(template_writer.TemplateWriter):
[lang].lproj subdirectories of the manifest bundle.
'''
- # TODO(gfeher): This function is duplicated in DocWriter.
- def _GetLocalizedPolicyMessage(self, policy, msg_id):
- '''Looks up localized caption or description for a policy.
- If the policy does not have the required message, then it is
- inherited from the group.
-
- Args:
- policy: The data structure of the policy.
- msg_id: Either 'caption' or 'desc'.
-
- Returns:
- The corresponding message for the policy.
- '''
- if msg_id in policy:
- msg = policy[msg_id]
- else:
- msg = policy['parent'][msg_id]
- return msg
-
def _AddToStringTable(self, item_name, caption, desc):
'''Add a title and a description of an item to the string table.
@@ -62,8 +43,7 @@ class PListStringsWriter(template_writer.TemplateWriter):
policy: The policy for which the strings will be added to the
string table.
'''
- desc = self._GetLocalizedPolicyMessage(policy, 'desc')
- caption = self._GetLocalizedPolicyMessage(policy, 'caption')
+ desc = policy['desc']
if (policy['type'] == 'enum'):
# Append the captions of enum items to the description string.
item_descs = []
@@ -71,7 +51,7 @@ class PListStringsWriter(template_writer.TemplateWriter):
item_descs.append(item['value'] + ' - ' + item['caption'])
desc = '\n'.join(item_descs) + '\n' + desc
- self._AddToStringTable(policy['name'], caption, desc)
+ self._AddToStringTable(policy['name'], policy['label'], desc)
def BeginTemplate(self):
self._AddToStringTable(
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py
index b604511..e8e8463 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py
@@ -28,7 +28,7 @@ class PListStringsWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# Test PListStringsWriter in case of empty polices.
grd = self.PrepareTest('''
{
- 'policy_groups': [],
+ 'policy_definitions': [],
'placeholders': [],
}''', '''
<messages>
@@ -51,9 +51,10 @@ Chromium.pfm_description = "Chromium preferen\\"ces";
# Tests a policy group with a single policy of type 'main'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'MainGroup',
+ 'type': 'group',
'policies': [{
'name': 'MainPolicy',
'type': 'main',
@@ -64,8 +65,10 @@ Chromium.pfm_description = "Chromium preferen\\"ces";
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_MAINGROUP_CAPTION">Caption of main.</message>
- <message name="IDS_POLICY_GROUP_MAINGROUP_DESC">Title of main.</message>
+ <message name="IDS_POLICY_MAINGROUP_CAPTION">Caption of main.</message>
+ <message name="IDS_POLICY_MAINGROUP_DESC">Title of main.</message>
+ <message name="IDS_POLICY_MAINPOLICY_CAPTION">Caption of main policy.</message>
+ <message name="IDS_POLICY_MAINPOLICY_DESC">Title of main policy.</message>
<message name="IDS_POLICY_MAC_CHROME_PREFERENCES">Preferences of $1</message>
</messages>
''' )
@@ -78,8 +81,8 @@ Chromium.pfm_description = "Chromium preferen\\"ces";
expected_output = \
'''Google Chrome.pfm_title = "Google Chrome";
Google Chrome.pfm_description = "Preferences of Google Chrome";
-MainPolicy.pfm_title = "Caption of main.";
-MainPolicy.pfm_description = "Title of main.";
+MainPolicy.pfm_title = "Caption of main policy.";
+MainPolicy.pfm_description = "Title of main policy.";
'''
self.assertEquals(output.strip(), expected_output.strip())
@@ -88,9 +91,10 @@ MainPolicy.pfm_description = "Title of main.";
# inheriting group description to policy description.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'StringGroup',
+ 'type': 'group',
'policies': [{
'name': 'StringPolicy',
'type': 'string',
@@ -101,10 +105,12 @@ MainPolicy.pfm_description = "Title of main.";
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_STRINGGROUP_CAPTION">Caption of group.</message>
- <message name="IDS_POLICY_GROUP_STRINGGROUP_DESC">Description of group.
+ <message name="IDS_POLICY_STRINGGROUP_CAPTION">Caption of group.</message>
+ <message name="IDS_POLICY_STRINGGROUP_DESC">Description of group.
With a newline.</message>
<message name="IDS_POLICY_STRINGPOLICY_CAPTION">Caption of policy.</message>
+ <message name="IDS_POLICY_STRINGPOLICY_DESC">Description of policy.
+With a newline.</message>
<message name="IDS_POLICY_MAC_CHROME_PREFERENCES">Preferences Of $1</message>
</messages>
''' )
@@ -118,7 +124,7 @@ With a newline.</message>
'''Chromium.pfm_title = "Chromium";
Chromium.pfm_description = "Preferences Of Chromium";
StringPolicy.pfm_title = "Caption of policy.";
-StringPolicy.pfm_description = "Description of group.\\nWith a newline.";
+StringPolicy.pfm_description = "Description of policy.\\nWith a newline.";
'''
self.assertEquals(output.strip(), expected_output.strip())
@@ -126,9 +132,10 @@ StringPolicy.pfm_description = "Description of group.\\nWith a newline.";
# Tests a policy group with a single policy of type 'enum'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'EnumGroup',
+ 'type': 'group',
'policies': [{
'name': 'EnumPolicy',
'type': 'enum',
@@ -143,8 +150,8 @@ StringPolicy.pfm_description = "Description of group.\\nWith a newline.";
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_ENUMGROUP_CAPTION">Caption of group.</message>
- <message name="IDS_POLICY_GROUP_ENUMGROUP_DESC">Description of group.</message>
+ <message name="IDS_POLICY_ENUMGROUP_CAPTION">Caption of group.</message>
+ <message name="IDS_POLICY_ENUMGROUP_DESC">Description of group.</message>
<message name="IDS_POLICY_ENUMPOLICY_CAPTION">Caption of policy.</message>
<message name="IDS_POLICY_ENUMPOLICY_DESC">Description of policy.</message>
<message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">Option1</message>
@@ -171,9 +178,10 @@ EnumPolicy.pfm_description = "0 - Option1\\n1 - Option2\\nDescription of policy.
# be included in the plist string table.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'NonMacGroup',
+ 'type': 'group',
'policies': [{
'name': 'NonMacPolicy',
'type': 'string',
@@ -184,9 +192,10 @@ EnumPolicy.pfm_description = "0 - Option1\\n1 - Option2\\nDescription of policy.
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_NONMACGROUP_CAPTION">Caption of group.</message>
- <message name="IDS_POLICY_GROUP_NONMACGROUP_DESC">Description of group.</message>
+ <message name="IDS_POLICY_NONMACGROUP_CAPTION">Caption of group.</message>
+ <message name="IDS_POLICY_NONMACGROUP_DESC">Description of group.</message>
<message name="IDS_POLICY_NONMACPOLICY_CAPTION">Caption of policy.</message>
+ <message name="IDS_POLICY_NONMACPOLICY_DESC">Description of policy.</message>
<message name="IDS_POLICY_MAC_CHROME_PREFERENCES">$1 preferences</message>
</messages>
''' )
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py
index 157a258..4b21ec4 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py
@@ -63,7 +63,7 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# Test PListWriter in case of empty polices.
grd = self.PrepareTest('''
{
- 'policy_groups': [],
+ 'policy_definitions': [],
'placeholders': [],
}''', '''<messages />''' )
@@ -81,9 +81,10 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# Tests a policy group with a single policy of type 'main'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'MainGroup',
+ 'type': 'group',
'policies': [{
'name': 'MainPolicy',
'type': 'main',
@@ -94,8 +95,10 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_MAINGROUP_CAPTION">This is not tested here.</message>
- <message name="IDS_POLICY_GROUP_MAINGROUP_DESC">This is not tested here.</message>
+ <message name="IDS_POLICY_MAINGROUP_CAPTION">This is not tested here.</message>
+ <message name="IDS_POLICY_MAINGROUP_DESC">This is not tested here.</message>
+ <message name="IDS_POLICY_MAINPOLICY_CAPTION">This is not tested here.</message>
+ <message name="IDS_POLICY_MAINPOLICY_DESC">This is not tested here.</message>
</messages>
''' )
output = self.GetOutput(
@@ -127,9 +130,10 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# Tests a policy group with a single policy of type 'string'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'StringGroup',
+ 'type': 'group',
'policies': [{
'name': 'StringPolicy',
'type': 'string',
@@ -140,8 +144,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_STRINGGROUP_CAPTION">This is not tested here.</message>
- <message name="IDS_POLICY_GROUP_STRINGGROUP_DESC">This is not tested here.</message>
+ <message name="IDS_POLICY_STRINGGROUP_CAPTION">This is not tested here.</message>
+ <message name="IDS_POLICY_STRINGGROUP_DESC">This is not tested here.</message>
<message name="IDS_POLICY_STRINGPOLICY_CAPTION">This is not tested here.</message>
<message name="IDS_POLICY_STRINGPOLICY_DESC">This is not tested here.</message>
</messages>
@@ -175,9 +179,10 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# Tests a policy group with a single policy of type 'enum'.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'EnumGroup',
+ 'type': 'group',
'policies': [{
'name': 'EnumPolicy',
'type': 'enum',
@@ -192,8 +197,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_ENUMGROUP_CAPTION">This is not tested here.</message>
- <message name="IDS_POLICY_GROUP_ENUMGROUP_DESC">This is not tested here.</message>
+ <message name="IDS_POLICY_ENUMGROUP_CAPTION">This is not tested here.</message>
+ <message name="IDS_POLICY_ENUMGROUP_DESC">This is not tested here.</message>
<message name="IDS_POLICY_ENUMPOLICY_CAPTION">This is not tested here.</message>
<message name="IDS_POLICY_ENUMPOLICY_DESC">This is not tested here.</message>
<message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">This is not tested here.</message>
@@ -235,9 +240,10 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
# be included in the plist file.
grd = self.PrepareTest('''
{
- 'policy_groups': [
+ 'policy_definitions': [
{
'name': 'NonMacGroup',
+ 'type': 'group',
'policies': [{
'name': 'NonMacPolicy',
'type': 'string',
@@ -248,9 +254,10 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
'placeholders': [],
}''', '''
<messages>
- <message name="IDS_POLICY_GROUP_NONMACGROUP_CAPTION">This is not tested here. (1)</message>
- <message name="IDS_POLICY_GROUP_NONMACGROUP_DESC">This is not tested here. (2)</message>
+ <message name="IDS_POLICY_NONMACGROUP_CAPTION">This is not tested here. (1)</message>
+ <message name="IDS_POLICY_NONMACGROUP_DESC">This is not tested here. (2)</message>
<message name="IDS_POLICY_NONMACPOLICY_CAPTION">This is not tested here. (3)</message>
+ <message name="IDS_POLICY_NONMACPOLICY_DESC">This is not tested here. (4)</message>
</messages>
''' )
output = self.GetOutput(
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 fd31c90..4af1e458 100644
--- a/tools/grit/grit/format/policy_templates/writers/template_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/template_writer.py
@@ -69,7 +69,6 @@ class TemplateWriter(object):
'''
pass
-
def WriteTemplate(self, template):
'''Writes the given template definition.
@@ -81,14 +80,18 @@ class TemplateWriter(object):
'''
self.Init()
self.BeginTemplate()
- for group in template:
- policies = self._GetPoliciesForWriter(group)
- if policies:
- # Only write nonempty groups.
- self.BeginPolicyGroup(group)
- for policy in policies:
- self.WritePolicy(policy)
- self.EndPolicyGroup()
+ for policy in template:
+ if policy['type'] == 'group':
+ child_policies = self._GetPoliciesForWriter(policy)
+ if child_policies:
+ # Only write nonempty groups.
+ self.BeginPolicyGroup(policy)
+ for child_policy in child_policies:
+ # Nesting of groups is currently not supported.
+ self.WritePolicy(child_policy)
+ self.EndPolicyGroup()
+ else:
+ self.WritePolicy(policy)
self.EndTemplate()
return self.GetTemplateText()