Bug 795556 - Part 2: Move privacy status propagation for new windows into the platform. r=bz

This commit is contained in:
Josh Matthews
2012-10-10 11:28:42 -04:00
parent c5b97d8984
commit 3cd477f5ba
4 changed files with 51 additions and 18 deletions

View File

@@ -2793,24 +2793,26 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
}
SetAllowDNSPrefetch(value);
}
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
// Set the PB flag on the docshell based on the global PB mode for now
nsCOMPtr<nsIPrivateBrowsingService> pbs =
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
if (pbs) {
bool inPrivateBrowsing = false;
pbs->GetPrivateBrowsingEnabled(&inPrivateBrowsing);
SetUsePrivateBrowsing(inPrivateBrowsing);
}
#else
nsCOMPtr<nsILoadContext> parentAsLoadContext(do_QueryInterface(parent));
if (parentAsLoadContext &&
NS_SUCCEEDED(parentAsLoadContext->GetUsePrivateBrowsing(&value)))
{
SetUsePrivateBrowsing(value);
}
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
// Belt and suspenders - we want to catch any instances where the flag
// we're propagating doesn't match the global state.
nsCOMPtr<nsIPrivateBrowsingService> pbs =
do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
if (pbs) {
bool inPrivateBrowsing = false;
pbs->GetPrivateBrowsingEnabled(&inPrivateBrowsing);
NS_ASSERTION(inPrivateBrowsing == mInPrivateBrowsing,
"Privacy status of parent docshell doesn't match global state!");
}
#endif
}
nsCOMPtr<nsIURIContentListener> parentURIListener(do_GetInterface(parent));
if (parentURIListener)
mContentListener->SetParentContentListener(parentURIListener);