bug 300733 - open links in a new tab in a window with toolbars, r+a=bsmedberg

This commit is contained in:
mconnor%steelgryphon.com 2005-07-25 21:43:22 +00:00
Родитель 6fd6b12a4e
Коммит 61d2b7b5ac
1 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -115,6 +115,25 @@ function getMostRecentWindow(aType) {
return wm.getMostRecentWindow(aType);
}
// this returns the most recent non-popup browser window
function getMostRecentBrowserWindow() {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var windowList = wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
if (!windowList.hasMoreElements())
return null;
var win = windowList.getNext();
while (!win.toolbar.visible) {
if (!windowList.hasMoreElements())
return null;
win = windowList.getNext();
}
return win;
}
var nsBrowserContentHandler = {
/* helper functions */
@ -371,7 +390,7 @@ const CONTRACTID_PREFIX = "@mozilla.org/uriloader/content-handler;1?type=";
function handURIToExistingBrowser(uri, location)
{
var navWin = getMostRecentWindow("navigator:browser");
var navWin = getMostRecentBrowserWindow();
if (!navWin) {
// if we couldn't load it in an existing window, open a new one
openWindow(null, nsBrowserContentHandler.chromeURL, "_blank",