| Index: chrome/browser/resources/settings/site_settings/site_settings_behavior.js
|
| diff --git a/chrome/browser/resources/settings/site_settings/site_settings_behavior.js b/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
|
| index c541b8db9f1ff136caaf0b309b88974d66b5dbb9..5d9e2f60daa57630e3b3f8495b99b1a9ebad3f41 100644
|
| --- a/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
|
| +++ b/chrome/browser/resources/settings/site_settings/site_settings_behavior.js
|
| @@ -10,10 +10,10 @@
|
| var SiteSettingsBehaviorImpl = {
|
| properties: {
|
| /**
|
| - * The ID of the category this element is displaying data for.
|
| + * The string ID of the category this element is displaying data for.
|
| * See site_settings/constants.js for possible values.
|
| */
|
| - category: Number,
|
| + category: String,
|
|
|
| /**
|
| * The browser proxy used to retrieve and change information about site
|
| @@ -34,7 +34,7 @@ var SiteSettingsBehaviorImpl = {
|
| * for.
|
| * @param {string} secondaryPattern The secondary pattern to reset the
|
| * permission for.
|
| - * @param {number} category The category permission to change.
|
| + * @param {string} category The category permission to change.
|
| * @protected
|
| */
|
| resetCategoryPermissionForOrigin: function(
|
| @@ -49,7 +49,7 @@ var SiteSettingsBehaviorImpl = {
|
| * for.
|
| * @param {string} secondaryPattern The secondary pattern to change the
|
| * permission for.
|
| - * @param {number} category The category permission to change.
|
| + * @param {string} category The category permission to change.
|
| * @param {string} value What value to set the permission to.
|
| * @protected
|
| */
|
| @@ -60,13 +60,18 @@ var SiteSettingsBehaviorImpl = {
|
| },
|
|
|
| /**
|
| - * A utility function to lookup a category name from its enum.
|
| - * @param {number} category The category ID to look up.
|
| + * A utility function to lookup a category name from its enum. Note: The
|
| + * category name is visible to the user as part of the URL.
|
| + * @param {string} category The category ID to look up.
|
| * @return {string} The category found or blank string if not found.
|
| * @protected
|
| */
|
| computeCategoryTextId: function(category) {
|
| switch (category) {
|
| + case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS:
|
| + return 'automatic-downloads';
|
| + case settings.ContentSettingsTypes.BACKGROUND_SYNC:
|
| + return 'background-sync';
|
| case settings.ContentSettingsTypes.CAMERA:
|
| return 'camera';
|
| case settings.ContentSettingsTypes.COOKIES:
|
| @@ -77,12 +82,18 @@ var SiteSettingsBehaviorImpl = {
|
| return 'images';
|
| case settings.ContentSettingsTypes.JAVASCRIPT:
|
| return 'javascript';
|
| + case settings.ContentSettingsTypes.KEYGEN:
|
| + return 'keygen';
|
| case settings.ContentSettingsTypes.MIC:
|
| return 'microphone';
|
| case settings.ContentSettingsTypes.NOTIFICATIONS:
|
| return 'notifications';
|
| + case settings.ContentSettingsTypes.PLUGINS:
|
| + return 'plugins';
|
| case settings.ContentSettingsTypes.POPUPS:
|
| return 'popups';
|
| + case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS:
|
| + return 'unsandboxed-plugins';
|
| default:
|
| return '';
|
| }
|
| @@ -92,12 +103,16 @@ var SiteSettingsBehaviorImpl = {
|
| * A utility function to compute the icon to use for the category, both for
|
| * the overall category as well as the individual permission in the details
|
| * for a site.
|
| - * @param {number} category The category to show the icon for.
|
| + * @param {string} category The category to show the icon for.
|
| * @return {string} The id of the icon for the given category.
|
| * @protected
|
| */
|
| computeIconForContentCategory: function(category) {
|
| switch (category) {
|
| + case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS:
|
| + return 'settings:file-download';
|
| + case settings.ContentSettingsTypes.BACKGROUND_SYNC:
|
| + return 'settings:sync';
|
| case settings.ContentSettingsTypes.CAMERA:
|
| return 'settings:videocam';
|
| case settings.ContentSettingsTypes.COOKIES:
|
| @@ -110,12 +125,18 @@ var SiteSettingsBehaviorImpl = {
|
| return 'settings:photo';
|
| case settings.ContentSettingsTypes.JAVASCRIPT:
|
| return 'settings:input';
|
| + case settings.ContentSettingsTypes.KEYGEN:
|
| + return 'settings:code';
|
| case settings.ContentSettingsTypes.MIC:
|
| return 'settings:mic';
|
| case settings.ContentSettingsTypes.NOTIFICATIONS:
|
| return 'settings:notifications';
|
| + case settings.ContentSettingsTypes.PLUGINS:
|
| + return 'settings:extension';
|
| case settings.ContentSettingsTypes.POPUPS:
|
| return 'settings:open-in-new';
|
| + case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS:
|
| + return 'settings:extension';
|
| default:
|
| assertNotReached('Invalid category: ' + category);
|
| return '';
|
| @@ -126,12 +147,16 @@ var SiteSettingsBehaviorImpl = {
|
| * A utility function to compute the title of the category, both for
|
| * the overall category as well as the individual permission in the details
|
| * for a site.
|
| - * @param {number} category The category to show the title for.
|
| + * @param {string} category The category to show the title for.
|
| * @return {string} The title for the given category.
|
| * @protected
|
| */
|
| computeTitleForContentCategory: function(category) {
|
| switch (category) {
|
| + case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS:
|
| + return loadTimeData.getString('siteSettingsAutomaticDownloads');
|
| + case settings.ContentSettingsTypes.BACKGROUND_SYNC:
|
| + return loadTimeData.getString('siteSettingsBackgroundSync');
|
| case settings.ContentSettingsTypes.CAMERA:
|
| return loadTimeData.getString('siteSettingsCamera');
|
| case settings.ContentSettingsTypes.COOKIES:
|
| @@ -144,12 +169,18 @@ var SiteSettingsBehaviorImpl = {
|
| return loadTimeData.getString('siteSettingsImages');
|
| case settings.ContentSettingsTypes.JAVASCRIPT:
|
| return loadTimeData.getString('siteSettingsJavascript');
|
| + case settings.ContentSettingsTypes.KEYGEN:
|
| + return loadTimeData.getString('siteSettingsKeygen');
|
| case settings.ContentSettingsTypes.MIC:
|
| return loadTimeData.getString('siteSettingsMic');
|
| case settings.ContentSettingsTypes.NOTIFICATIONS:
|
| return loadTimeData.getString('siteSettingsNotifications');
|
| + case settings.ContentSettingsTypes.PLUGINS:
|
| + return loadTimeData.getString('siteSettingsPlugins');
|
| case settings.ContentSettingsTypes.POPUPS:
|
| return loadTimeData.getString('siteSettingsPopups');
|
| + case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS:
|
| + return loadTimeData.getString('siteSettingsUnsandboxedPlugins');
|
| default:
|
| assertNotReached('Invalid category: ' + category);
|
| return '';
|
| @@ -158,7 +189,7 @@ var SiteSettingsBehaviorImpl = {
|
|
|
| /**
|
| * A utility function to compute the description for the category.
|
| - * @param {number} category The category to show the description for.
|
| + * @param {string} category The category to show the description for.
|
| * @param {boolean} categoryEnabled The state of the global toggle.
|
| * @param {boolean} showRecommendation Whether to show the '(recommended)'
|
| * label prefix.
|
| @@ -191,8 +222,8 @@ var SiteSettingsBehaviorImpl = {
|
| return showRecommendation ?
|
| loadTimeData.getString('siteSettingsAskBeforeSendingRecommended') :
|
| loadTimeData.getString('siteSettingsAskBeforeSending');
|
| - case settings.ContentSettingsTypes.GEOLOCATION:
|
| case settings.ContentSettingsTypes.CAMERA:
|
| + case settings.ContentSettingsTypes.GEOLOCATION:
|
| case settings.ContentSettingsTypes.MIC:
|
| // "Ask before accessing (recommended)" vs "Blocked".
|
| if (!categoryEnabled) {
|
| @@ -217,6 +248,49 @@ var SiteSettingsBehaviorImpl = {
|
| return showRecommendation ?
|
| loadTimeData.getString('siteSettingsShowAllRecommended') :
|
| loadTimeData.getString('siteSettingsShowAll');
|
| + case settings.ContentSettingsTypes.PLUGINS:
|
| + // "Detect and run important content (recommended)" vs "Let me choose".
|
| + if (!categoryEnabled) {
|
| + return loadTimeData.getString('siteSettingsLetMeChoose');
|
| + }
|
| + return showRecommendation ?
|
| + loadTimeData.getString(
|
| + 'siteSettingsDetectAndRunImportantRecommended') :
|
| + loadTimeData.getString('siteSettingsDetectAndRunImportant');
|
| + case settings.ContentSettingsTypes.BACKGROUND_SYNC:
|
| + // "Allow sites to finish sending and receiving data" vs "Do not allow".
|
| + if (!categoryEnabled) {
|
| + return loadTimeData.getString('siteSettingsBackgroundSyncBlocked');
|
| + }
|
| + return showRecommendation ?
|
| + loadTimeData.getString(
|
| + 'siteSettingsAllowRecentlyClosedSitesRecommended') :
|
| + loadTimeData.getString('siteSettingsAllowRecentlyClosedSites');
|
| + case settings.ContentSettingsTypes.KEYGEN:
|
| + // "Allow sites to use keygen" vs "Do not allow".
|
| + if (categoryEnabled) {
|
| + return loadTimeData.getString('siteSettingsKeygenAllow');
|
| + }
|
| + return showRecommendation ?
|
| + loadTimeData.getString('siteSettingsKeygenBlockRecommended') :
|
| + loadTimeData.getString('siteSettingsKeygenBlock');
|
| + case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS:
|
| + // "Ask when a site wants to auto-download multiple" vs "Do not allow".
|
| + if (!categoryEnabled) {
|
| + return loadTimeData.getString('siteSettingsAutoDownloadBlock');
|
| + }
|
| + return showRecommendation ?
|
| + loadTimeData.getString('siteSettingsAutoDownloadAskRecommended') :
|
| + loadTimeData.getString('siteSettingsAutoDownloadAsk');
|
| + case settings.ContentSettingsTypes.UNSANDBOXED_PLUGINS:
|
| + // "Ask when a plugin accesses your computer" vs "Do not allow".
|
| + if (!categoryEnabled) {
|
| + return loadTimeData.getString('siteSettingsUnsandboxedPluginsBlock');
|
| + }
|
| + return showRecommendation ?
|
| + loadTimeData.getString(
|
| + 'siteSettingsUnsandboxedPluginsAskRecommended') :
|
| + loadTimeData.getString('siteSettingsUnsandboxedPluginsAsk');
|
| default:
|
| assertNotReached();
|
| return '';
|
| @@ -252,6 +326,37 @@ var SiteSettingsBehaviorImpl = {
|
| },
|
|
|
| /**
|
| + * Adds the wildcard prefix to a pattern string.
|
| + * @param {string} pattern The pattern to add the wildcard to.
|
| + * @return {string} The resulting pattern.
|
| + * @private
|
| + */
|
| + addPatternWildcard_: function(pattern) {
|
| + if (pattern.startsWith('http://'))
|
| + return pattern.replace('http://', 'http://[*.]');
|
| + else if (pattern.startsWith('https://'))
|
| + return pattern.replace('https://', 'https://[*.]');
|
| + else
|
| + return '[*.]' + pattern;
|
| + },
|
| +
|
| + /**
|
| + * Removes the wildcard prefix from a pattern string.
|
| + * @param {string} pattern The pattern to remove the wildcard from.
|
| + * @return {string} The resulting pattern.
|
| + * @private
|
| + */
|
| + removePatternWildcard_: function(pattern) {
|
| + if (pattern.startsWith('http://[*.]'))
|
| + return pattern.replace('http://[*.]', 'http://');
|
| + else if (pattern.startsWith('https://[*.]'))
|
| + return pattern.replace('https://[*.]', 'https://');
|
| + else if (pattern.startsWith('[*.]'))
|
| + return pattern.substring(4, pattern.length);
|
| + return pattern;
|
| + },
|
| +
|
| + /**
|
| * Returns the icon to use for a given site.
|
| * @param {SiteException} site The url of the site to fetch the icon for.
|
| * @return {string} The background-image style with the favicon.
|
|
|