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 18cb1d83604e0f0400fcf8b20e1c61f463bc2b0d..954e22095c857cbf89e4383c806a77410fb8d587 100644 |
| --- a/chrome/browser/resources/settings/site_settings/site_list.js |
| +++ b/chrome/browser/resources/settings/site_settings/site_list.js |
| @@ -77,6 +77,15 @@ Polymer({ |
| showSessionOnlyAction_: Boolean, |
| /** |
| + * Keeps track of the incognito status of the current profile (whether one |
| + * exists). |
| + */ |
| + profileHasIncognito_: { |
|
dschuyler
2016/08/31 21:48:52
nit: should this be profileIsIncognito? Does a
pro
Finnur
2016/09/01 11:10:15
Both, I would say. A profile can be incognito, but
dschuyler
2016/09/01 23:13:49
I like it!
|
| + type: Boolean, |
| + value: false, |
| + }, |
| + |
| + /** |
| * All possible actions in the action menu. |
| */ |
| actions_: { |
| @@ -98,6 +107,8 @@ Polymer({ |
| ready: function() { |
| this.addWebUIListener('contentSettingSitePermissionChanged', |
| this.siteWithinCategoryChanged_.bind(this)); |
| + this.addWebUIListener('onIncognitoStatusChanged', |
| + this.onIncognitoStatusChanged_.bind(this)); |
| }, |
| /** |
| @@ -111,6 +122,20 @@ Polymer({ |
| this.configureWidget_(); |
| }, |
| + onIncognitoStatusChanged_: function(incognitoEnabled) { |
| + // A change notification is not sent for each site that is deleted during |
| + // incognito profile destruction. Therefore, we reconfigure the list when |
| + // the incognito profile is destroyed, except for SESSION_ONLY, which won't |
| + // have any incognito exceptions. |
| + if (this.categorySubtype == settings.PermissionValues.SESSION_ONLY) |
| + return; |
| + |
| + if (this.profileHasIncognito_) |
| + this.configureWidget_(); |
| + |
| + this.profileHasIncognito_ = incognitoEnabled; |
| + }, |
| + |
| /** |
| * Configures the action menu, visibility of the widget and shows the list. |
| * @private |
| @@ -341,7 +366,7 @@ Polymer({ |
| } |
| return comparison; |
| }); |
| - var results = []; |
| + var results = /** @type {!Array<SiteException>} */ []; |
| var lastOrigin = ''; |
| var lastEmbeddingOrigin = ''; |
| for (var i = 0; i < sites.length; ++i) { |
| @@ -366,6 +391,7 @@ Polymer({ |
| originForDisplay: originForDisplay, |
| embeddingOrigin: embeddingOrigin, |
| embeddingOriginForDisplay: embeddingOriginForDisplay, |
| + incognito: sites[i].incognito, |
| source: sites[i].source, |
| }); |
| @@ -390,6 +416,21 @@ 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. |
| + */ |
| + showSessionOnlyActionForSite_: function(site) { |
| + // 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) |
| + return false; |
| + |
| + return this.showSessionOnlyAction_; |
| + }, |
| + |
| + /** |
| * A handler for selecting a site (by clicking on the origin). |
| * @private |
| */ |
| @@ -409,14 +450,15 @@ Polymer({ |
| */ |
| onActionMenuIronActivate_: function(event) { |
| var origin = event.model.item.origin; |
| + var incognito = event.model.item.incognito; |
| var embeddingOrigin = event.model.item.embeddingOrigin; |
| var action = event.detail.selected; |
| if (action == settings.PermissionValues.DEFAULT) { |
| - this.resetCategoryPermissionForOrigin( |
| - origin, embeddingOrigin, this.category); |
| + this.browserProxy.resetCategoryPermissionForOrigin( |
| + origin, embeddingOrigin, this.category, incognito); |
| } else { |
| - this.setCategoryPermissionForOrigin( |
| - origin, embeddingOrigin, this.category, action); |
| + this.browserProxy.setCategoryPermissionForOrigin( |
| + origin, embeddingOrigin, this.category, action, incognito); |
| } |
| }, |
| @@ -444,6 +486,23 @@ Polymer({ |
| }, |
| /** |
| + * Returns the appropriate site description to display. This can, for example, |
| + * be blank, an 'embedded on <site>' or 'Current incognito session' (or a |
| + * mix of the last two). |
| + * @param {SiteException} item The site exception entry. |
| + * @return {string} The site description. |
| + */ |
| + computeSiteDescription_: function(item) { |
| + if (item.incognito && item.embeddingOriginForDisplay.length > 0) { |
| + return loadTimeData.getStringF('embeddedIncognitoSite', |
| + item.embeddingOriginForDisplay); |
| + } |
| + if (item.incognito) |
| + return loadTimeData.getString('incognitoSite'); |
| + return item.embeddingOriginForDisplay; |
| + }, |
| + |
| + /** |
| * Returns true if this widget is showing the Allow list. |
| * @private |
| */ |