Backout of b407ff123b6f

This commit is contained in:
Doug Turner 2011-12-17 21:52:19 -08:00
parent 2a4b8377d3
commit 51b484700c

View File

@ -976,62 +976,33 @@ function nsBrowserAccess() {
} }
nsBrowserAccess.prototype = { nsBrowserAccess.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIBrowserDOMWindow]),
_getBrowser: function _getBrowser(aURI, aOpener, aWhere, aContext) {
let isExternal = (aContext == Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
if (isExternal && aURI && aURI.schemeIs("chrome"))
return null;
let loadflags = isExternal ?
Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
if (aWhere == Ci.nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW) {
switch (aContext) {
case Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL:
aWhere = Services.prefs.getIntPref("browser.link.open_external");
break;
default: // OPEN_NEW or an illegal value
aWhere = Services.prefs.getIntPref("browser.link.open_newwindow");
}
}
let browser;
if (aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW || aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB) {
let tab = BrowserApp.addTab("about:blank", { selected: true });
browser = tab.browser;
} else { // OPEN_CURRENTWINDOW and illegal values
browser = BrowserApp.selectedBrowser;
}
Services.io.offline = false;
try {
let referrer;
if (aURI && browser) {
if (aOpener) {
let location = aOpener.location;
referrer = Services.io.newURI(location, null, null);
}
browser.loadURIWithFlags(aURI.spec, loadflags, referrer, null, null);
}
} catch(e) { }
return browser;
},
openURI: function browser_openURI(aURI, aOpener, aWhere, aContext) { openURI: function browser_openURI(aURI, aOpener, aWhere, aContext) {
let browser = this._getBrowser(aURI, aOpener, aWhere, aContext); let isExternal = (aContext == Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
return browser ? browser.QueryInterface(Ci.nsIFrameLoaderOwner) : null;
dump("nsBrowserAccess::openURI");
let browser = BrowserApp.selectedBrowser;
if (!browser || isExternal) {
let tab = BrowserApp.addTab("about:blank");
BrowserApp.selectTab(tab);
browser = tab.browser;
}
// Why does returning the browser.contentWindow not work here?
Services.io.offline = false;
BrowserApp.loadURI(aURI.spec, browser);
return null;
}, },
openURIInFrame: function browser_openURIInFrame(aURI, aOpener, aWhere, aContext) { openURIInFrame: function browser_openURIInFrame(aURI, aOpener, aWhere, aContext) {
let browser = this._getBrowser(aURI, aOpener, aWhere, aContext); dump("nsBrowserAccess::openURIInFrame");
return browser ? browser.QueryInterface(Ci.nsIFrameLoaderOwner) : null; return null;
}, },
isTabContentWindow: function(aWindow) { isTabContentWindow: function(aWindow) {
return BrowserApp.getBrowserForWindow(aWindow) != null; return BrowserApp.getBrowserForWindow(aWindow) != null;
} },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIBrowserDOMWindow])
}; };