Chromium Code Reviews| 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 d7d0a698b2b94fda473a048a74b6e3c61499ebd5..f8e71f742821fb8b491434ad76c8758e2a4eae85 100644 |
| --- a/chrome/browser/resources/settings/site_settings/site_list.js |
| +++ b/chrome/browser/resources/settings/site_settings/site_list.js |
| @@ -44,6 +44,12 @@ Polymer({ |
| }, |
| /** |
| + * The site serving as the model for the currenly open action menu. |
| + * @private {?SiteException} |
| + */ |
| + actionMenuSite_: Object, |
| + |
| + /** |
| * Array of sites to display in the widget. |
| * @type {!Array<SiteException>} |
| */ |
| @@ -363,15 +369,15 @@ Polymer({ |
| }, |
| /** |
| - * Whether to show the Session Only menu item for a given site. |
| - * @param {SiteException} site The site in question. |
| - * @return {boolean} Whether to show the menu item. |
| + * @return {boolean} Whether to show the "Session Only" menu item for the |
| + * currently active site. |
| + * @private |
| */ |
| - showSessionOnlyActionForSite_: function(site) { |
| + showSessionOnlyActionForSite_: function() { |
| // It makes no sense to show "clear on exit" for exceptions that only apply |
| // to incognito. It gives the impression that they might under some |
| // circumstances not be cleared on exit, which isn't true. |
| - if (site.incognito) |
| + if (!this.actionMenuSite_ || this.actionMenuSite_.incognito) |
| return false; |
| return this.showSessionOnlyAction_; |
| @@ -379,6 +385,7 @@ Polymer({ |
| /** |
| * A handler for selecting a site (by clicking on the origin). |
| + * @param {!{model: !{item: !SiteException}}} event |
| * @private |
| */ |
| onOriginTap_: function(event) { |
| @@ -391,15 +398,14 @@ Polymer({ |
| /** |
| * A handler for activating one of the menu action items. |
| - * @param {!{model: !{item: !{origin: string}}}} event |
| * @param {string} action The permission to set (Allow, Block, SessionOnly, |
| * etc). |
| * @private |
| */ |
| - onActionMenuActivate_: function(event, action) { |
| - var origin = event.model.item.origin; |
| - var incognito = event.model.item.incognito; |
| - var embeddingOrigin = event.model.item.embeddingOrigin; |
| + onActionMenuActivate_: function(action) { |
| + var origin = this.actionMenuSite_.origin; |
| + var incognito = this.actionMenuSite_.incognito; |
| + var embeddingOrigin = this.actionMenuSite_.embeddingOrigin; |
| if (action == settings.PermissionValues.DEFAULT) { |
| this.browserProxy.resetCategoryPermissionForOrigin( |
| origin, embeddingOrigin, this.category, incognito); |
| @@ -410,23 +416,27 @@ Polymer({ |
| }, |
| /** @private */ |
| - onAllowTap_: function(event) { |
| - this.onActionMenuActivate_(event, settings.PermissionValues.ALLOW); |
| + onAllowTap_: function() { |
| + this.onActionMenuActivate_(settings.PermissionValues.ALLOW); |
| + this.closeActionMenu_(); |
| }, |
| /** @private */ |
| - onBlockTap_: function(event) { |
| - this.onActionMenuActivate_(event, settings.PermissionValues.BLOCK); |
| + onBlockTap_: function() { |
| + this.onActionMenuActivate_(settings.PermissionValues.BLOCK); |
| + this.closeActionMenu_(); |
| }, |
| /** @private */ |
| - onSessionOnlyTap_: function(event) { |
| - this.onActionMenuActivate_(event, settings.PermissionValues.SESSION_ONLY); |
| + onSessionOnlyTap_: function() { |
| + this.onActionMenuActivate_(settings.PermissionValues.SESSION_ONLY); |
| + this.closeActionMenu_(); |
| }, |
| /** @private */ |
| - onResetTap_: function(event) { |
| - this.onActionMenuActivate_(event, settings.PermissionValues.DEFAULT); |
| + onResetTap_: function() { |
| + this.onActionMenuActivate_(settings.PermissionValues.DEFAULT); |
| + this.closeActionMenu_(); |
| }, |
| /** |
| @@ -482,4 +492,19 @@ Polymer({ |
| return toggleState; |
| }, |
| + |
| + /** @private */ |
|
dschuyler
2016/10/21 00:41:08
@param for e
dpapad
2016/10/21 00:56:06
Done. It is unfortunate that we are using non-stan
|
| + onShowActionMenuTap_: function(e) { |
| + this.actionMenuSite_ = e.model.item; |
| + /** @type {!SettingsActionMenuElement} */ ( |
| + this.$$('dialog[is=settings-action-menu]')).showAt( |
| + /** @type {!Element} */ (Polymer.dom(e).localTarget)); |
| + }, |
| + |
| + /** @private */ |
| + closeActionMenu_: function() { |
| + this.actionMenuSite_ = null; |
| + /** @type {!SettingsActionMenuElement} */ ( |
| + this.$$('dialog[is=settings-action-menu]')).close(); |
| + }, |
| }); |