[PALEMOON] [frontend vs backend] Reduce size of PopupBlocking:UpdateBlockedPopups messages

Issue #392
This commit is contained in:
janekptacijarabaci 2018-05-27 15:00:42 +02:00 • committed by Roy Tam
commit adb584360c

View file

@ -420,7 +420,8 @@ var gPopupBlockerObserver = {
if (!this._reportButton && gURLBar) if (!this._reportButton && gURLBar)
this._reportButton = document.getElementById("page-report-button"); this._reportButton = document.getElementById("page-report-button");
if (!gBrowser.selectedBrowser.blockedPopups) { if (!gBrowser.selectedBrowser.blockedPopups ||
!gBrowser.selectedBrowser.blockedPopups.length) {
// Hide the icon in the location bar (if the location bar exists) // Hide the icon in the location bar (if the location bar exists)
if (gURLBar) if (gURLBar)
this._reportButton.hidden = true; this._reportButton.hidden = true;
@ -522,17 +523,32 @@ var gPopupBlockerObserver = {
else else
blockedPopupAllowSite.removeAttribute("disabled"); blockedPopupAllowSite.removeAttribute("disabled");
var foundUsablePopupURI = false; let blockedPopupDontShowMessage = document.getElementById("blockedPopupDontShowMessage");
var blockedPopups = browser.blockedPopups; let showMessage = gPrefService.getBoolPref("privacy.popups.showBrowserMessage");
blockedPopupDontShowMessage.setAttribute("checked", !showMessage);
if (aEvent.target.anchorNode.id == "page-report-button") {
aEvent.target.anchorNode.setAttribute("open", "true");
blockedPopupDontShowMessage.setAttribute("label", gNavigatorBundle.getString("popupWarningDontShowFromLocationbar"));
} else {
blockedPopupDontShowMessage.setAttribute("label", gNavigatorBundle.getString("popupWarningDontShowFromMessage"));
}
let blockedPopupsSeparator =
document.getElementById("blockedPopupsSeparator");
blockedPopupsSeparator.setAttribute("hidden", true);
gBrowser.selectedBrowser.retrieveListOfBlockedPopups().then(blockedPopups => {
let foundUsablePopupURI = false;
if (blockedPopups) { if (blockedPopups) {
for (let i = 0; i < blockedPopups.length; i++) { for (let i = 0; i < blockedPopups.length; i++) {
let blockedPopup = blockedPopups[i]; let blockedPopup = blockedPopups[i];
// popupWindowURI will be null if the file picker popup is blocked. // popupWindowURI will be null if the file picker popup is blocked.
// xxxdz this should make the option say "Show file picker" and do it (Bug 590306) // xxxdz this should make the option say "Show file picker" and do it (Bug 590306)
if (!blockedPopup.popupWindowURI) if (!blockedPopup.popupWindowURIspec)
continue; continue;
var popupURIspec = blockedPopup.popupWindowURI.spec;
var popupURIspec = blockedPopup.popupWindowURIspec;
// Sometimes the popup URI that we get back from the blockedPopup // Sometimes the popup URI that we get back from the blockedPopup
// isn't useful (for instance, netscape.com's popup URI ends up // isn't useful (for instance, netscape.com's popup URI ends up
@ -540,6 +556,7 @@ var gPopupBlockerObserver = {
// the popup they're trying to show). This isn't going to be // the popup they're trying to show). This isn't going to be
// useful to the user, so we won't create a menu item for it. // useful to the user, so we won't create a menu item for it.
if (popupURIspec == "" || popupURIspec == "about:blank" || if (popupURIspec == "" || popupURIspec == "about:blank" ||
popupURIspec == "<self>" ||
popupURIspec == uri.spec) popupURIspec == uri.spec)
continue; continue;
@ -554,9 +571,6 @@ var gPopupBlockerObserver = {
var label = gNavigatorBundle.getFormattedString("popupShowPopupPrefix", var label = gNavigatorBundle.getFormattedString("popupShowPopupPrefix",
[popupURIspec]); [popupURIspec]);
menuitem.setAttribute("label", label); menuitem.setAttribute("label", label);
menuitem.setAttribute("popupWindowURI", popupURIspec);
menuitem.setAttribute("popupWindowFeatures", blockedPopup.popupWindowFeatures);
menuitem.setAttribute("popupWindowName", blockedPopup.popupWindowName);
menuitem.setAttribute("oncommand", "gPopupBlockerObserver.showBlockedPopup(event);"); menuitem.setAttribute("oncommand", "gPopupBlockerObserver.showBlockedPopup(event);");
menuitem.setAttribute("popupReportIndex", i); menuitem.setAttribute("popupReportIndex", i);
menuitem.popupReportBrowser = browser; menuitem.popupReportBrowser = browser;
@ -564,23 +578,11 @@ var gPopupBlockerObserver = {
} }
} }
// Show or hide the separator, depending on whether we added any // Show the separator if we added any
// showable popup addresses to the menu. // showable popup addresses to the menu.
var blockedPopupsSeparator =
document.getElementById("blockedPopupsSeparator");
if (foundUsablePopupURI) if (foundUsablePopupURI)
blockedPopupsSeparator.removeAttribute("hidden"); blockedPopupsSeparator.removeAttribute("hidden");
else }, null);
blockedPopupsSeparator.setAttribute("hidden", true);
var blockedPopupDontShowMessage = document.getElementById("blockedPopupDontShowMessage");
var showMessage = gPrefService.getBoolPref("privacy.popups.showBrowserMessage");
blockedPopupDontShowMessage.setAttribute("checked", !showMessage);
if (aEvent.target.anchorNode.id == "page-report-button") {
aEvent.target.anchorNode.setAttribute("open", "true");
blockedPopupDontShowMessage.setAttribute("label", gNavigatorBundle.getString("popupWarningDontShowFromLocationbar"));
} else
blockedPopupDontShowMessage.setAttribute("label", gNavigatorBundle.getString("popupWarningDontShowFromMessage"));
}, },
onPopupHiding: function (aEvent) { onPopupHiding: function (aEvent) {