Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3620)

Unified Diff: chrome/browser/resources/settings/site_settings/site_list.js

Issue 2055823003: Site Settings Desktop: Implement the 'Clear on exit' menu for Cookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Polish Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 866da1aaab6c6b9dc62182d84690cdfce64a9f40..6d97dd41f78c7af7350c17ea5b50d57384a65884 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,6 +94,7 @@ Polymer({
ALLOW: 'Allow',
BLOCK: 'Block',
RESET: 'Reset',
+ SESSION_ONLY: 'SessionOnly',
}
},
@@ -99,6 +106,8 @@ Polymer({
allowAction: loadTimeData.getString('siteSettingsActionAllow'),
blockAction: loadTimeData.getString('siteSettingsActionBlock'),
resetAction: loadTimeData.getString('siteSettingsActionReset'),
+ sessionOnlyAction:
+ loadTimeData.getString('siteSettingsActionSessionOnly'),
};
},
},
@@ -109,6 +118,7 @@ Polymer({
],
ready: function() {
+ this.PermissionValues = settings.PermissionValues;
michaelpg 2016/06/09 18:43:42 consider making this a readOnly property of SiteSe
Finnur 2016/06/10 14:20:46 Done.
this.addWebUIListener('contentSettingSitePermissionChanged',
this.siteWithinCategoryChanged_.bind(this));
},
@@ -146,23 +156,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));
@@ -253,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]);
@@ -357,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;
},
/**
@@ -382,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);
}
},
@@ -416,20 +420,25 @@ Polymer({
loadTimeData.getString(
toggleState ? 'siteSettingsAllow' : 'siteSettingsExceptions'),
siteList.length);
- } else {
+ } else if (this.categorySubtype == settings.PermissionValues.BLOCK) {
return loadTimeData.getStringF(
'titleAndCount',
loadTimeData.getString('siteSettingsBlock'),
siteList.length);
+ } else if (this.categorySubtype == settings.PermissionValues.SESSION_ONLY) {
+ return loadTimeData.getStringF(
+ 'titleAndCount',
+ loadTimeData.getString('siteSettingsSessionOnly'),
+ siteList.length);
}
},
/**
- * Returns true if this widget is showing the allow list.
+ * Returns true if this widget is showing the Block list.
* @private
*/
- isAllowList_: function() {
- return this.categorySubtype == settings.PermissionValues.ALLOW;
+ isBlockList_: function() {
+ return this.categorySubtype == settings.PermissionValues.BLOCK;
},
/**
@@ -446,7 +455,7 @@ Polymer({
// 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_())
+ if (!this.isBlockList_())
return true;
return toggleState;

Powered by Google App Engine
This is Rietveld 408576698