Skip to content

Commit

Permalink
Avoid CPOWs in wrapper for browser.loadURIWithFlags() + simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Mar 4, 2016
1 parent 3eb2a7d commit 6fef2c5
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,37 +969,34 @@ var privateTab = {
if(params && typeof params == "object") // Firefox 38+
aFlags = params.flags;
_dbgv && _log("loadURIWithFlags() flags: " + aFlags);
if(!(aFlags & Components.interfaces.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL))
return false;
var tab = _this.getTabForBrowser(this);
if(!tab) {
_log("loadURIWithFlags() with LOAD_FLAGS_FROM_EXTERNAL flag, tab not found!");
return false;
}
if(!_this.isPrivateTab(tab))
return false;
// See chrome://browser/content/browser.js, nsBrowserAccess.prototype.openURI()
var stack = new Error().stack;
_dbgv && _log("loadURIWithFlags(), stack:\n" + stack);
if(
aFlags & Components.interfaces.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL
&& _this.isPrivateWindow(this.contentWindow || this.contentWindowAsCPOW)
stack.indexOf("addTab@chrome:") != -1
|| stack.indexOf("loadOneTab@chrome:") != -1
) {
// See chrome://browser/content/browser.js, nsBrowserAccess.prototype.openURI()
var stack = new Error().stack;
_dbgv && _log("loadURIWithFlags(), stack:\n" + stack);
if(
stack.indexOf("addTab@chrome:") != -1
|| stack.indexOf("loadOneTab@chrome:") != -1
) {
var tab = _this.getTabForBrowser(this);
if(tab) {
_log("loadURIWithFlags() with LOAD_FLAGS_FROM_EXTERNAL flag => make tab not private");
_this.toggleTabPrivate(tab, false);
}
else {
_log("loadURIWithFlags() with LOAD_FLAGS_FROM_EXTERNAL flag, tab not found!");
}
return false;
}
_log("loadURIWithFlags() with LOAD_FLAGS_FROM_EXTERNAL flag => open in new tab");
_this.readyToOpenTab(window, false);
var tab = gBrowser.loadOneTab(aURI || "about:blank", {
referrerURI: aReferrerURI,
fromExternal: true,
inBackground: prefs.getPref("browser.tabs.loadDivertedInBackground")
});
return !!tab;
_log("loadURIWithFlags() with LOAD_FLAGS_FROM_EXTERNAL flag => make tab not private");
_this.toggleTabPrivate(tab, false);
return false;
}
return false;
_log("loadURIWithFlags() with LOAD_FLAGS_FROM_EXTERNAL flag => open in new tab");
_this.readyToOpenTab(window, false);
gBrowser.loadOneTab(aURI || "about:blank", {
referrerURI: aReferrerURI,
fromExternal: true,
inBackground: prefs.getPref("browser.tabs.loadDivertedInBackground")
});
return true;
}
);
}
Expand Down

0 comments on commit 6fef2c5

Please sign in to comment.