mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 819202 - Part 1: Implement the "non-private" window.open feature; r=bzbarsky
This patch adds support for a "non-private" window flag which can be used to open new chrome windows in non-private mode in per-window private browsing builds. It also tests to make sure that the flag is not accessible from content.
This commit is contained in:
parent
6fc966d0af
commit
9a46d83e97
@ -63,8 +63,15 @@ interface nsIWebBrowserChrome : nsISupports
|
||||
const unsigned long CHROME_WINDOW_MIN = 0x00004000;
|
||||
const unsigned long CHROME_WINDOW_POPUP = 0x00008000;
|
||||
|
||||
// private browsing windows
|
||||
// whether to open a new private window. CHROME_NON_PRIVATE_WINDOW
|
||||
// forces the opened window to be non-private, and overrides
|
||||
// CHROME_PRIVATE_WINDOW if it's set. CHROME_PRIVATE_WINDOW
|
||||
// forces the opened window to be private. If neither of these
|
||||
// flags are specified, the opened window will inherit the privacy
|
||||
// status of its opener. If there is no opener window, the new
|
||||
// window will be non-private.
|
||||
const unsigned long CHROME_PRIVATE_WINDOW = 0x00010000;
|
||||
const unsigned long CHROME_NON_PRIVATE_WINDOW = 0x00020000;
|
||||
|
||||
// Prevents new window animations on Mac OS X Lion. Ignored on other
|
||||
// platforms.
|
||||
|
@ -903,11 +903,13 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
||||
}
|
||||
|
||||
if (windowIsNew) {
|
||||
// See if the caller has requested a private browsing window, or if all
|
||||
// windows should be private.
|
||||
// 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_PRIVATE_WINDOW) &&
|
||||
!(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW));
|
||||
|
||||
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
nsCOMPtr<nsIPrivateBrowsingService> pbs =
|
||||
@ -921,7 +923,8 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow *aParent,
|
||||
|
||||
// Otherwise, propagate the privacy status of the parent window, if
|
||||
// available, to the child.
|
||||
if (!isPrivateBrowsingWindow) {
|
||||
if (!isPrivateBrowsingWindow &&
|
||||
!(chromeFlags & nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW)) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
GetWindowTreeItem(aParent, getter_AddRefs(parentItem));
|
||||
nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(parentItem);
|
||||
@ -1520,6 +1523,8 @@ uint32_t nsWindowWatcher::CalculateChromeFlags(nsIDOMWindow *aParent,
|
||||
if (isChrome) {
|
||||
chromeFlags |= WinHasOption(aFeatures, "private", 0, &presenceFlag) ?
|
||||
nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW : 0;
|
||||
chromeFlags |= WinHasOption(aFeatures, "non-private", 0, &presenceFlag) ?
|
||||
nsIWebBrowserChrome::CHROME_NON_PRIVATE_WINDOW : 0;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
||||
|
@ -5,4 +5,8 @@
|
||||
var win = window.open("about:blank", "_blank", "private");
|
||||
ok(!SpecialPowers.isWindowPrivate(win));
|
||||
win.close();
|
||||
// Also, make sure that passing non-private doesn't make any difference either
|
||||
win = window.open("about:blank", "_blank", "non-private");
|
||||
ok(!SpecialPowers.isWindowPrivate(win));
|
||||
win.close();
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user