From 6e2d06ad52f01aca970b3450e8026c8f118815ea Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 22 Feb 2013 18:15:20 -0500 Subject: [PATCH] Bug 842015 - Avoid modifying the root docshell's privacy status when we aren't opening a new toplevel window. r=bz --- .../windowwatcher/src/nsWindowWatcher.cpp | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index fdbb281f65a4..272c9a97c614 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -899,33 +899,38 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent, } } - if (windowIsNew) { - // If all windows should be private, make sure the new window is also - // private. Otherwise, see if the caller has explicitly requested a - // private or non-private window. - bool isPrivateBrowsingWindow = + // If all windows should be private, make sure the new window is also + // private. Otherwise, see if the caller has explicitly requested a + // private or non-private window. + bool isPrivateBrowsingWindow = Preferences::GetBool("browser.privatebrowsing.autostart") || (!!(chromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) && !(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)); - // Otherwise, propagate the privacy status of the parent window, if - // available, to the child. - if (!isPrivateBrowsingWindow && - !(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)) { - nsCOMPtr parentItem; - GetWindowTreeItem(aParent, getter_AddRefs(parentItem)); - nsCOMPtr parentContext = do_QueryInterface(parentItem); - if (parentContext) { - isPrivateBrowsingWindow = parentContext->UsePrivateBrowsing(); - } + // Otherwise, propagate the privacy status of the parent window, if + // available, to the child. + if (!isPrivateBrowsingWindow && + !(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)) { + nsCOMPtr parentItem; + GetWindowTreeItem(aParent, getter_AddRefs(parentItem)); + nsCOMPtr parentContext = do_QueryInterface(parentItem); + if (parentContext) { + isPrivateBrowsingWindow = parentContext->UsePrivateBrowsing(); } + } + if (isNewToplevelWindow) { nsCOMPtr childRoot; newDocShellItem->GetRootTreeItem(getter_AddRefs(childRoot)); nsCOMPtr childContext = do_QueryInterface(childRoot); if (childContext) { childContext->SetPrivateBrowsing(isPrivateBrowsingWindow); } + } else if (windowIsNew) { + nsCOMPtr childContext = do_QueryInterface(newDocShellItem); + if (childContext) { + childContext->SetPrivateBrowsing(isPrivateBrowsingWindow); + } } if (uriToLoad && aNavigate) { // get the script principal and pass it to docshell