| Index: chrome/browser/resources/settings/site_settings/site_list.js
|
| diff --git a/chrome/browser/resources/settings/site_settings/site_list.js b/chrome/browser/resources/settings/site_settings/site_list.js
|
| index 94fedf38a7e5140d1146fc8a5a48e7892fe48fa9..4c24964206ec390dd650bfa6982894233d3a2d57 100644
|
| --- a/chrome/browser/resources/settings/site_settings/site_list.js
|
| +++ b/chrome/browser/resources/settings/site_settings/site_list.js
|
| @@ -79,6 +79,12 @@ Polymer({
|
| showBlockAction_: Boolean,
|
|
|
| /**
|
| + * Whether to show the 'Clear on exit' action in the action
|
| + * menu.
|
| + */
|
| + showSessionOnlyAction_: Boolean,
|
| +
|
| + /**
|
| * All possible actions in the action menu.
|
| */
|
| actions_: {
|
| @@ -88,20 +94,9 @@ Polymer({
|
| ALLOW: 'Allow',
|
| BLOCK: 'Block',
|
| RESET: 'Reset',
|
| + SESSION_ONLY: 'SessionOnly',
|
| }
|
| },
|
| -
|
| - i18n_: {
|
| - readOnly: true,
|
| - type: Object,
|
| - value: function() {
|
| - return {
|
| - allowAction: loadTimeData.getString('siteSettingsActionAllow'),
|
| - blockAction: loadTimeData.getString('siteSettingsActionBlock'),
|
| - resetAction: loadTimeData.getString('siteSettingsActionReset'),
|
| - };
|
| - },
|
| - },
|
| },
|
|
|
| observers: [
|
| @@ -146,23 +141,25 @@ Polymer({
|
| * @private
|
| */
|
| ensureOpened_: function() {
|
| - // Allowed list is always shown opened by default and All Sites is presented
|
| - // all in one list (nothing closed by default).
|
| + // Allowed list and Clear on Exit lists are always shown opened by default
|
| + // and All Sites is presented all in one list (nothing closed by default).
|
| if (this.allSites ||
|
| - this.categorySubtype == settings.PermissionValues.ALLOW) {
|
| + this.categorySubtype == settings.PermissionValues.ALLOW ||
|
| + this.categorySubtype == settings.PermissionValues.SESSION_ONLY) {
|
| this.$.category.opened = true;
|
| return;
|
| }
|
|
|
| // Block list should only be shown opened if there is nothing to show in
|
| - // the allowed list.
|
| + // the other lists.
|
| if (this.category != settings.INVALID_CATEGORY_SUBTYPE) {
|
| this.browserProxy_.getExceptionList(this.category).then(
|
| function(exceptionList) {
|
| - var allowExists = exceptionList.some(function(exception) {
|
| - return exception.setting == settings.PermissionValues.ALLOW;
|
| + var othersExists = exceptionList.some(function(exception) {
|
| + return exception.setting == settings.PermissionValues.ALLOW ||
|
| + exception.setting == settings.PermissionValues.SESSION_ONLY;
|
| });
|
| - if (allowExists)
|
| + if (othersExists)
|
| return;
|
| this.$.category.opened = true;
|
| }.bind(this));
|
| @@ -176,7 +173,8 @@ Polymer({
|
| * @private
|
| */
|
| updateCategoryVisibility_: function() {
|
| - this.$.category.hidden = !this.showSiteList_(this.categoryEnabled);
|
| + this.$.category.hidden =
|
| + !this.showSiteList_(this.sites, this.categoryEnabled);
|
| },
|
|
|
| /**
|
| @@ -267,16 +265,8 @@ Polymer({
|
| if (exceptionList[i].setting == settings.PermissionValues.DEFAULT)
|
| continue;
|
|
|
| - // Filter out 'Block' values if this list is handling 'Allow' items.
|
| - if (exceptionList[i].setting == settings.PermissionValues.BLOCK &&
|
| - this.categorySubtype != settings.PermissionValues.BLOCK) {
|
| - continue;
|
| - }
|
| - // Filter out 'Allow' values if this list is handling 'Block' items.
|
| - if (exceptionList[i].setting == settings.PermissionValues.ALLOW &&
|
| - this.categorySubtype != settings.PermissionValues.ALLOW) {
|
| + if (exceptionList[i].setting != this.categorySubtype)
|
| continue;
|
| - }
|
| }
|
|
|
| sites.push(exceptionList[i]);
|
| @@ -371,9 +361,12 @@ Polymer({
|
| */
|
| setUpActionMenu_: function() {
|
| this.showAllowAction_ =
|
| - this.categorySubtype == settings.PermissionValues.BLOCK;
|
| + this.categorySubtype != settings.PermissionValues.ALLOW;
|
| this.showBlockAction_ =
|
| - this.categorySubtype == settings.PermissionValues.ALLOW;
|
| + this.categorySubtype != settings.PermissionValues.BLOCK;
|
| + this.showSessionOnlyAction_ =
|
| + this.categorySubtype != settings.PermissionValues.SESSION_ONLY &&
|
| + this.category == settings.ContentSettingsTypes.COOKIES;
|
| },
|
|
|
| /**
|
| @@ -396,22 +389,19 @@ Polymer({
|
| /**
|
| * A handler for activating one of the menu action items.
|
| * @param {!{model: !{item: !{origin: string}},
|
| - * detail: !{item: !{textContent: string}}}} event
|
| + * detail: !{selected: string}}} event
|
| * @private
|
| */
|
| onActionMenuIronActivate_: function(event) {
|
| var origin = event.model.item.origin;
|
| var embeddingOrigin = event.model.item.embeddingOrigin;
|
| - var action = event.detail.item.textContent;
|
| - if (action == this.i18n_.resetAction) {
|
| + var action = event.detail.selected;
|
| + if (action == settings.PermissionValues.DEFAULT) {
|
| this.resetCategoryPermissionForOrigin(
|
| origin, embeddingOrigin, this.category);
|
| } else {
|
| - var value = (action == this.i18n_.allowAction) ?
|
| - settings.PermissionValues.ALLOW :
|
| - settings.PermissionValues.BLOCK;
|
| this.setCategoryPermissionForOrigin(
|
| - origin, embeddingOrigin, this.category, value);
|
| + origin, embeddingOrigin, this.category, action);
|
| }
|
| },
|
|
|
| @@ -424,22 +414,22 @@ Polymer({
|
| * @private
|
| */
|
| computeSiteListHeader_: function(siteList, toggleState) {
|
| + var title = '';
|
| if (this.categorySubtype == settings.PermissionValues.ALLOW) {
|
| - return loadTimeData.getStringF(
|
| - 'titleAndCount',
|
| - loadTimeData.getString(
|
| - toggleState ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
|
| - siteList.length);
|
| + title = loadTimeData.getString(
|
| + toggleState ? 'siteSettingsAllow' : 'siteSettingsExceptions');
|
| + } else if (this.categorySubtype == settings.PermissionValues.BLOCK) {
|
| + title = loadTimeData.getString('siteSettingsBlock');
|
| + } else if (this.categorySubtype == settings.PermissionValues.SESSION_ONLY) {
|
| + title = loadTimeData.getString('siteSettingsSessionOnly');
|
| } else {
|
| - return loadTimeData.getStringF(
|
| - 'titleAndCount',
|
| - loadTimeData.getString('siteSettingsBlock'),
|
| - siteList.length);
|
| + return title;
|
| }
|
| + return loadTimeData.getStringF('titleAndCount', title, siteList.length);
|
| },
|
|
|
| /**
|
| - * Returns true if this widget is showing the allow list.
|
| + * Returns true if this widget is showing the Allow list.
|
| * @private
|
| */
|
| isAllowList_: function() {
|
| @@ -447,17 +437,30 @@ Polymer({
|
| },
|
|
|
| /**
|
| + * Returns true if this widget is showing the Session Only list.
|
| + * @private
|
| + */
|
| + isSessionOnlyList_: function() {
|
| + return this.categorySubtype == settings.PermissionValues.SESSION_ONLY;
|
| + },
|
| +
|
| + /**
|
| * Returns whether to show the site list.
|
| + * @param {Array} siteList The list of all sites to display for this category
|
| + * subtype.
|
| * @param {boolean} toggleState The state of the global toggle for this
|
| * category.
|
| * @private
|
| */
|
| - showSiteList_: function(toggleState) {
|
| + showSiteList_: function(siteList, toggleState) {
|
| // The Block list is only shown when the category is set to Allow since it
|
| // is redundant to also list all the sites that are blocked.
|
| if (this.isAllowList_())
|
| return true;
|
|
|
| + if (this.isSessionOnlyList_())
|
| + return siteList.length > 0;
|
| +
|
| return toggleState;
|
| },
|
| });
|
|
|