From 1a6470f3a1242108030eaec96fbcf2853fe75c35 Mon Sep 17 00:00:00 2001 From: Johann Hofmann Date: Fri, 6 Jan 2017 17:10:39 +0100 Subject: [PATCH] Bug 1329210 - Hide the permission reload hint when the control center is reopened. r=florian MozReview-Commit-ID: Fb6ZEeYIJHG --HG-- extra : rebase_source : 3d9fc16b3cfffe6c2a5adef2537ad9dd9b47cb48 --- browser/base/content/browser.js | 40 ++++++++++++++------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index fa39c089ac4c..c03cc6b01261 100755 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -6605,11 +6605,6 @@ var gIdentityHandler = { */ _state: 0, - /** - * Whether a permission is just removed from permission list. - */ - _permissionJustRemoved: false, - get _isBroken() { return this._state & Ci.nsIWebProgressListener.STATE_IS_BROKEN; }, @@ -7304,6 +7299,9 @@ var gIdentityHandler = { // the popup is actually needed this._identityPopup.hidden = false; + // Remove the reload hint that we show after a user has cleared a permission. + this._permissionReloadHint.setAttribute("hidden", "true"); + // Update the popup strings this.refreshIdentityPopup(); @@ -7364,21 +7362,10 @@ var gIdentityHandler = { }, onLocationChange() { - this._permissionJustRemoved = false; - this.updatePermissionHint(); - }, + this._permissionReloadHint.setAttribute("hidden", "true"); - updatePermissionHint() { - if (!this._permissionList.hasChildNodes() && !this._permissionJustRemoved) { + if (!this._permissionList.hasChildNodes()) { this._permissionEmptyHint.removeAttribute("hidden"); - } else { - this._permissionEmptyHint.setAttribute("hidden", "true"); - } - - if (this._permissionJustRemoved) { - this._permissionReloadHint.removeAttribute("hidden"); - } else { - this._permissionReloadHint.setAttribute("hidden", "true"); } }, @@ -7418,7 +7405,13 @@ var gIdentityHandler = { this._permissionList.appendChild(item); } - this.updatePermissionHint(); + // Show a placeholder text if there's no permission and no reload hint. + if (!this._permissionList.hasChildNodes() && + this._permissionReloadHint.hasAttribute("hidden")) { + this._permissionEmptyHint.removeAttribute("hidden"); + } else { + this._permissionEmptyHint.setAttribute("hidden", "true"); + } }, _handleHeightChange(aFunction, aWillShowReloadHint) { @@ -7464,8 +7457,9 @@ var gIdentityHandler = { let tooltiptext = gNavigatorBundle.getString("permissions.remove.tooltip"); button.setAttribute("tooltiptext", tooltiptext); button.addEventListener("command", () => { - this._handleHeightChange(() => - this._permissionList.removeChild(container), !this._permissionJustRemoved); + // Only resize the window if the reload hint was previously hidden. + this._handleHeightChange(() => this._permissionList.removeChild(container), + this._permissionReloadHint.hasAttribute("hidden")); if (aPermission.inUse && ["camera", "microphone", "screen"].includes(aPermission.id)) { let windowId = this._sharingState.windowId; @@ -7490,8 +7484,8 @@ var gIdentityHandler = { mm.sendAsyncMessage("webrtc:StopSharing", windowId); } SitePermissions.remove(gBrowser.currentURI, aPermission.id); - this._permissionJustRemoved = true; - this.updatePermissionHint(); + + this._permissionReloadHint.removeAttribute("hidden"); // Set telemetry values for clearing a permission let histogram = Services.telemetry.getKeyedHistogramById("WEB_PERMISSION_CLEARED");