From 5839168a9f01111c5cf4eef3effa79c8b2d4bb95 Mon Sep 17 00:00:00 2001 From: JustOff Date: Sun, 6 May 2018 14:47:23 +0300 Subject: [PALEMOON] Replace fullscreen permission dialog with a warning --- application/palemoon/app/profile/palemoon.js | 5 -- .../palemoon/base/content/browser-fullScreen.js | 100 +++------------------ application/palemoon/base/content/browser.css | 12 +-- application/palemoon/base/content/browser.xul | 12 --- .../locales/en-US/chrome/browser/browser.dtd | 3 - .../en-US/chrome/browser/browser.properties | 2 - application/palemoon/themes/linux/browser.css | 9 -- application/palemoon/themes/osx/browser.css | 9 -- application/palemoon/themes/windows/browser.css | 9 -- 9 files changed, 13 insertions(+), 148 deletions(-) (limited to 'application') diff --git a/application/palemoon/app/profile/palemoon.js b/application/palemoon/app/profile/palemoon.js index f0e860749..90b4949b9 100644 --- a/application/palemoon/app/profile/palemoon.js +++ b/application/palemoon/app/profile/palemoon.js @@ -1058,11 +1058,6 @@ pref("browser.newtabpage.rows", 4); // Enable the DOM fullscreen API. pref("full-screen-api.enabled", true); -// True if the fullscreen API requires approval upon a domain entering fullscreen. -// Domains that have already had fullscreen permission granted won't re-request -// approval. -pref("full-screen-api.approval-required", true); - // about:permissions // Maximum number of sites to return from the places database. // 0-100 (currently) diff --git a/application/palemoon/base/content/browser-fullScreen.js b/application/palemoon/base/content/browser-fullScreen.js index d36225c4d..6afd247be 100644 --- a/application/palemoon/base/content/browser-fullScreen.js +++ b/application/palemoon/base/content/browser-fullScreen.js @@ -247,66 +247,20 @@ var FullScreen = { this.warningBox.setAttribute("hidden", true); this.warningBox.removeAttribute("fade-warning-out"); - this.warningBox.removeAttribute("obscure-browser"); this.warningBox = null; }, - setFullscreenAllowed: function(isApproved) { - // The "remember decision" checkbox is hidden when showing for documents that - // the permission manager can't handle (documents with URIs without a host). - // We simply require those to be approved every time instead. - let rememberCheckbox = document.getElementById("full-screen-remember-decision"); - let uri = this.fullscreenDoc.nodePrincipal.URI; - if (!rememberCheckbox.hidden) { - if (rememberCheckbox.checked) - Services.perms.add(uri, - "fullscreen", - isApproved ? Services.perms.ALLOW_ACTION : Services.perms.DENY_ACTION, - Services.perms.EXPIRE_NEVER); - else if (isApproved) { - // The user has only temporarily approved fullscren for this fullscreen - // session only. Add the permission (so Goanna knows to approve any further - // fullscreen requests for this host in this fullscreen session) but add - // a listener to revoke the permission when the chrome document exits - // fullscreen. - Services.perms.add(uri, - "fullscreen", - Services.perms.ALLOW_ACTION, - Services.perms.EXPIRE_SESSION); - var onFullscreenchange = function onFullscreenchange(event) { - if (event.target == document && document.mozFullScreenElement == null) { - // The chrome document has left fullscreen. Remove the temporary permission grant. - Services.perms.remove(uri, "fullscreen"); - document.removeEventListener("mozfullscreenchange", onFullscreenchange); - } - } - document.addEventListener("mozfullscreenchange", onFullscreenchange); - } - } - if (this.warningBox) - this.warningBox.setAttribute("fade-warning-out", "true"); - // If the document has been granted fullscreen, notify Goanna so it can resume - // any pending pointer lock requests, otherwise exit fullscreen; the user denied - // the fullscreen request. - if (isApproved) - Services.obs.notifyObservers(this.fullscreenDoc, "fullscreen-approved", ""); - else - document.mozCancelFullScreen(); - }, - warningBox: null, warningFadeOutTimeout: null, fullscreenDoc: null, - // Shows the fullscreen approval UI, or if the domain has already been approved - // for fullscreen, shows a warning that the site has entered fullscreen for a short - // duration. + // Shows a warning that the site has entered fullscreen for a short duration. showWarning: function(targetDoc) { - if (!document.mozFullScreen || - !gPrefService.getBoolPref("full-screen-api.approval-required")) + let timeout = gPrefService.getIntPref("full-screen-api.warning.timeout"); + if (!document.mozFullScreen || timeout <= 0) return; - // Set the strings on the fullscreen approval UI. + // Set the strings on the fullscreen warning UI. this.fullscreenDoc = targetDoc; let uri = this.fullscreenDoc.nodePrincipal.URI; let host = null; @@ -314,11 +268,8 @@ var FullScreen = { host = uri.host; } catch (e) { } let hostLabel = document.getElementById("full-screen-domain-text"); - let rememberCheckbox = document.getElementById("full-screen-remember-decision"); - let isApproved = false; if (host) { - // Document's principal's URI has a host. Display a warning including the hostname and - // show UI to enable the user to permanently grant this host permission to enter fullscreen. + // Document's principal's URI has a host. Display a warning including the hostname. let utils = {}; Cu.import("resource://gre/modules/DownloadUtils.jsm", utils); let displayHost = utils.DownloadUtils.getURIHost(uri.spec)[0]; @@ -326,17 +277,8 @@ var FullScreen = { hostLabel.textContent = bundle.formatStringFromName("fullscreen.entered", [displayHost], 1); hostLabel.removeAttribute("hidden"); - - rememberCheckbox.label = bundle.formatStringFromName("fullscreen.rememberDecision", [displayHost], 1); - rememberCheckbox.checked = false; - rememberCheckbox.removeAttribute("hidden"); - - // Note we only allow documents whose principal's URI has a host to - // store permission grants. - isApproved = Services.perms.testPermission(uri, "fullscreen") == Services.perms.ALLOW_ACTION; } else { hostLabel.setAttribute("hidden", "true"); - rememberCheckbox.setAttribute("hidden", "true"); } // Note: the warning box can be non-null if the warning box from the previous request @@ -354,32 +296,12 @@ var FullScreen = { this.warningBox.removeAttribute("fade-warning-out"); } - // If fullscreen mode has not yet been approved for the fullscreen - // document's domain, show the approval UI and don't auto fade out the - // fullscreen warning box. Otherwise, we're just notifying of entry into - // fullscreen mode. Note if the resource's host is null, we must be - // showing a local file or a local data URI, and we require explicit - // approval every time. - let authUI = document.getElementById("full-screen-approval-pane"); - if (isApproved) { - authUI.setAttribute("hidden", "true"); - this.warningBox.removeAttribute("obscure-browser"); - } else { - // Partially obscure the element underneath the approval UI. - this.warningBox.setAttribute("obscure-browser", "true"); - authUI.removeAttribute("hidden"); - } - - // If we're not showing the fullscreen approval UI, we're just notifying the user - // of the transition, so set a timeout to fade the warning out after a few moments. - if (isApproved) - this.warningFadeOutTimeout = - setTimeout( - function() { - if (this.warningBox) - this.warningBox.setAttribute("fade-warning-out", "true"); - }.bind(this), - 3000); + // Set a timeout to fade the warning out after a few moments. + this.warningFadeOutTimeout = setTimeout(() => { + if (this.warningBox) { + this.warningBox.setAttribute("fade-warning-out", "true"); + } + }, timeout); }, showNavToolbox: function(trackMouse = true) { diff --git a/application/palemoon/base/content/browser.css b/application/palemoon/base/content/browser.css index 6fd2c5ce1..a2970aefc 100644 --- a/application/palemoon/base/content/browser.css +++ b/application/palemoon/base/content/browser.css @@ -504,6 +504,7 @@ window[chromehidden~="toolbar"] toolbar:not(.toolbar-primary):not(#nav-bar):not( width: 100%; height: 100%; z-index: 2147483647 !important; + pointer-events: none; } #full-screen-warning-container[fade-warning-out] { @@ -512,22 +513,13 @@ window[chromehidden~="toolbar"] toolbar:not(.toolbar-primary):not(#nav-bar):not( opacity: 0.0; } -/* When the modal fullscreen approval UI is showing, don't allow interaction - with the page, but when we're just showing the warning upon entering - fullscreen on an already approved page, do allow interaction with the page. - */ -#full-screen-warning-container:not([obscure-browser]) { - pointer-events: none; -} - #full-screen-warning-message { /* We must specify a max-width, otherwise word-wrap:break-word doesn't work in descendant and