From 3688853ede781a5452364755b744f0ad189cb0a2 Mon Sep 17 00:00:00 2001 From: "mvl%exedo.nl" Date: Tue, 8 Jun 2004 12:06:56 +0000 Subject: [PATCH] Add a way to manually show a single blocked pop-up window bug 198846, r=danm, sr=jag --- .../content/cookieNavigatorOverlay.xul | 7 ++- xpfe/browser/resources/content/navigator.js | 60 +++++++++++++++++++ xpfe/browser/resources/content/navigator.xul | 11 +++- .../content/nsBrowserStatusHandler.js | 7 ++- .../locale/en-US/navigator.properties | 2 + .../content/permissionsNavigatorOverlay.xul | 7 ++- 6 files changed, 90 insertions(+), 4 deletions(-) diff --git a/extensions/cookie/resources/content/cookieNavigatorOverlay.xul b/extensions/cookie/resources/content/cookieNavigatorOverlay.xul index e3b7dd9142f5..b55c45179522 100644 --- a/extensions/cookie/resources/content/cookieNavigatorOverlay.xul +++ b/extensions/cookie/resources/content/cookieNavigatorOverlay.xul @@ -262,7 +262,9 @@ + insertbefore="navBeginGlobalItems" + oncommand="popupBlockerMenuCommand(event.target);" + onpopupshowing="return popupBlockerMenuShowing(event)" > diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index d1c87e704c03..f17edf40eb57 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -2199,6 +2199,27 @@ function onPopupBlocked(aEvent) { var popupIcon = document.getElementById("popupIcon"); popupIcon.hidden = false; } + if (!browser.popupUrls) { + browser.popupUrls = []; + browser.popupFeatures = []; + } + // Check for duplicates, remove the old occurence of this url, + // to update the features, and put it at the end of the list. + for (var i = 0; i < browser.popupUrls.length; ++i) { + if (browser.popupUrls[i].equals(aEvent.popupWindowURI)) { + browser.popupUrls.splice(i, 1); + browser.popupFeatures.splice(i, 1); + break; + } + } + // Limit the length of the menu to some reasonable size. + // We only add one item every time, so no need for more complex stuff. + if (browser.popupUrls.length >= 100) { + browser.popupUrls.shift(); + browser.popupFeatures.shift(); + } + browser.popupUrls.push(aEvent.popupWindowURI); + browser.popupFeatures.push(aEvent.popupWindowFeatures); } } } @@ -2224,6 +2245,45 @@ function StatusbarViewPopupManager() { "chrome,resizable=yes", hostPort); } +function popupBlockerMenuShowing(event) { + var parent = event.target; + var browser = getBrowser().selectedBrowser; + var separator = document.getElementById("popupMenuSeparator"); + + if ("popupDomain" in browser) { + createShowPopupsMenu(parent); + if (separator) + separator.hidden = false; + } else { + if (separator) + separator.hidden = true; + } +} + +function createShowPopupsMenu(parent) { + while (parent.lastChild && parent.lastChild.hasAttribute("uri")) + parent.removeChild(parent.lastChild); + + var browser = getBrowser().selectedBrowser; + + for (var i = 0; i < browser.popupUrls.length; i++) { + var menuitem = document.createElement("menuitem"); + menuitem.setAttribute("label", gNavigatorBundle.getFormattedString('popupMenuShow', [browser.popupUrls[i].spec])); + menuitem.setAttribute("uri", browser.popupUrls[i].spec); + menuitem.setAttribute("features", browser.popupFeatures[i]); + parent.appendChild(menuitem); + } + + return true; +} + +function popupBlockerMenuCommand(target) { + var uri = target.getAttribute("uri"); + if (uri) { + window.content.open(uri, "", target.getAttribute("features")); + } +} + function toHistory() { toOpenWindowByType("history:manager", "chrome://communicator/content/history/history.xul"); diff --git a/xpfe/browser/resources/content/navigator.xul b/xpfe/browser/resources/content/navigator.xul index 9a9a517229c7..999199b4f4bc 100644 --- a/xpfe/browser/resources/content/navigator.xul +++ b/xpfe/browser/resources/content/navigator.xul @@ -349,11 +349,20 @@ -