Bug 1202634 - Make sure TabParent LoadContext for pop-ups shares private browsing state of opener. r=billm

This commit is contained in:
Mike Conley 2015-09-17 15:15:33 -04:00
parent 3ce252bdb7
commit dcb768bf20

View File

@ -128,9 +128,35 @@ nsIContentParent::AllocPBrowserParent(const TabId& aTabId,
return nullptr;
}
const IPCTabAppBrowserContext& appBrowser = aContext.appBrowserContext();
const PopupIPCTabContext& popupContext = appBrowser.get_PopupIPCTabContext();
uint32_t chromeFlags = aChromeFlags;
// CanOpenBrowser has ensured that the IPCTabContext is of
// type PopupIPCTabContext, and that the opener TabParent is
// reachable.
auto opener = TabParent::GetFrom(popupContext.opener().get_PBrowserParent());
// We must ensure that the private browsing and remoteness flags
// match those of the opener.
nsCOMPtr<nsILoadContext> loadContext = opener->GetLoadContext();
if (!loadContext) {
return nullptr;
}
bool isPrivate;
loadContext->GetUsePrivateBrowsing(&isPrivate);
if (isPrivate) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}
// And because we're allocating a remote browser, of course the
// window is remote.
chromeFlags |= nsIWebBrowserChrome::CHROME_REMOTE_WINDOW;
MaybeInvalidTabContext tc(aContext);
MOZ_ASSERT(tc.IsValid());
TabParent* parent = new TabParent(this, aTabId, tc.GetTabContext(), aChromeFlags);
TabParent* parent = new TabParent(this, aTabId, tc.GetTabContext(), chromeFlags);
// We release this ref in DeallocPBrowserParent()
NS_ADDREF(parent);