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 87b3431373
commit 540ba83a99
2 changed files with 11 additions and 3 deletions

View File

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

View File

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