Bug 842015 - Avoid modifying the root docshell's privacy status when we aren't opening a new toplevel window. r=bz

This commit is contained in:
Josh Matthews 2013-02-22 18:15:20 -05:00
Родитель cc629bf54e
Коммит 6e2d06ad52
1 изменённых файлов: 20 добавлений и 15 удалений

Просмотреть файл

@ -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<nsIDocShellTreeItem> parentItem;
GetWindowTreeItem(aParent, getter_AddRefs(parentItem));
nsCOMPtr<nsILoadContext> 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<nsIDocShellTreeItem> parentItem;
GetWindowTreeItem(aParent, getter_AddRefs(parentItem));
nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(parentItem);
if (parentContext) {
isPrivateBrowsingWindow = parentContext->UsePrivateBrowsing();
}
}
if (isNewToplevelWindow) {
nsCOMPtr<nsIDocShellTreeItem> childRoot;
newDocShellItem->GetRootTreeItem(getter_AddRefs(childRoot));
nsCOMPtr<nsILoadContext> childContext = do_QueryInterface(childRoot);
if (childContext) {
childContext->SetPrivateBrowsing(isPrivateBrowsingWindow);
}
} else if (windowIsNew) {
nsCOMPtr<nsILoadContext> childContext = do_QueryInterface(newDocShellItem);
if (childContext) {
childContext->SetPrivateBrowsing(isPrivateBrowsingWindow);
}
}
if (uriToLoad && aNavigate) { // get the script principal and pass it to docshell