From 85134fe662aa87da2204e2efb68c993e21f66187 Mon Sep 17 00:00:00 2001 From: "mconnor%steelgryphon.com" Date: Tue, 26 Apr 2005 16:55:59 +0000 Subject: [PATCH] bug 217611 - page info can be opened multiple times, patch by Jason Barnabe (jason_barnabe@fastmail.fm), r=me, a=asa git-svn-id: svn://10.0.0.236/trunk@172741 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/browser.js | 31 +++++++++++++++++++++--- mozilla/browser/base/content/pageInfo.js | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index 87528878413..268bde89812 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -31,6 +31,7 @@ # Joe Hewitt # Alec Flett # Asaf Romano +# Jason Barnabe # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -1892,10 +1893,11 @@ function BrowserViewSourceOfURL(url, charset, pageCookie) // doc=null for regular page info, doc=owner document for frame info. function BrowserPageInfo(doc) { - window.openDialog("chrome://browser/content/pageInfo.xul", - "_blank", - "chrome,dialog=no", - doc); + toOpenDialogByTypeAndUrl("Browser:page-info", + doc ? doc.location : window.content.document.location, + "chrome://browser/content/pageInfo.xul", + "chrome,dialog=no", + doc); } #ifdef DEBUG @@ -2763,6 +2765,27 @@ function toOpenWindowByType(inType, uri, features) window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); } +function toOpenDialogByTypeAndUrl(inType, relatedUrl, windowUri, features, extraArgument) +{ + var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); + var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); + var windows = windowManagerInterface.getEnumerator(inType); + + // Check for windows matching the url + while (windows.hasMoreElements()) { + var currentWindow = windows.getNext(); + if (currentWindow.document.firstChild.getAttribute("relatedUrl") == relatedUrl) { + currentWindow.focus(); + return; + } + } + + // We didn't find a matching window, so open a new one. + if (features) + window.openDialog(windowUri, "_blank", features, extraArgument); + else + window.openDialog(windowUri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", extraArgument); +} function OpenBrowserWindow() { diff --git a/mozilla/browser/base/content/pageInfo.js b/mozilla/browser/base/content/pageInfo.js index 0b7776792a5..cba58f32651 100644 --- a/mozilla/browser/base/content/pageInfo.js +++ b/mozilla/browser/base/content/pageInfo.js @@ -290,6 +290,8 @@ function onLoadPageInfo() } document.title = docTitle; + + document.getElementById("main-window").setAttribute("relatedUrl", theDocument.location.toString()); // do the easy stuff first makeGeneralTab();