Bug 841495 - Implement background page thumbnail service (part 1: propagate private-browsing state from parent docshell to remote docshell). r=smaug

This commit is contained in:
Drew Willcoxon 2013-05-06 21:10:31 -07:00
parent 2bf222075b
commit 0c74f00f8b
3 changed files with 35 additions and 1 deletions

View File

@ -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<ContentParent> cp = GetNewOrUsed(aContext.IsBrowserElement())) {
nsRefPtr<TabParent> 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<Element> frameElement = do_QueryInterface(aFrameElement);
MOZ_ASSERT(frameElement);
nsIDocShell* docShell =
frameElement->OwnerDoc()->GetWindow()->GetDocShell();
MOZ_ASSERT(docShell);
nsCOMPtr<nsILoadContext> 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<TabParent*>(browser);
}
return nullptr;

View File

@ -688,6 +688,14 @@ TabChild::Init()
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebNav);
MOZ_ASSERT(docShell);
docShell->SetAffectPrivateSessionLifetime(
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME);
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(mWebNav);
MOZ_ASSERT(loadContext);
loadContext->SetPrivateBrowsing(
mChromeFlags & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW);
nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
NS_ENSURE_TRUE(webProgress, NS_ERROR_FAILURE);
webProgress->AddProgressListener(this, nsIWebProgress::NOTIFY_LOCATION);

View File

@ -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.