Bug 909218 - add defaultLoadFlags to nsIDocShell. r=bz

This commit is contained in:
Mark Hammond 2013-09-06 16:33:28 +10:00
parent a4824ee8b5
commit 94e78bfd55
3 changed files with 51 additions and 2 deletions

View File

@ -763,6 +763,7 @@ nsDocShell::nsDocShell():
mInEnsureScriptEnv(false),
#endif
mAffectPrivateSessionLifetime(true),
mDefaultLoadFlags(nsIRequest::LOAD_NORMAL),
mFrameType(eFrameTypeRegular),
mOwnOrContainingAppId(nsIScriptSecurityManager::UNKNOWN_APP_ID),
mParentCharsetSource(0)
@ -2876,6 +2877,12 @@ nsDocShell::SetDocLoaderParent(nsDocLoader * aParent)
SetAllowDNSPrefetch(value);
value = parentAsDocShell->GetAffectPrivateSessionLifetime();
SetAffectPrivateSessionLifetime(value);
uint32_t flags;
if (NS_SUCCEEDED(parentAsDocShell->GetDefaultLoadFlags(&flags)))
{
SetDefaultLoadFlags(flags);
}
}
nsCOMPtr<nsILoadContext> parentAsLoadContext(do_QueryInterface(parent));
@ -5368,6 +5375,32 @@ nsDocShell::GetSandboxFlags(uint32_t *aSandboxFlags)
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetDefaultLoadFlags(uint32_t aDefaultLoadFlags)
{
mDefaultLoadFlags = aDefaultLoadFlags;
// Recursively tell all of our children. We *do not* skip
// <iframe mozbrowser> children - if someone sticks custom flags in this
// docShell then they too get the same flags.
nsTObserverArray<nsDocLoader*>::ForwardIterator iter(mChildList);
while (iter.HasMore()) {
nsCOMPtr<nsIDocShell> docshell = do_QueryObject(iter.GetNext());
if (!docshell) {
continue;
}
docshell->SetDefaultLoadFlags(aDefaultLoadFlags);
}
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::GetDefaultLoadFlags(uint32_t *aDefaultLoadFlags)
{
*aDefaultLoadFlags = mDefaultLoadFlags;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetMixedContentChannel(nsIChannel* aMixedContentChannel)
{
@ -7791,6 +7824,9 @@ nsDocShell::RestoreFromHistory()
bool allowContentRetargeting = childShell->GetAllowContentRetargeting();
uint32_t defaultLoadFlags;
childShell->GetDefaultLoadFlags(&defaultLoadFlags);
// 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 and mInPrivateBrowsing, which
@ -7805,6 +7841,7 @@ nsDocShell::RestoreFromHistory()
childShell->SetAllowMedia(allowMedia);
childShell->SetAllowDNSPrefetch(allowDNSPrefetch);
childShell->SetAllowContentRetargeting(allowContentRetargeting);
childShell->SetDefaultLoadFlags(defaultLoadFlags);
rv = childShell->BeginRestore(nullptr, false);
NS_ENSURE_SUCCESS(rv, rv);
@ -9432,7 +9469,7 @@ nsDocShell::DoURILoad(nsIURI * aURI,
uriLoader = do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
nsLoadFlags loadFlags = mDefaultLoadFlags;
if (aFirstParty) {
// tag first party URL loads
loadFlags |= nsIChannel::LOAD_INITIAL_DOCUMENT_URI;

View File

@ -841,6 +841,7 @@ protected:
#endif
bool mAffectPrivateSessionLifetime;
uint64_t mHistoryID;
uint32_t mDefaultLoadFlags;
static nsIURIFixup *sURIFixup;

View File

@ -42,7 +42,9 @@ interface nsIVariant;
interface nsIPrivacyTransitionObserver;
interface nsIReflowObserver;
[scriptable, builtinclass, uuid(62f1b40d-1d15-4640-95dc-20caae775bd1)]
typedef unsigned long nsLoadFlags;
[scriptable, builtinclass, uuid(5f4d82fc-3220-4f7e-9b00-626f1033318a)]
interface nsIDocShell : nsIDocShellTreeItem
{
/**
@ -352,6 +354,15 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
attribute unsigned long loadType;
/*
* Default load flags (as defined in nsIRequest) that will be set on all
* requests made by this docShell and propagated to all child docShells.
* Default is no flags. Once set, only future requests initiated by the
* docShell are affected, so in general, these flags should be set before
* the docShell loads any content.
*/
attribute nsLoadFlags defaultLoadFlags;
/*
* returns true if the docshell is being destroyed, false otherwise
*/