Bug 1108547 - Part 1: Inherit the correct private browsing status on new windows created for targeted navigations; r=jdm

This commit is contained in:
Ehsan Akhgari 2015-01-21 21:01:19 -05:00
parent 3cab8effef
commit 8c17d11b29
2 changed files with 11 additions and 3 deletions

View File

@ -4761,18 +4761,22 @@ nsBrowserAccess.prototype = {
else
aWhere = gPrefService.getIntPref("browser.link.open_newwindow");
}
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aOpener || window);
switch (aWhere) {
case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW :
// FIXME: Bug 408379. So how come this doesn't send the
// referrer like the other loads do?
var url = aURI ? aURI.spec : "about:blank";
let features = "all,dialog=no";
if (isPrivate) {
features += ",private";
}
// Pass all params to openDialog to ensure that "url" isn't passed through
// loadOneOrMoreURIs, which splits based on "|"
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url, null, null, null);
newWindow = openDialog(getBrowserURL(), "_blank", features, url, null, null, null);
break;
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
let referrer = aOpener ? makeURI(aOpener.location.href) : null;
let isPrivate = PrivateBrowsingUtils.isWindowPrivate(aOpener || window);
let browser = this._openURIInNewTab(aURI, referrer, isPrivate, isExternal);
if (browser)
newWindow = browser.contentWindow;

View File

@ -9635,9 +9635,13 @@ nsDocShell::InternalLoad(nsIURI * aURI,
nsAutoCString spec;
if (aURI)
aURI->GetSpec(spec);
nsAutoString features;
if (mInPrivateBrowsing) {
features.AssignLiteral("private");
}
rv = win->OpenNoNavigate(NS_ConvertUTF8toUTF16(spec),
name, // window name
EmptyString(), // Features
features,
getter_AddRefs(newWin));
// In some cases the Open call doesn't actually result in a new