diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index c2b8901137f..60043bc2f19 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -87,6 +87,8 @@ #include "StructuredCloneUtils.h" #include "TabParent.h" #include "URIUtils.h" +#include "nsIWebBrowserChrome.h" +#include "nsIDocShell.h" #ifdef ANDROID # include "gfxAndroidPlatform.h" @@ -419,10 +421,29 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext, if (nsRefPtr cp = GetNewOrUsed(aContext.IsBrowserElement())) { nsRefPtr tp(new TabParent(aContext)); tp->SetOwnerElement(aFrameElement); + uint32_t chromeFlags = 0; + + // Propagate the private-browsing status of the element's parent + // docshell to the remote docshell, via the chrome flags. + nsCOMPtr frameElement = do_QueryInterface(aFrameElement); + MOZ_ASSERT(frameElement); + nsIDocShell* docShell = + frameElement->OwnerDoc()->GetWindow()->GetDocShell(); + MOZ_ASSERT(docShell); + nsCOMPtr loadContext = do_QueryInterface(docShell); + if (loadContext && loadContext->UsePrivateBrowsing()) { + chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW; + } + bool affectLifetime; + docShell->GetAffectPrivateSessionLifetime(&affectLifetime); + if (affectLifetime) { + chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME; + } + PBrowserParent* browser = cp->SendPBrowserConstructor( tp.forget().get(), // DeallocPBrowserParent() releases this ref. aContext.AsIPCTabContext(), - /* chromeFlags */ 0); + chromeFlags); return static_cast(browser); } return nullptr; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index bf7b04052be..22e9b39470d 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -688,6 +688,14 @@ TabChild::Init() nsCOMPtr docShell = do_GetInterface(mWebNav); MOZ_ASSERT(docShell); + + docShell->SetAffectPrivateSessionLifetime( + mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME); + nsCOMPtr loadContext = do_GetInterface(mWebNav); + MOZ_ASSERT(loadContext); + loadContext->SetPrivateBrowsing( + mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW); + nsCOMPtr webProgress = do_GetInterface(docShell); NS_ENSURE_TRUE(webProgress, NS_ERROR_FAILURE); webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_LOCATION); diff --git a/embedding/browser/webBrowser/nsIWebBrowserChrome.idl b/embedding/browser/webBrowser/nsIWebBrowserChrome.idl index a7d3cb27949..efa6b7a6229 100644 --- a/embedding/browser/webBrowser/nsIWebBrowserChrome.idl +++ b/embedding/browser/webBrowser/nsIWebBrowserChrome.idl @@ -69,8 +69,13 @@ interface nsIWebBrowserChrome : nsISupports // 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. + // + // CHROME_PRIVATE_LIFETIME causes the docshell to affect private-browsing + // session lifetime. This flag is currently respected only for remote + // docshells. const unsigned long CHROME_PRIVATE_WINDOW = 0x00010000; const unsigned long CHROME_NON_PRIVATE_WINDOW = 0x00020000; + const unsigned long CHROME_PRIVATE_LIFETIME = 0x00040000; // Prevents new window animations on Mac OS X Lion. Ignored on other // platforms.