Bug 722840 - Add private browsing attribute to docshells. r=bz

This commit is contained in:
Josh Matthews
2012-02-02 14:03:46 -05:00
parent fd88285285
commit a7d4bbf532
3 changed files with 41 additions and 3 deletions

View File

@@ -749,6 +749,7 @@ nsDocShell::nsDocShell():
mIsActive(true),
mIsAppTab(false),
mUseGlobalHistory(false),
mInPrivateBrowsing(false),
mFiredUnloadEvent(false),
mEODForCurrentDocument(false),
mURIResultedInDocument(false),
@@ -1984,6 +1985,30 @@ nsDocShell::SetAllowJavascript(bool aAllowJavascript)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing)
{
NS_ENSURE_ARG_POINTER(aUsePrivateBrowsing);
*aUsePrivateBrowsing = mInPrivateBrowsing;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetUsePrivateBrowsing(bool aUsePrivateBrowsing)
{
mInPrivateBrowsing = aUsePrivateBrowsing;
PRInt32 count = mChildList.Count();
for (PRInt32 i = 0; i < count; ++i) {
nsCOMPtr<nsILoadContext> shell = do_QueryInterface(ChildAt(i));
if (shell) {
shell->SetUsePrivateBrowsing(aUsePrivateBrowsing);
}
}
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetAllowMetaRedirects(bool * aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
@@ -2608,10 +2633,10 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
// If parent is another docshell, we inherit all their flags for
// allowing plugins, scripting etc.
bool value;
nsCOMPtr<nsIDocShell> parentAsDocShell(do_QueryInterface(parent));
if (parentAsDocShell)
{
bool value;
if (NS_SUCCEEDED(parentAsDocShell->GetAllowPlugins(&value)))
{
SetAllowPlugins(value);
@@ -2645,6 +2670,12 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
}
SetAllowDNSPrefetch(value);
}
nsCOMPtr<nsILoadContext> parentAsLoadContext(do_QueryInterface(parent));
if (parentAsLoadContext &&
NS_SUCCEEDED(parentAsLoadContext->GetUsePrivateBrowsing(&value)))
{
SetUsePrivateBrowsing(value);
}
nsCOMPtr<nsIURIContentListener> parentURIListener(do_GetInterface(parent));
if (parentURIListener)
@@ -7217,7 +7248,8 @@ nsDocShell::RestoreFromHistory()
// this.AddChild(child) calls child.SetDocLoaderParent(this), meaning
// that the child inherits our state. Among other things, this means
// that the child inherits our mIsActive, which is what we want.
// that the child inherits our mIsActive and mInPrivateBrowsing, which
// is what we want.
AddChild(childItem);
childShell->SetAllowPlugins(allowPlugins);