From fe5aa7fd5097cd525d0f53b66d6e4fbcdbb1fa25 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 git-svn-id: svn://10.0.0.236/trunk@157584 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/cookieNavigatorOverlay.xul | 7 ++- .../browser/resources/content/navigator.js | 60 +++++++++++++++++++ .../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/mozilla/extensions/cookie/resources/content/cookieNavigatorOverlay.xul b/mozilla/extensions/cookie/resources/content/cookieNavigatorOverlay.xul index e3b7dd9142f..b55c4517952 100644 --- a/mozilla/extensions/cookie/resources/content/cookieNavigatorOverlay.xul +++ b/mozilla/extensions/cookie/resources/content/cookieNavigatorOverlay.xul @@ -262,7 +262,9 @@ + insertbefore="navBeginGlobalItems" + oncommand="popupBlockerMenuCommand(event.target);" + onpopupshowing="return popupBlockerMenuShowing(event)" > diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index d1c87e704c0..f17edf40eb5 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/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/mozilla/xpfe/browser/resources/content/navigator.xul b/mozilla/xpfe/browser/resources/content/navigator.xul index 9a9a517229c..999199b4f4b 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.xul +++ b/mozilla/xpfe/browser/resources/content/navigator.xul @@ -349,11 +349,20 @@ -