зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1492648 - Move from nsDocShellLoadInfo to nsDocShellLoadState r=bzbarsky,nika
Creates the nsDocShellLoadState object, which is basically nsDocShellLoadInfo plus a few extra fields to make it usable as a single argument to nsDocShell::LoadURI (and eventually nsDocShell::InternalLoad). Subframe history handling is a huge logic block in nsDocShell::LoadURI, which is only used on history loads. This patch also extracts the logic out into its own function to make the body of LoadURI clearer. Differential Revision: https://phabricator.services.mozilla.com/D6944 --HG-- rename : docshell/base/nsDocShellLoadInfo.cpp => docshell/base/nsDocShellLoadState.cpp rename : docshell/base/nsDocShellLoadInfo.h => docshell/base/nsDocShellLoadState.h extra : moz-landing-system : lando
This commit is contained in:
Родитель
00b47a070d
Коммит
0bb3246aa5
|
@ -38,19 +38,24 @@ NS_IMPL_CI_INTERFACE_GETTER(NullPrincipal,
|
|||
/* static */ already_AddRefed<NullPrincipal>
|
||||
NullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
|
||||
{
|
||||
RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
|
||||
nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef());
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
return nullPrin.forget();
|
||||
MOZ_ASSERT(aInheritFrom);
|
||||
return CreateWithInheritedAttributes(Cast(aInheritFrom)->OriginAttributesRef(), false);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<NullPrincipal>
|
||||
NullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty)
|
||||
{
|
||||
OriginAttributes attrs = nsDocShell::Cast(aDocShell)->GetOriginAttributes();
|
||||
MOZ_ASSERT(aDocShell);
|
||||
|
||||
OriginAttributes attrs = nsDocShell::Cast(aDocShell)->GetOriginAttributes();
|
||||
return CreateWithInheritedAttributes(attrs, aIsFirstParty);
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<NullPrincipal>
|
||||
NullPrincipal::CreateWithInheritedAttributes(const OriginAttributes& aOriginAttributes, bool aIsFirstParty)
|
||||
{
|
||||
RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
|
||||
nsresult rv = nullPrin->Init(attrs, aIsFirstParty);
|
||||
nsresult rv = nullPrin->Init(aOriginAttributes, aIsFirstParty);
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
return nullPrin.forget();
|
||||
}
|
||||
|
|
|
@ -56,14 +56,19 @@ public:
|
|||
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
|
||||
NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
|
||||
|
||||
static already_AddRefed<NullPrincipal> CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);
|
||||
static already_AddRefed<NullPrincipal>
|
||||
CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom);
|
||||
|
||||
// Create NullPrincipal with origin attributes from docshell.
|
||||
// If aIsFirstParty is true, and the pref 'privacy.firstparty.isolate' is also
|
||||
// enabled, the mFirstPartyDomain value of the origin attributes will be set
|
||||
// to an unique value.
|
||||
static already_AddRefed<NullPrincipal>
|
||||
CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty = false);
|
||||
CreateWithInheritedAttributes(nsIDocShell* aDocShell,
|
||||
bool aIsFirstParty = false);
|
||||
static already_AddRefed<NullPrincipal>
|
||||
CreateWithInheritedAttributes(const OriginAttributes& aOriginAttributes,
|
||||
bool aIsFirstParty = false);
|
||||
|
||||
static already_AddRefed<NullPrincipal>
|
||||
Create(const OriginAttributes& aOriginAttributes,
|
||||
|
@ -85,7 +90,8 @@ public:
|
|||
protected:
|
||||
virtual ~NullPrincipal() = default;
|
||||
|
||||
bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) override
|
||||
bool SubsumesInternal(nsIPrincipal* aOther,
|
||||
DocumentDomainConsideration aConsideration) override
|
||||
{
|
||||
return aOther == this;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ XPIDL_MODULE = 'docshell'
|
|||
EXPORTS += [
|
||||
'nsCTooltipTextProvider.h',
|
||||
'nsDocShell.h',
|
||||
'nsDocShellLoadInfo.h',
|
||||
'nsDocShellLoadState.h',
|
||||
'nsDocShellLoadTypes.h',
|
||||
'nsDocShellTreeOwner.h',
|
||||
'nsILinkHandler.h',
|
||||
|
@ -88,7 +88,7 @@ UNIFIED_SOURCES += [
|
|||
'nsDocShell.cpp',
|
||||
'nsDocShellEditorData.cpp',
|
||||
'nsDocShellEnumerator.cpp',
|
||||
'nsDocShellLoadInfo.cpp',
|
||||
'nsDocShellLoadState.cpp',
|
||||
'nsDocShellTreeOwner.cpp',
|
||||
'nsDSURIContentListener.cpp',
|
||||
'nsPingListener.cpp',
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
#include "nsDocShellCID.h"
|
||||
#include "nsDocShellEditorData.h"
|
||||
#include "nsDocShellEnumerator.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadTypes.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
|
@ -643,14 +643,12 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURI(nsIURI* aURI,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
uint32_t aLoadFlags,
|
||||
bool aFirstParty)
|
||||
nsDocShell::LoadURI(nsDocShellLoadState* aLoadState)
|
||||
{
|
||||
MOZ_ASSERT(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
|
||||
"Unexpected flags");
|
||||
MOZ_ASSERT((aLoadFlags & 0xf) == 0, "Should not have these flags set");
|
||||
MOZ_ASSERT(aLoadState, "Must have a valid load state!");
|
||||
MOZ_ASSERT((aLoadState->LoadFlags() & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0,
|
||||
"Should not have these flags set");
|
||||
MOZ_ASSERT(aLoadState->URI(), "Should have a valid URI to load");
|
||||
|
||||
// Note: we allow loads to get through here even if mFiredUnloadEvent is
|
||||
// true; that case will get handled in LoadInternal or LoadHistoryEntry,
|
||||
|
@ -662,86 +660,121 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
Maybe<nsCOMPtr<nsIURI>> resultPrincipalURI;
|
||||
bool keepResultPrincipalURIIfSet = false;
|
||||
bool loadReplace = false;
|
||||
nsCOMPtr<nsIInputStream> postStream;
|
||||
nsCOMPtr<nsIInputStream> headersStream;
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
bool inheritPrincipal = false;
|
||||
bool principalIsExplicit = false;
|
||||
bool sendReferrer = true;
|
||||
uint32_t referrerPolicy = RP_Unset;
|
||||
bool isSrcdoc = false;
|
||||
nsCOMPtr<nsISHEntry> shEntry;
|
||||
nsString target;
|
||||
nsAutoString srcdoc;
|
||||
bool forceAllowDataURI = false;
|
||||
bool originalFrameSrc = false;
|
||||
nsCOMPtr<nsIDocShell> sourceDocShell;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
uint32_t loadType = MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags);
|
||||
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
if (!StartupTimeline::HasRecord(StartupTimeline::FIRST_LOAD_URI) &&
|
||||
mItemType == typeContent && !NS_IsAboutBlank(aURI)) {
|
||||
mItemType == typeContent && !NS_IsAboutBlank(aLoadState->URI())) {
|
||||
StartupTimeline::RecordOnce(StartupTimeline::FIRST_LOAD_URI);
|
||||
}
|
||||
|
||||
// Extract the info from the DocShellLoadInfo struct...
|
||||
if (aLoadInfo) {
|
||||
referrer = aLoadInfo->Referrer();
|
||||
originalURI = aLoadInfo->OriginalURI();
|
||||
aLoadInfo->GetMaybeResultPrincipalURI(resultPrincipalURI);
|
||||
keepResultPrincipalURIIfSet = aLoadInfo->KeepResultPrincipalURIIfSet();
|
||||
loadReplace = aLoadInfo->LoadReplace();
|
||||
// Get the appropriate loadType from nsIDocShellLoadInfo type
|
||||
loadType = aLoadInfo->LoadType();
|
||||
|
||||
triggeringPrincipal = aLoadInfo->TriggeringPrincipal();
|
||||
inheritPrincipal = aLoadInfo->InheritPrincipal();
|
||||
principalIsExplicit = aLoadInfo->PrincipalIsExplicit();
|
||||
shEntry = aLoadInfo->SHEntry();
|
||||
aLoadInfo->GetTarget(target);
|
||||
postStream = aLoadInfo->PostDataStream();
|
||||
headersStream = aLoadInfo->HeadersStream();
|
||||
sendReferrer = aLoadInfo->SendReferrer();
|
||||
referrerPolicy = aLoadInfo->ReferrerPolicy();
|
||||
isSrcdoc = aLoadInfo->IsSrcdocLoad();
|
||||
aLoadInfo->GetSrcdocData(srcdoc);
|
||||
sourceDocShell = aLoadInfo->SourceDocShell();
|
||||
baseURI = aLoadInfo->BaseURI();
|
||||
forceAllowDataURI = aLoadInfo->ForceAllowDataURI();
|
||||
originalFrameSrc = aLoadInfo->OriginalFrameSrc();
|
||||
}
|
||||
|
||||
MOZ_LOG(gDocShellLeakLog, LogLevel::Debug,
|
||||
("nsDocShell[%p]: loading %s with flags 0x%08x",
|
||||
this, aURI->GetSpecOrDefault().get(), aLoadFlags));
|
||||
this, aLoadState->URI()->GetSpecOrDefault().get(),
|
||||
aLoadState->LoadFlags()));
|
||||
|
||||
if (!shEntry &&
|
||||
!LOAD_TYPE_HAS_FLAGS(loadType, LOAD_FLAGS_REPLACE_HISTORY)) {
|
||||
// First verify if this is a subframe.
|
||||
if (!aLoadState->SHEntry() &&
|
||||
!LOAD_TYPE_HAS_FLAGS(aLoadState->LoadType(),
|
||||
LOAD_FLAGS_REPLACE_HISTORY)) {
|
||||
// This is possibly a subframe, so handle it accordingly.
|
||||
//
|
||||
// If history exists, it will be loaded into the aLoadState object, and the
|
||||
// LoadType will be changed.
|
||||
MaybeHandleSubframeHistory(aLoadState);
|
||||
}
|
||||
|
||||
if (aLoadState->SHEntry()) {
|
||||
#ifdef DEBUG
|
||||
MOZ_LOG(gDocShellLog, LogLevel::Debug,
|
||||
("nsDocShell[%p]: loading from session history", this));
|
||||
#endif
|
||||
|
||||
return LoadHistoryEntry(aLoadState->SHEntry(), aLoadState->LoadType());
|
||||
}
|
||||
|
||||
// On history navigation via Back/Forward buttons, don't execute
|
||||
// automatic JavaScript redirection such as |location.href = ...| or
|
||||
// |window.open()|
|
||||
//
|
||||
// LOAD_NORMAL: window.open(...) etc.
|
||||
// LOAD_STOP_CONTENT: location.href = ..., location.assign(...)
|
||||
if ((aLoadState->LoadType() == LOAD_NORMAL ||
|
||||
aLoadState->LoadType() == LOAD_STOP_CONTENT) &&
|
||||
ShouldBlockLoadingForBackButton()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Set up the inheriting principal in LoadState.
|
||||
nsresult rv = aLoadState->SetupInheritingPrincipal(mItemType, mOriginAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aLoadState->SetupTriggeringPrincipal(mOriginAttributes);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aLoadState->CalculateDocShellInternalLoadFlags();
|
||||
|
||||
mozilla::Maybe<nsCOMPtr<nsIURI>> resultPrincipalURI;
|
||||
aLoadState->GetMaybeResultPrincipalURI(resultPrincipalURI);
|
||||
|
||||
MOZ_ASSERT(aLoadState->TypeHint().IsVoid(),
|
||||
"Typehint should be null when calling InternalLoad from LoadURI");
|
||||
MOZ_ASSERT(aLoadState->FileName().IsVoid(),
|
||||
"FileName should be null when calling InternalLoad from LoadURI");
|
||||
MOZ_ASSERT(aLoadState->SHEntry() == nullptr,
|
||||
"SHEntry should be null when calling InternalLoad from LoadURI");
|
||||
|
||||
return InternalLoad(aLoadState->URI(),
|
||||
aLoadState->OriginalURI(),
|
||||
resultPrincipalURI,
|
||||
aLoadState->KeepResultPrincipalURIIfSet(),
|
||||
aLoadState->LoadReplace(),
|
||||
aLoadState->Referrer(),
|
||||
aLoadState->ReferrerPolicy(),
|
||||
aLoadState->TriggeringPrincipal(),
|
||||
aLoadState->PrincipalToInherit(),
|
||||
aLoadState->DocShellInternalLoadFlags(),
|
||||
aLoadState->Target(),
|
||||
aLoadState->TypeHint(),
|
||||
aLoadState->FileName(),
|
||||
aLoadState->PostDataStream(),
|
||||
aLoadState->HeadersStream(),
|
||||
aLoadState->LoadType(),
|
||||
aLoadState->SHEntry(),
|
||||
aLoadState->FirstParty(),
|
||||
aLoadState->SrcdocData(),
|
||||
aLoadState->SourceDocShell(),
|
||||
aLoadState->BaseURI(),
|
||||
nullptr, // no nsIDocShell
|
||||
nullptr); // no nsIRequest
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
|
||||
{
|
||||
// First, verify if this is a subframe.
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentAsItem));
|
||||
nsCOMPtr<nsIDocShell> parentDS(do_QueryInterface(parentAsItem));
|
||||
uint32_t parentLoadType;
|
||||
|
||||
if (parentDS && parentDS != static_cast<nsIDocShell*>(this)) {
|
||||
/* OK. It is a subframe. Checkout the
|
||||
* parent's loadtype. If the parent was loaded thro' a history
|
||||
* mechanism, then get the SH entry for the child from the parent.
|
||||
* This is done to restore frameset navigation while going back/forward.
|
||||
* If the parent was loaded through any other loadType, set the
|
||||
* child's loadType too accordingly, so that session history does not
|
||||
* get confused.
|
||||
if (!parentDS || parentDS == static_cast<nsIDocShell*>(this)) {
|
||||
// This is the root docshell. If we got here while
|
||||
// executing an onLoad Handler,this load will not go
|
||||
// into session history.
|
||||
bool inOnLoadHandler = false;
|
||||
GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
if (inOnLoadHandler) {
|
||||
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* OK. It is a subframe. Checkout the parent's loadtype. If the parent was
|
||||
* loaded through a history mechanism, then get the SH entry for the child from
|
||||
* the parent. This is done to restore frameset navigation while going
|
||||
* back/forward. If the parent was loaded through any other loadType, set the
|
||||
* child's loadType too accordingly, so that session history does not get
|
||||
* confused.
|
||||
*/
|
||||
|
||||
// Get the parent's load type
|
||||
uint32_t parentLoadType;
|
||||
parentDS->GetLoadType(&parentLoadType);
|
||||
|
||||
// Get the ShEntry for the child from the parent
|
||||
|
@ -749,13 +782,17 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
bool oshe = false;
|
||||
parentDS->GetCurrentSHEntry(getter_AddRefs(currentSH), &oshe);
|
||||
bool dynamicallyAddedChild = mDynamicallyCreated;
|
||||
|
||||
if (!dynamicallyAddedChild && !oshe && currentSH) {
|
||||
currentSH->HasDynamicallyAddedChild(&dynamicallyAddedChild);
|
||||
}
|
||||
|
||||
if (!dynamicallyAddedChild) {
|
||||
// Only use the old SHEntry, if we're sure enough that
|
||||
// it wasn't originally for some other frame.
|
||||
nsCOMPtr<nsISHEntry> shEntry;
|
||||
parentDS->GetChildSHEntry(mChildOffset, getter_AddRefs(shEntry));
|
||||
aLoadState->SetSHEntry(shEntry);
|
||||
}
|
||||
|
||||
// Make some decisions on the child frame's loadType based on the
|
||||
|
@ -768,58 +805,13 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
// currentSHEntry is null.
|
||||
nsCOMPtr<nsISHEntry> currentChildEntry;
|
||||
GetCurrentSHEntry(getter_AddRefs(currentChildEntry), &oshe);
|
||||
if (!mCurrentURI || (NS_IsAboutBlank(mCurrentURI) && !currentChildEntry)) {
|
||||
// This is a newly created frame. Check for exception cases first.
|
||||
// By default the subframe will inherit the parent's loadType.
|
||||
if (shEntry && (parentLoadType == LOAD_NORMAL ||
|
||||
parentLoadType == LOAD_LINK ||
|
||||
parentLoadType == LOAD_NORMAL_EXTERNAL)) {
|
||||
// The parent was loaded normally. In this case, this *brand new*
|
||||
// child really shouldn't have a SHEntry. If it does, it could be
|
||||
// because the parent is replacing an existing frame with a new frame,
|
||||
// in the onLoadHandler. We don't want this url to get into session
|
||||
// history. Clear off shEntry, and set load type to
|
||||
// LOAD_BYPASS_HISTORY.
|
||||
bool inOnLoadHandler = false;
|
||||
parentDS->GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
if (inOnLoadHandler) {
|
||||
loadType = LOAD_NORMAL_REPLACE;
|
||||
shEntry = nullptr;
|
||||
}
|
||||
} else if (parentLoadType == LOAD_REFRESH) {
|
||||
// Clear shEntry. For refresh loads, we have to load
|
||||
// what comes thro' the pipe, not what's in history.
|
||||
shEntry = nullptr;
|
||||
} else if ((parentLoadType == LOAD_BYPASS_HISTORY) ||
|
||||
(shEntry &&
|
||||
((parentLoadType & LOAD_CMD_HISTORY) ||
|
||||
(parentLoadType == LOAD_RELOAD_NORMAL) ||
|
||||
(parentLoadType == LOAD_RELOAD_CHARSET_CHANGE) ||
|
||||
(parentLoadType == LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE) ||
|
||||
(parentLoadType == LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE)))) {
|
||||
// If the parent url, bypassed history or was loaded from
|
||||
// history, pass on the parent's loadType to the new child
|
||||
// frame too, so that the child frame will also
|
||||
// avoid getting into history.
|
||||
loadType = parentLoadType;
|
||||
} else if (parentLoadType == LOAD_ERROR_PAGE) {
|
||||
// If the parent document is an error page, we don't
|
||||
// want to update global/session history. However,
|
||||
// this child frame is not an error page.
|
||||
loadType = LOAD_BYPASS_HISTORY;
|
||||
} else if ((parentLoadType == LOAD_RELOAD_BYPASS_CACHE) ||
|
||||
(parentLoadType == LOAD_RELOAD_BYPASS_PROXY) ||
|
||||
(parentLoadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE)) {
|
||||
// the new frame should inherit the parent's load type so that it also
|
||||
// bypasses the cache and/or proxy
|
||||
loadType = parentLoadType;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (mCurrentURI && (!NS_IsAboutBlank(mCurrentURI) || currentChildEntry)) {
|
||||
// This is a pre-existing subframe. If
|
||||
// 1. The load of this frame was not originally initiated by session
|
||||
// history directly (i.e. (!shEntry) condition succeeded, but it can
|
||||
// still be a history load on parent which causes this frame being
|
||||
// loaded), and
|
||||
// loaded), which we checked with the above assert, and
|
||||
// 2. mCurrentURI is not null, nor the initial about:blank,
|
||||
// it is possible that a parent's onLoadHandler or even self's
|
||||
// onLoadHandler is loading a new page in this child. Check parent's and
|
||||
|
@ -831,187 +823,57 @@ nsDocShell::LoadURI(nsIURI* aURI,
|
|||
GetBusyFlags(&selfBusy);
|
||||
if (parentBusy & BUSY_FLAGS_BUSY ||
|
||||
selfBusy & BUSY_FLAGS_BUSY) {
|
||||
loadType = LOAD_NORMAL_REPLACE;
|
||||
shEntry = nullptr;
|
||||
}
|
||||
}
|
||||
} // parentDS
|
||||
else {
|
||||
// This is the root docshell. If we got here while
|
||||
// executing an onLoad Handler,this load will not go
|
||||
// into session history.
|
||||
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
aLoadState->SetSHEntry(nullptr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// This is a newly created frame. Check for exception cases first.
|
||||
// By default the subframe will inherit the parent's loadType.
|
||||
if (aLoadState->SHEntry() && (parentLoadType == LOAD_NORMAL ||
|
||||
parentLoadType == LOAD_LINK ||
|
||||
parentLoadType == LOAD_NORMAL_EXTERNAL)) {
|
||||
// The parent was loaded normally. In this case, this *brand new*
|
||||
// child really shouldn't have a SHEntry. If it does, it could be
|
||||
// because the parent is replacing an existing frame with a new frame,
|
||||
// in the onLoadHandler. We don't want this url to get into session
|
||||
// history. Clear off shEntry, and set load type to
|
||||
// LOAD_BYPASS_HISTORY.
|
||||
bool inOnLoadHandler = false;
|
||||
GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
parentDS->GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
if (inOnLoadHandler) {
|
||||
loadType = LOAD_NORMAL_REPLACE;
|
||||
}
|
||||
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
aLoadState->SetSHEntry(nullptr);
|
||||
}
|
||||
} // !shEntry
|
||||
|
||||
if (shEntry) {
|
||||
#ifdef DEBUG
|
||||
MOZ_LOG(gDocShellLog, LogLevel::Debug,
|
||||
("nsDocShell[%p]: loading from session history", this));
|
||||
#endif
|
||||
|
||||
return LoadHistoryEntry(shEntry, loadType);
|
||||
} else if (parentLoadType == LOAD_REFRESH) {
|
||||
// Clear shEntry. For refresh loads, we have to load
|
||||
// what comes through the pipe, not what's in history.
|
||||
aLoadState->SetSHEntry(nullptr);
|
||||
} else if ((parentLoadType == LOAD_BYPASS_HISTORY) ||
|
||||
(aLoadState->SHEntry() &&
|
||||
((parentLoadType & LOAD_CMD_HISTORY) ||
|
||||
(parentLoadType == LOAD_RELOAD_NORMAL) ||
|
||||
(parentLoadType == LOAD_RELOAD_CHARSET_CHANGE) ||
|
||||
(parentLoadType == LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE) ||
|
||||
(parentLoadType == LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE)))) {
|
||||
// If the parent url, bypassed history or was loaded from
|
||||
// history, pass on the parent's loadType to the new child
|
||||
// frame too, so that the child frame will also
|
||||
// avoid getting into history.
|
||||
aLoadState->SetLoadType(parentLoadType);
|
||||
} else if (parentLoadType == LOAD_ERROR_PAGE) {
|
||||
// If the parent document is an error page, we don't
|
||||
// want to update global/session history. However,
|
||||
// this child frame is not an error page.
|
||||
aLoadState->SetLoadType(LOAD_BYPASS_HISTORY);
|
||||
} else if ((parentLoadType == LOAD_RELOAD_BYPASS_CACHE) ||
|
||||
(parentLoadType == LOAD_RELOAD_BYPASS_PROXY) ||
|
||||
(parentLoadType == LOAD_RELOAD_BYPASS_PROXY_AND_CACHE)) {
|
||||
// the new frame should inherit the parent's load type so that it also
|
||||
// bypasses the cache and/or proxy
|
||||
aLoadState->SetLoadType(parentLoadType);
|
||||
}
|
||||
|
||||
// On history navigation via Back/Forward buttons, don't execute
|
||||
// automatic JavaScript redirection such as |location.href = ...| or
|
||||
// |window.open()|
|
||||
//
|
||||
// LOAD_NORMAL: window.open(...) etc.
|
||||
// LOAD_STOP_CONTENT: location.href = ..., location.assign(...)
|
||||
if ((loadType == LOAD_NORMAL || loadType == LOAD_STOP_CONTENT) &&
|
||||
ShouldBlockLoadingForBackButton()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Perform the load...
|
||||
|
||||
// We need a principalToInherit.
|
||||
//
|
||||
// If principalIsExplicit is not set there are 4 possibilities:
|
||||
// (1) If the system principal or an expanded principal was passed
|
||||
// in and we're a typeContent docshell, inherit the principal
|
||||
// from the current document instead.
|
||||
// (2) In all other cases when the principal passed in is not null,
|
||||
// use that principal.
|
||||
// (3) If the caller has allowed inheriting from the current document,
|
||||
// or if we're being called from system code (eg chrome JS or pure
|
||||
// C++) then inheritPrincipal should be true and InternalLoad will get
|
||||
// a principal from the current document. If none of these things are
|
||||
// true, then
|
||||
// (4) we don't pass a principal into the channel, and a principal will be
|
||||
// created later from the channel's internal data.
|
||||
//
|
||||
// If principalIsExplicit *is* set, there are 4 possibilities
|
||||
// (1) If the system principal or an expanded principal was passed in
|
||||
// and we're a typeContent docshell, return an error.
|
||||
// (2) In all other cases when the principal passed in is not null,
|
||||
// use that principal.
|
||||
// (3) If the caller has allowed inheriting from the current document,
|
||||
// then inheritPrincipal should be true and InternalLoad will get
|
||||
// a principal from the current document. If none of these things are
|
||||
// true, then
|
||||
// (4) we dont' pass a principal into the channel, and a principal will be
|
||||
// created later from the channel's internal data.
|
||||
nsCOMPtr<nsIPrincipal> principalToInherit = triggeringPrincipal;
|
||||
if (principalToInherit && mItemType != typeChrome) {
|
||||
if (nsContentUtils::IsSystemPrincipal(principalToInherit)) {
|
||||
if (principalIsExplicit) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
principalToInherit = nullptr;
|
||||
inheritPrincipal = true;
|
||||
} else if (nsContentUtils::IsExpandedPrincipal(principalToInherit)) {
|
||||
if (principalIsExplicit) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
// Don't inherit from the current page. Just do the safe thing
|
||||
// and pretend that we were loaded by a nullprincipal.
|
||||
//
|
||||
// We didn't inherit OriginAttributes here as ExpandedPrincipal doesn't
|
||||
// have origin attributes.
|
||||
principalToInherit = NullPrincipal::CreateWithInheritedAttributes(this);
|
||||
inheritPrincipal = false;
|
||||
}
|
||||
}
|
||||
if (!principalToInherit && !inheritPrincipal && !principalIsExplicit) {
|
||||
// See if there's system or chrome JS code running
|
||||
inheritPrincipal = nsContentUtils::LegacyIsCallerChromeOrNativeCode();
|
||||
}
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL) {
|
||||
inheritPrincipal = false;
|
||||
// If aFirstParty is true and the pref 'privacy.firstparty.isolate' is
|
||||
// enabled, we will set firstPartyDomain on the origin attributes.
|
||||
principalToInherit = NullPrincipal::CreateWithInheritedAttributes(this, aFirstParty);
|
||||
}
|
||||
|
||||
// If the triggeringPrincipal is not passed explicitly, we first try to create
|
||||
// a principal from the referrer, since the referrer URI reflects the web origin
|
||||
// that triggered the load. If there is no referrer URI, we fall back to using
|
||||
// the SystemPrincipal. It's safe to assume that no provided triggeringPrincipal
|
||||
// and no referrer simulate a load that was triggered by the system.
|
||||
// It's important to note that this block of code needs to appear *after* the block
|
||||
// where we munge the principalToInherit, because otherwise we would never enter
|
||||
// code blocks checking if the principalToInherit is null and we will end up with
|
||||
// a wrong inheritPrincipal flag.
|
||||
if (!triggeringPrincipal) {
|
||||
if (referrer) {
|
||||
nsresult rv = CreatePrincipalFromReferrer(referrer,
|
||||
getter_AddRefs(triggeringPrincipal));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else {
|
||||
triggeringPrincipal = nsContentUtils::GetSystemPrincipal();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
|
||||
if (inheritPrincipal) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(principalToInherit), "Should not inherit SystemPrincipal");
|
||||
flags |= INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL;
|
||||
}
|
||||
|
||||
if (!sendReferrer) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER;
|
||||
}
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
||||
}
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_FIRST_LOAD) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_FIRST_LOAD;
|
||||
}
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_BYPASS_CLASSIFIER) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER;
|
||||
}
|
||||
|
||||
if (aLoadFlags & LOAD_FLAGS_FORCE_ALLOW_COOKIES) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES;
|
||||
}
|
||||
|
||||
if (isSrcdoc) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_IS_SRCDOC;
|
||||
}
|
||||
|
||||
if (forceAllowDataURI) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
|
||||
}
|
||||
|
||||
if (originalFrameSrc) {
|
||||
flags |= INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC;
|
||||
}
|
||||
|
||||
return InternalLoad(aURI,
|
||||
originalURI,
|
||||
resultPrincipalURI,
|
||||
keepResultPrincipalURIIfSet,
|
||||
loadReplace,
|
||||
referrer,
|
||||
referrerPolicy,
|
||||
triggeringPrincipal,
|
||||
principalToInherit,
|
||||
flags,
|
||||
target,
|
||||
nullptr, // No type hint
|
||||
VoidString(), // No forced download
|
||||
postStream,
|
||||
headersStream,
|
||||
loadType,
|
||||
nullptr, // No SHEntry
|
||||
aFirstParty,
|
||||
srcdoc,
|
||||
sourceDocShell,
|
||||
baseURI,
|
||||
nullptr, // No nsIDocShell
|
||||
nullptr); // No nsIRequest
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4226,7 +4088,7 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI,
|
|||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
NS_ASSERTION((aLoadFlags & 0xf) == 0, "Unexpected flags");
|
||||
NS_ASSERTION((aLoadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0, "Unexpected flags");
|
||||
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
|
@ -4321,27 +4183,28 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI,
|
|||
uint32_t extraFlags = (aLoadFlags & EXTRA_LOAD_FLAGS);
|
||||
aLoadFlags &= ~EXTRA_LOAD_FLAGS;
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
/*
|
||||
* If the user "Disables Protection on This Page", we have to make sure to
|
||||
* remember the users decision when opening links in child tabs [Bug 906190]
|
||||
*/
|
||||
uint32_t loadType;
|
||||
if (aLoadFlags & LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
|
||||
loadType = MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags);
|
||||
loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags));
|
||||
} else {
|
||||
loadType = MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags);
|
||||
loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags));
|
||||
}
|
||||
|
||||
loadInfo->SetLoadType(loadType);
|
||||
loadInfo->SetPostDataStream(postStream);
|
||||
loadInfo->SetReferrer(aReferringURI);
|
||||
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadInfo->SetHeadersStream(aHeaderStream);
|
||||
loadInfo->SetBaseURI(aBaseURI);
|
||||
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadInfo->SetForceAllowDataURI(forceAllowDataURI);
|
||||
loadState->SetURI(uri);
|
||||
loadState->SetLoadFlags(extraFlags);
|
||||
loadState->SetFirstParty(true);
|
||||
loadState->SetPostDataStream(postStream);
|
||||
loadState->SetReferrer(aReferringURI);
|
||||
loadState->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadState->SetHeadersStream(aHeaderStream);
|
||||
loadState->SetBaseURI(aBaseURI);
|
||||
loadState->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadState->SetForceAllowDataURI(forceAllowDataURI);
|
||||
|
||||
if (fixupInfo) {
|
||||
nsAutoString searchProvider, keyword;
|
||||
|
@ -4350,7 +4213,7 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI,
|
|||
MaybeNotifyKeywordSearchLoading(searchProvider, keyword);
|
||||
}
|
||||
|
||||
rv = LoadURI(uri, loadInfo, extraFlags, true);
|
||||
rv = LoadURI(loadState);
|
||||
|
||||
// Save URI string in case it's needed later when
|
||||
// sending to search engine service in EndPageLoad()
|
||||
|
@ -4918,7 +4781,7 @@ nsDocShell::LoadErrorPage(nsIURI* aErrorURI, nsIURI* aFailedURI, nsIChannel* aFa
|
|||
return InternalLoad(aErrorURI, nullptr, Nothing(), false, false, nullptr, RP_Unset,
|
||||
nsContentUtils::GetSystemPrincipal(), nullptr,
|
||||
INTERNAL_LOAD_FLAGS_NONE, EmptyString(),
|
||||
nullptr, VoidString(), nullptr, nullptr,
|
||||
VoidCString(), VoidString(), nullptr, nullptr,
|
||||
LOAD_ERROR_PAGE, nullptr, true, VoidString(), this,
|
||||
nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
@ -4930,7 +4793,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
nsresult rv;
|
||||
NS_ASSERTION(((aReloadFlags & 0xf) == 0),
|
||||
NS_ASSERTION(((aReloadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0),
|
||||
"Reload command not updated to use load flags!");
|
||||
NS_ASSERTION((aReloadFlags & EXTRA_LOAD_FLAGS) == 0,
|
||||
"Don't pass these flags to Reload");
|
||||
|
@ -5018,7 +4881,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
triggeringPrincipal,
|
||||
flags,
|
||||
EmptyString(), // No window target
|
||||
NS_LossyConvertUTF16toASCII(contentTypeHint).get(),
|
||||
NS_LossyConvertUTF16toASCII(contentTypeHint),
|
||||
VoidString(), // No forced download
|
||||
nullptr, // No post data
|
||||
nullptr, // No headers data
|
||||
|
@ -6270,22 +6133,22 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
/* We do need to pass in a referrer, but we don't want it to
|
||||
* be sent to the server.
|
||||
*/
|
||||
loadInfo->SetSendReferrer(false);
|
||||
loadState->SetSendReferrer(false);
|
||||
|
||||
/* for most refreshes the current URI is an appropriate
|
||||
* internal referrer
|
||||
*/
|
||||
loadInfo->SetReferrer(mCurrentURI);
|
||||
loadState->SetReferrer(mCurrentURI);
|
||||
|
||||
loadInfo->SetOriginalURI(mCurrentURI);
|
||||
loadInfo->SetResultPrincipalURI(aURI);
|
||||
loadInfo->SetResultPrincipalURIIsSome(true);
|
||||
loadInfo->SetKeepResultPrincipalURIIfSet(true);
|
||||
loadState->SetOriginalURI(mCurrentURI);
|
||||
loadState->SetResultPrincipalURI(aURI);
|
||||
loadState->SetResultPrincipalURIIsSome(true);
|
||||
loadState->SetKeepResultPrincipalURIIfSet(true);
|
||||
|
||||
// Set the triggering pricipal to aPrincipal if available, or current
|
||||
// document's principal otherwise.
|
||||
|
@ -6297,8 +6160,8 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
}
|
||||
principal = doc->NodePrincipal();
|
||||
}
|
||||
loadInfo->SetTriggeringPrincipal(principal);
|
||||
loadInfo->SetPrincipalIsExplicit(true);
|
||||
loadState->SetTriggeringPrincipal(principal);
|
||||
loadState->SetPrincipalIsExplicit(true);
|
||||
|
||||
/* Check if this META refresh causes a redirection
|
||||
* to another site.
|
||||
|
@ -6311,7 +6174,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
* we have in mind (15000 ms as defined by REFRESH_REDIRECT_TIMER).
|
||||
* Pass a REPLACE flag to LoadURI().
|
||||
*/
|
||||
loadInfo->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
loadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
|
||||
/* for redirects we mimic HTTP, which passes the
|
||||
* original referrer
|
||||
|
@ -6319,17 +6182,21 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
nsCOMPtr<nsIURI> internalReferrer;
|
||||
GetReferringURI(getter_AddRefs(internalReferrer));
|
||||
if (internalReferrer) {
|
||||
loadInfo->SetReferrer(internalReferrer);
|
||||
loadState->SetReferrer(internalReferrer);
|
||||
}
|
||||
} else {
|
||||
loadInfo->SetLoadType(LOAD_REFRESH);
|
||||
loadState->SetLoadType(LOAD_REFRESH);
|
||||
}
|
||||
|
||||
loadState->SetURI(aURI);
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL);
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
/*
|
||||
* LoadURI(...) will cancel all refresh timers... This causes the
|
||||
* Timer and its refreshData instance to be released...
|
||||
*/
|
||||
LoadURI(aURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL, true);
|
||||
LoadURI(loadState);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -9095,7 +8962,7 @@ public:
|
|||
nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIPrincipal* aPrincipalToInherit,
|
||||
uint32_t aFlags,
|
||||
const char* aTypeHint,
|
||||
const nsACString& aTypeHint,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
uint32_t aLoadType,
|
||||
|
@ -9105,6 +8972,7 @@ public:
|
|||
nsIDocShell* aSourceDocShell,
|
||||
nsIURI* aBaseURI)
|
||||
: mozilla::Runnable("InternalLoadEvent")
|
||||
, mTypeHint(aTypeHint)
|
||||
, mSrcdoc(aSrcdoc)
|
||||
, mDocShell(aDocShell)
|
||||
, mURI(aURI)
|
||||
|
@ -9125,12 +8993,6 @@ public:
|
|||
, mSourceDocShell(aSourceDocShell)
|
||||
, mBaseURI(aBaseURI)
|
||||
{
|
||||
// Make sure to keep null things null as needed
|
||||
if (aTypeHint) {
|
||||
mTypeHint = aTypeHint;
|
||||
} else {
|
||||
mTypeHint.SetIsVoid(true);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
|
@ -9143,8 +9005,7 @@ public:
|
|||
mReferrerPolicy,
|
||||
mTriggeringPrincipal, mPrincipalToInherit,
|
||||
mFlags, EmptyString(),
|
||||
mTypeHint.IsVoid() ? nullptr
|
||||
: mTypeHint.get(),
|
||||
mTypeHint,
|
||||
VoidString(), mPostData,
|
||||
mHeadersData, mLoadType, mSHEntry,
|
||||
mFirstParty, mSrcdoc, mSourceDocShell,
|
||||
|
@ -9215,7 +9076,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
nsIPrincipal* aPrincipalToInherit,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aWindowTarget,
|
||||
const char* aTypeHint,
|
||||
const nsACString& aTypeHint,
|
||||
const nsAString& aFileName,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
|
@ -9496,31 +9357,31 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
MOZ_ASSERT(!aSHEntry);
|
||||
MOZ_ASSERT(aFirstParty); // Windowwatcher will assume this.
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
// Set up our loadinfo so it will do the load as much like we would have
|
||||
// as possible.
|
||||
loadInfo->SetReferrer(aReferrer);
|
||||
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadInfo->SetSendReferrer(!(aFlags &
|
||||
loadState->SetReferrer(aReferrer);
|
||||
loadState->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadState->SetSendReferrer(!(aFlags &
|
||||
INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER));
|
||||
loadInfo->SetOriginalURI(aOriginalURI);
|
||||
loadInfo->SetMaybeResultPrincipalURI(aResultPrincipalURI);
|
||||
loadInfo->SetKeepResultPrincipalURIIfSet(aKeepResultPrincipalURIIfSet);
|
||||
loadInfo->SetLoadReplace(aLoadReplace);
|
||||
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadInfo->SetInheritPrincipal(
|
||||
loadState->SetOriginalURI(aOriginalURI);
|
||||
loadState->SetMaybeResultPrincipalURI(aResultPrincipalURI);
|
||||
loadState->SetKeepResultPrincipalURIIfSet(aKeepResultPrincipalURIIfSet);
|
||||
loadState->SetLoadReplace(aLoadReplace);
|
||||
loadState->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadState->SetInheritPrincipal(
|
||||
aFlags & INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL);
|
||||
// Explicit principal because we do not want any guesses as to what the
|
||||
// principal to inherit is: it should be aTriggeringPrincipal.
|
||||
loadInfo->SetPrincipalIsExplicit(true);
|
||||
loadInfo->SetLoadType(LOAD_LINK);
|
||||
loadInfo->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
|
||||
loadState->SetPrincipalIsExplicit(true);
|
||||
loadState->SetLoadType(LOAD_LINK);
|
||||
loadState->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
|
||||
|
||||
rv = win->Open(NS_ConvertUTF8toUTF16(spec),
|
||||
aWindowTarget, // window name
|
||||
EmptyString(), // Features
|
||||
loadInfo,
|
||||
loadState,
|
||||
true, // aForceNoOpener
|
||||
getter_AddRefs(newWin));
|
||||
MOZ_ASSERT(!newWin);
|
||||
|
@ -10331,7 +10192,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
uint32_t aReferrerPolicy,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIPrincipal* aPrincipalToInherit,
|
||||
const char* aTypeHint,
|
||||
const nsACString& aTypeHint,
|
||||
const nsAString& aFileName,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
|
@ -10680,8 +10541,8 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
loadInfo->SetResultPrincipalURI(aResultPrincipalURI.ref());
|
||||
}
|
||||
|
||||
if (aTypeHint && *aTypeHint) {
|
||||
channel->SetContentType(nsDependentCString(aTypeHint));
|
||||
if (!aTypeHint.IsVoid()) {
|
||||
channel->SetContentType(aTypeHint);
|
||||
mContentTypeHint = aTypeHint;
|
||||
} else {
|
||||
mContentTypeHint.Truncate();
|
||||
|
@ -12235,7 +12096,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
|
|||
principalToInherit,
|
||||
flags,
|
||||
EmptyString(), // No window target
|
||||
contentType.get(), // Type hint
|
||||
contentType, // Type hint
|
||||
VoidString(), // No forced file download
|
||||
postData, // Post data stream
|
||||
nullptr, // No headers stream
|
||||
|
@ -13423,7 +13284,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
|
|||
aContent->NodePrincipal(),
|
||||
flags,
|
||||
target, // Window target
|
||||
NS_LossyConvertUTF16toASCII(typeHint).get(),
|
||||
NS_LossyConvertUTF16toASCII(typeHint),
|
||||
aFileName, // Download as file
|
||||
aPostDataStream, // Post data stream
|
||||
aHeadersDataStream, // Headers stream
|
||||
|
|
|
@ -534,7 +534,7 @@ private: // member functions
|
|||
uint32_t aReferrerPolicy,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIPrincipal* aPrincipalToInherit,
|
||||
const char* aTypeHint,
|
||||
const nsACString& aTypeHint,
|
||||
const nsAString& aFileName,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
|
@ -905,6 +905,14 @@ private: // member functions
|
|||
return mCSSErrorReportingEnabled;
|
||||
}
|
||||
|
||||
// Handles retrieval of subframe session history for nsDocShell::LoadURI. If a
|
||||
// load is requested in a subframe of the current DocShell, the subframe
|
||||
// loadType may need to reflect the loadType of the parent document, or in
|
||||
// some cases (like reloads), the history load may need to be cancelled. See
|
||||
// function comments for in-depth logic descriptions.
|
||||
void
|
||||
MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState);
|
||||
|
||||
private: // data members
|
||||
static nsIURIFixup* sURIFixup;
|
||||
|
||||
|
|
|
@ -1,318 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsISHEntry.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "mozilla/net/ReferrerPolicy.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
||||
} // mozilla
|
||||
|
||||
nsDocShellLoadInfo::nsDocShellLoadInfo()
|
||||
: mResultPrincipalURIIsSome(false)
|
||||
, mKeepResultPrincipalURIIfSet(false)
|
||||
, mLoadReplace(false)
|
||||
, mInheritPrincipal(false)
|
||||
, mPrincipalIsExplicit(false)
|
||||
, mForceAllowDataURI(false)
|
||||
, mOriginalFrameSrc(false)
|
||||
, mSendReferrer(true)
|
||||
, mReferrerPolicy(mozilla::net::RP_Unset)
|
||||
, mLoadType(LOAD_NORMAL)
|
||||
, mIsSrcdocLoad(false)
|
||||
{
|
||||
}
|
||||
|
||||
nsDocShellLoadInfo::~nsDocShellLoadInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadInfo::Referrer() const
|
||||
{
|
||||
return mReferrer;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetReferrer(nsIURI* aReferrer)
|
||||
{
|
||||
mReferrer = aReferrer;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadInfo::OriginalURI() const
|
||||
{
|
||||
return mOriginalURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetOriginalURI(nsIURI* aOriginalURI)
|
||||
{
|
||||
mOriginalURI = aOriginalURI;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadInfo::ResultPrincipalURI() const
|
||||
{
|
||||
return mResultPrincipalURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetResultPrincipalURI(nsIURI* aResultPrincipalURI)
|
||||
{
|
||||
mResultPrincipalURI = aResultPrincipalURI;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::ResultPrincipalURIIsSome() const
|
||||
{
|
||||
return mResultPrincipalURIIsSome;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetResultPrincipalURIIsSome(bool aIsSome)
|
||||
{
|
||||
mResultPrincipalURIIsSome = aIsSome;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::KeepResultPrincipalURIIfSet() const
|
||||
{
|
||||
return mKeepResultPrincipalURIIfSet;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetKeepResultPrincipalURIIfSet(bool aKeep)
|
||||
{
|
||||
mKeepResultPrincipalURIIfSet = aKeep;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::LoadReplace() const
|
||||
{
|
||||
return mLoadReplace;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetLoadReplace(bool aLoadReplace)
|
||||
{
|
||||
mLoadReplace = aLoadReplace;
|
||||
}
|
||||
|
||||
nsIPrincipal*
|
||||
nsDocShellLoadInfo::TriggeringPrincipal() const
|
||||
{
|
||||
return mTriggeringPrincipal;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
mTriggeringPrincipal = aTriggeringPrincipal;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::InheritPrincipal() const
|
||||
{
|
||||
return mInheritPrincipal;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetInheritPrincipal(bool aInheritPrincipal)
|
||||
{
|
||||
mInheritPrincipal = aInheritPrincipal;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::PrincipalIsExplicit() const
|
||||
{
|
||||
return mPrincipalIsExplicit;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetPrincipalIsExplicit(bool aPrincipalIsExplicit)
|
||||
{
|
||||
mPrincipalIsExplicit = aPrincipalIsExplicit;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::ForceAllowDataURI() const
|
||||
{
|
||||
return mForceAllowDataURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetForceAllowDataURI(bool aForceAllowDataURI)
|
||||
{
|
||||
mForceAllowDataURI = aForceAllowDataURI;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::OriginalFrameSrc() const
|
||||
{
|
||||
return mOriginalFrameSrc;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetOriginalFrameSrc(bool aOriginalFrameSrc)
|
||||
{
|
||||
mOriginalFrameSrc = aOriginalFrameSrc;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDocShellLoadInfo::LoadType() const
|
||||
{
|
||||
return mLoadType;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetLoadType(uint32_t aLoadType)
|
||||
{
|
||||
mLoadType = aLoadType;
|
||||
}
|
||||
|
||||
nsISHEntry*
|
||||
nsDocShellLoadInfo::SHEntry() const
|
||||
{
|
||||
return mSHEntry;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetSHEntry(nsISHEntry* aSHEntry)
|
||||
{
|
||||
mSHEntry = aSHEntry;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::GetTarget(nsAString& aTarget) const
|
||||
{
|
||||
aTarget = mTarget;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetTarget(const nsAString& aTarget)
|
||||
{
|
||||
mTarget = aTarget;
|
||||
}
|
||||
|
||||
nsIInputStream*
|
||||
nsDocShellLoadInfo::PostDataStream() const
|
||||
{
|
||||
return mPostDataStream;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetPostDataStream(nsIInputStream* aStream)
|
||||
{
|
||||
mPostDataStream = aStream;
|
||||
}
|
||||
|
||||
nsIInputStream*
|
||||
nsDocShellLoadInfo::HeadersStream() const
|
||||
{
|
||||
return mHeadersStream;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetHeadersStream(nsIInputStream* aHeadersStream)
|
||||
{
|
||||
mHeadersStream = aHeadersStream;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::SendReferrer() const
|
||||
{
|
||||
return mSendReferrer;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetSendReferrer(bool aSendReferrer)
|
||||
{
|
||||
mSendReferrer = aSendReferrer;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDocShellLoadInfo::ReferrerPolicy() const
|
||||
{
|
||||
return mReferrerPolicy;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetReferrerPolicy(mozilla::net::ReferrerPolicy aReferrerPolicy)
|
||||
{
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadInfo::IsSrcdocLoad() const
|
||||
{
|
||||
return mIsSrcdocLoad;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::GetSrcdocData(nsAString& aSrcdocData) const
|
||||
{
|
||||
aSrcdocData = mSrcdocData;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetSrcdocData(const nsAString& aSrcdocData)
|
||||
{
|
||||
mSrcdocData = aSrcdocData;
|
||||
mIsSrcdocLoad = true;
|
||||
}
|
||||
|
||||
nsIDocShell*
|
||||
nsDocShellLoadInfo::SourceDocShell() const
|
||||
{
|
||||
return mSourceDocShell;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetSourceDocShell(nsIDocShell* aSourceDocShell)
|
||||
{
|
||||
mSourceDocShell = aSourceDocShell;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadInfo::BaseURI() const
|
||||
{
|
||||
return mBaseURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetBaseURI(nsIURI* aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::GetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>>& aRPURI) const
|
||||
{
|
||||
bool isSome = ResultPrincipalURIIsSome();
|
||||
aRPURI.reset();
|
||||
|
||||
if (!isSome) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri = ResultPrincipalURI();
|
||||
aRPURI.emplace(std::move(uri));
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadInfo::SetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI)
|
||||
{
|
||||
SetResultPrincipalURI(aRPURI.refOr(nullptr));
|
||||
SetResultPrincipalURIIsSome(aRPURI.isSome());
|
||||
}
|
|
@ -0,0 +1,554 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
#include "mozilla/OriginAttributes.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
|
||||
nsDocShellLoadState::nsDocShellLoadState()
|
||||
: mResultPrincipalURIIsSome(false)
|
||||
, mKeepResultPrincipalURIIfSet(false)
|
||||
, mLoadReplace(false)
|
||||
, mInheritPrincipal(false)
|
||||
, mPrincipalIsExplicit(false)
|
||||
, mForceAllowDataURI(false)
|
||||
, mOriginalFrameSrc(false)
|
||||
, mSendReferrer(true)
|
||||
, mReferrerPolicy(mozilla::net::RP_Unset)
|
||||
, mLoadType(LOAD_NORMAL)
|
||||
, mIsSrcdocLoad(false)
|
||||
, mLoadFlags(0)
|
||||
, mFirstParty(false)
|
||||
, mTypeHint(VoidCString())
|
||||
, mFileName(VoidString())
|
||||
, mDocShellInternalLoadFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
nsDocShellLoadState::~nsDocShellLoadState()
|
||||
{
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadState::Referrer() const
|
||||
{
|
||||
return mReferrer;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetReferrer(nsIURI* aReferrer)
|
||||
{
|
||||
mReferrer = aReferrer;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadState::URI() const
|
||||
{
|
||||
return mURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetURI(nsIURI* aURI)
|
||||
{
|
||||
mURI = aURI;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadState::OriginalURI() const
|
||||
{
|
||||
return mOriginalURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetOriginalURI(nsIURI* aOriginalURI)
|
||||
{
|
||||
mOriginalURI = aOriginalURI;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadState::ResultPrincipalURI() const
|
||||
{
|
||||
return mResultPrincipalURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetResultPrincipalURI(nsIURI* aResultPrincipalURI)
|
||||
{
|
||||
mResultPrincipalURI = aResultPrincipalURI;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::ResultPrincipalURIIsSome() const
|
||||
{
|
||||
return mResultPrincipalURIIsSome;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetResultPrincipalURIIsSome(bool aIsSome)
|
||||
{
|
||||
mResultPrincipalURIIsSome = aIsSome;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::KeepResultPrincipalURIIfSet() const
|
||||
{
|
||||
return mKeepResultPrincipalURIIfSet;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetKeepResultPrincipalURIIfSet(bool aKeep)
|
||||
{
|
||||
mKeepResultPrincipalURIIfSet = aKeep;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::LoadReplace() const
|
||||
{
|
||||
return mLoadReplace;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetLoadReplace(bool aLoadReplace)
|
||||
{
|
||||
mLoadReplace = aLoadReplace;
|
||||
}
|
||||
|
||||
nsIPrincipal*
|
||||
nsDocShellLoadState::TriggeringPrincipal() const
|
||||
{
|
||||
return mTriggeringPrincipal;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
mTriggeringPrincipal = aTriggeringPrincipal;
|
||||
}
|
||||
|
||||
nsIPrincipal*
|
||||
nsDocShellLoadState::PrincipalToInherit() const
|
||||
{
|
||||
return mPrincipalToInherit;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit)
|
||||
{
|
||||
mPrincipalToInherit = aPrincipalToInherit;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::InheritPrincipal() const
|
||||
{
|
||||
return mInheritPrincipal;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetInheritPrincipal(bool aInheritPrincipal)
|
||||
{
|
||||
mInheritPrincipal = aInheritPrincipal;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::PrincipalIsExplicit() const
|
||||
{
|
||||
return mPrincipalIsExplicit;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetPrincipalIsExplicit(bool aPrincipalIsExplicit)
|
||||
{
|
||||
mPrincipalIsExplicit = aPrincipalIsExplicit;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::ForceAllowDataURI() const
|
||||
{
|
||||
return mForceAllowDataURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetForceAllowDataURI(bool aForceAllowDataURI)
|
||||
{
|
||||
mForceAllowDataURI = aForceAllowDataURI;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::OriginalFrameSrc() const
|
||||
{
|
||||
return mOriginalFrameSrc;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetOriginalFrameSrc(bool aOriginalFrameSrc)
|
||||
{
|
||||
mOriginalFrameSrc = aOriginalFrameSrc;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDocShellLoadState::LoadType() const
|
||||
{
|
||||
return mLoadType;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetLoadType(uint32_t aLoadType)
|
||||
{
|
||||
mLoadType = aLoadType;
|
||||
}
|
||||
|
||||
nsISHEntry*
|
||||
nsDocShellLoadState::SHEntry() const
|
||||
{
|
||||
return mSHEntry;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetSHEntry(nsISHEntry* aSHEntry)
|
||||
{
|
||||
mSHEntry = aSHEntry;
|
||||
}
|
||||
|
||||
const nsString&
|
||||
nsDocShellLoadState::Target() const
|
||||
{
|
||||
return mTarget;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetTarget(const nsAString& aTarget)
|
||||
{
|
||||
mTarget = aTarget;
|
||||
}
|
||||
|
||||
nsIInputStream*
|
||||
nsDocShellLoadState::PostDataStream() const
|
||||
{
|
||||
return mPostDataStream;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetPostDataStream(nsIInputStream* aStream)
|
||||
{
|
||||
mPostDataStream = aStream;
|
||||
}
|
||||
|
||||
nsIInputStream*
|
||||
nsDocShellLoadState::HeadersStream() const
|
||||
{
|
||||
return mHeadersStream;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetHeadersStream(nsIInputStream* aHeadersStream)
|
||||
{
|
||||
mHeadersStream = aHeadersStream;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::SendReferrer() const
|
||||
{
|
||||
return mSendReferrer;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetSendReferrer(bool aSendReferrer)
|
||||
{
|
||||
mSendReferrer = aSendReferrer;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDocShellLoadState::ReferrerPolicy() const
|
||||
{
|
||||
return mReferrerPolicy;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetReferrerPolicy(mozilla::net::ReferrerPolicy aReferrerPolicy)
|
||||
{
|
||||
mReferrerPolicy = aReferrerPolicy;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::IsSrcdocLoad() const
|
||||
{
|
||||
return mIsSrcdocLoad;
|
||||
}
|
||||
|
||||
const nsString&
|
||||
nsDocShellLoadState::SrcdocData() const
|
||||
{
|
||||
return mSrcdocData;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetSrcdocData(const nsAString& aSrcdocData)
|
||||
{
|
||||
mSrcdocData = aSrcdocData;
|
||||
mIsSrcdocLoad = true;
|
||||
}
|
||||
|
||||
nsIDocShell*
|
||||
nsDocShellLoadState::SourceDocShell() const
|
||||
{
|
||||
return mSourceDocShell;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetSourceDocShell(nsIDocShell* aSourceDocShell)
|
||||
{
|
||||
mSourceDocShell = aSourceDocShell;
|
||||
}
|
||||
|
||||
nsIURI*
|
||||
nsDocShellLoadState::BaseURI() const
|
||||
{
|
||||
return mBaseURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetBaseURI(nsIURI* aBaseURI)
|
||||
{
|
||||
mBaseURI = aBaseURI;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::GetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>>& aRPURI) const
|
||||
{
|
||||
bool isSome = ResultPrincipalURIIsSome();
|
||||
aRPURI.reset();
|
||||
|
||||
if (!isSome) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri = ResultPrincipalURI();
|
||||
aRPURI.emplace(std::move(uri));
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI)
|
||||
{
|
||||
SetResultPrincipalURI(aRPURI.refOr(nullptr));
|
||||
SetResultPrincipalURIIsSome(aRPURI.isSome());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDocShellLoadState::LoadFlags() const
|
||||
{
|
||||
return mLoadFlags;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetLoadFlags(uint32_t aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocShellLoadState::FirstParty() const
|
||||
{
|
||||
return mFirstParty;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetFirstParty(bool aFirstParty)
|
||||
{
|
||||
mFirstParty = aFirstParty;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
nsDocShellLoadState::TypeHint() const
|
||||
{
|
||||
return mTypeHint;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetTypeHint(const nsCString& aTypeHint)
|
||||
{
|
||||
mTypeHint = aTypeHint;
|
||||
}
|
||||
|
||||
const nsString&
|
||||
nsDocShellLoadState::FileName() const
|
||||
{
|
||||
return mFileName;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetFileName(const nsAString& aFileName)
|
||||
{
|
||||
mFileName = aFileName;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsDocShellLoadState::DocShellInternalLoadFlags() const
|
||||
{
|
||||
return mDocShellInternalLoadFlags;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::SetDocShellInternalLoadFlags(uint32_t aFlags)
|
||||
{
|
||||
mDocShellInternalLoadFlags = aFlags;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsDocShellLoadState::SetupInheritingPrincipal(uint32_t aItemType,
|
||||
const mozilla::OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
// We need a principalToInherit.
|
||||
//
|
||||
// If principalIsExplicit is not set there are 4 possibilities:
|
||||
// (1) If the system principal or an expanded principal was passed
|
||||
// in and we're a typeContent docshell, inherit the principal
|
||||
// from the current document instead.
|
||||
// (2) In all other cases when the principal passed in is not null,
|
||||
// use that principal.
|
||||
// (3) If the caller has allowed inheriting from the current document,
|
||||
// or if we're being called from system code (eg chrome JS or pure
|
||||
// C++) then inheritPrincipal should be true and InternalLoad will get
|
||||
// a principal from the current document. If none of these things are
|
||||
// true, then
|
||||
// (4) we don't pass a principal into the channel, and a principal will be
|
||||
// created later from the channel's internal data.
|
||||
//
|
||||
// If principalIsExplicit *is* set, there are 4 possibilities
|
||||
// (1) If the system principal or an expanded principal was passed in
|
||||
// and we're a typeContent docshell, return an error.
|
||||
// (2) In all other cases when the principal passed in is not null,
|
||||
// use that principal.
|
||||
// (3) If the caller has allowed inheriting from the current document,
|
||||
// then inheritPrincipal should be true and InternalLoad will get
|
||||
// a principal from the current document. If none of these things are
|
||||
// true, then
|
||||
// (4) we dont' pass a principal into the channel, and a principal will be
|
||||
// created later from the channel's internal data.
|
||||
mPrincipalToInherit = mTriggeringPrincipal;
|
||||
if (mPrincipalToInherit && aItemType != nsIDocShellTreeItem::typeChrome) {
|
||||
if (nsContentUtils::IsSystemPrincipal(mPrincipalToInherit)) {
|
||||
if (mPrincipalIsExplicit) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
mPrincipalToInherit = nullptr;
|
||||
mInheritPrincipal = true;
|
||||
} else if (nsContentUtils::IsExpandedPrincipal(mPrincipalToInherit)) {
|
||||
if (mPrincipalIsExplicit) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
// Don't inherit from the current page. Just do the safe thing
|
||||
// and pretend that we were loaded by a nullprincipal.
|
||||
//
|
||||
// We didn't inherit OriginAttributes here as ExpandedPrincipal doesn't
|
||||
// have origin attributes.
|
||||
mPrincipalToInherit =
|
||||
NullPrincipal::CreateWithInheritedAttributes(aOriginAttributes,
|
||||
false);
|
||||
mInheritPrincipal = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mPrincipalToInherit && !mInheritPrincipal && !mPrincipalIsExplicit) {
|
||||
// See if there's system or chrome JS code running
|
||||
mInheritPrincipal = nsContentUtils::LegacyIsCallerChromeOrNativeCode();
|
||||
}
|
||||
|
||||
if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL) {
|
||||
mInheritPrincipal = false;
|
||||
// If mFirstParty is true and the pref 'privacy.firstparty.isolate' is
|
||||
// enabled, we will set firstPartyDomain on the origin attributes.
|
||||
mPrincipalToInherit =
|
||||
NullPrincipal::CreateWithInheritedAttributes(aOriginAttributes,
|
||||
mFirstParty);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocShellLoadState::SetupTriggeringPrincipal(const mozilla::OriginAttributes& aOriginAttributes)
|
||||
{
|
||||
// If the triggeringPrincipal is not set, we first try to create a principal
|
||||
// from the referrer, since the referrer URI reflects the web origin that
|
||||
// triggered the load. If there is no referrer URI, we fall back to using the
|
||||
// SystemPrincipal. It's safe to assume that no provided triggeringPrincipal
|
||||
// and no referrer simulate a load that was triggered by the system. It's
|
||||
// important to note that this block of code needs to appear *after* the block
|
||||
// where we munge the principalToInherit, because otherwise we would never
|
||||
// enter code blocks checking if the principalToInherit is null and we will
|
||||
// end up with a wrong inheritPrincipal flag.
|
||||
if (!mTriggeringPrincipal) {
|
||||
if (mReferrer) {
|
||||
mTriggeringPrincipal =
|
||||
BasePrincipal::CreateCodebasePrincipal(mReferrer, aOriginAttributes);
|
||||
|
||||
if (!mTriggeringPrincipal) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocShellLoadState::CalculateDocShellInternalLoadFlags()
|
||||
{
|
||||
MOZ_ASSERT(mDocShellInternalLoadFlags == 0,
|
||||
"Shouldn't have any load flags set at this point.");
|
||||
|
||||
if (mInheritPrincipal) {
|
||||
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(mPrincipalToInherit),
|
||||
"Should not inherit SystemPrincipal");
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL;
|
||||
}
|
||||
|
||||
if (!mSendReferrer) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER;
|
||||
}
|
||||
|
||||
if (mDocShellInternalLoadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
||||
}
|
||||
|
||||
if (mDocShellInternalLoadFlags & nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD) {
|
||||
mDocShellInternalLoadFlags |= nsIDocShell::INTERNAL_LOAD_FLAGS_FIRST_LOAD;
|
||||
}
|
||||
|
||||
if (mDocShellInternalLoadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CLASSIFIER) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER;
|
||||
}
|
||||
|
||||
if (mDocShellInternalLoadFlags & nsIWebNavigation::LOAD_FLAGS_FORCE_ALLOW_COOKIES) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES;
|
||||
}
|
||||
|
||||
if (mIsSrcdocLoad) {
|
||||
mDocShellInternalLoadFlags |= nsIDocShell::INTERNAL_LOAD_FLAGS_IS_SRCDOC;
|
||||
}
|
||||
|
||||
if (mForceAllowDataURI) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
|
||||
}
|
||||
|
||||
if (mOriginalFrameSrc) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_ORIGINAL_FRAME_SRC;
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef nsDocShellLoadInfo_h__
|
||||
#define nsDocShellLoadInfo_h__
|
||||
#ifndef nsDocShellLoadState_h__
|
||||
#define nsDocShellLoadState_h__
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -17,22 +17,29 @@ class nsIInputStream;
|
|||
class nsISHEntry;
|
||||
class nsIURI;
|
||||
class nsIDocShell;
|
||||
class OriginAttibutes;
|
||||
|
||||
/**
|
||||
* nsDocShellLoadInfo contains setup information used in a nsIDocShell::loadURI
|
||||
* nsDocShellLoadState contains setup information used in a nsIDocShell::loadURI
|
||||
* call.
|
||||
*/
|
||||
class nsDocShellLoadInfo
|
||||
class nsDocShellLoadState final
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadInfo);
|
||||
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadState);
|
||||
|
||||
nsDocShellLoadInfo();
|
||||
nsDocShellLoadState();
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
nsIURI* Referrer() const;
|
||||
|
||||
void SetReferrer(nsIURI* aReferrer);
|
||||
|
||||
nsIURI* URI() const;
|
||||
|
||||
void SetURI(nsIURI* aURI);
|
||||
|
||||
nsIURI* OriginalURI() const;
|
||||
|
||||
void SetOriginalURI(nsIURI* aOriginalURI);
|
||||
|
@ -49,6 +56,10 @@ public:
|
|||
|
||||
void SetKeepResultPrincipalURIIfSet(bool aKeep);
|
||||
|
||||
nsIPrincipal* PrincipalToInherit() const;
|
||||
|
||||
void SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit);
|
||||
|
||||
bool LoadReplace() const;
|
||||
|
||||
void SetLoadReplace(bool aLoadReplace);
|
||||
|
@ -81,7 +92,7 @@ public:
|
|||
|
||||
void SetSHEntry(nsISHEntry* aSHEntry);
|
||||
|
||||
void GetTarget(nsAString& aTarget) const;
|
||||
const nsString& Target() const;
|
||||
|
||||
void SetTarget(const nsAString& aTarget);
|
||||
|
||||
|
@ -103,7 +114,7 @@ public:
|
|||
|
||||
bool IsSrcdocLoad() const;
|
||||
|
||||
void GetSrcdocData(nsAString& aSrcdocData) const;
|
||||
const nsString& SrcdocData() const;
|
||||
|
||||
void SetSrcdocData(const nsAString& aSrcdocData);
|
||||
|
||||
|
@ -123,13 +134,54 @@ public:
|
|||
void
|
||||
SetMaybeResultPrincipalURI(mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI);
|
||||
|
||||
uint32_t LoadFlags() const;
|
||||
|
||||
void SetLoadFlags(uint32_t aFlags);
|
||||
|
||||
bool FirstParty() const;
|
||||
|
||||
void SetFirstParty(bool aFirstParty);
|
||||
|
||||
const nsCString& TypeHint() const;
|
||||
|
||||
void SetTypeHint(const nsCString& aTypeHint);
|
||||
|
||||
const nsString& FileName() const;
|
||||
|
||||
void SetFileName(const nsAString& aFileName);
|
||||
|
||||
uint32_t DocShellInternalLoadFlags() const;
|
||||
|
||||
void SetDocShellInternalLoadFlags(uint32_t aFlags);
|
||||
|
||||
// Give the type of DocShell we're loading into (chrome/content/etc) and
|
||||
// origin attributes for the URI we're loading, figure out if we should
|
||||
// inherit our principal from the document the load was requested from, or
|
||||
// else if the principal should be set up later in the process (after loads).
|
||||
// See comments in function for more info on principal selection algorithm
|
||||
nsresult SetupInheritingPrincipal(uint32_t aItemType, const mozilla::OriginAttributes& aOriginAttributes);
|
||||
|
||||
// If no triggering principal exists at the moment, create one using referrer
|
||||
// information and origin attributes.
|
||||
nsresult SetupTriggeringPrincipal(const mozilla::OriginAttributes& aOriginAttributes);
|
||||
|
||||
// When loading a document through nsDocShell::LoadURI(), a special set of
|
||||
// flags needs to be set based on other values in nsDocShellLoadState. This
|
||||
// function calculates those flags, before the LoadState is passed to
|
||||
// nsDocShell::InternalLoad.
|
||||
void CalculateDocShellInternalLoadFlags();
|
||||
protected:
|
||||
virtual ~nsDocShellLoadInfo();
|
||||
// Destructor can't be defaulted or inlined, as header doesn't have all type
|
||||
// includes it needs to do so.
|
||||
~nsDocShellLoadState();
|
||||
|
||||
protected:
|
||||
// This is the referrer for the load.
|
||||
nsCOMPtr<nsIURI> mReferrer;
|
||||
|
||||
// The URI we are navigating to. Will not be null once set.
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
|
||||
// The originalURI to be passed to nsIDocShell.internalLoad. May be null.
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
|
||||
|
@ -162,6 +214,12 @@ protected:
|
|||
// for a content docshell the load fails.
|
||||
bool mPrincipalIsExplicit;
|
||||
|
||||
// Principal we're inheriting. If null, this means the principal should be
|
||||
// inherited from the current document. If set to NullPrincipal, the channel
|
||||
// will fill in principal information later in the load. See internal function
|
||||
// comments for more info.
|
||||
nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
|
||||
|
||||
// If this attribute is true, then a top-level navigation
|
||||
// to a data URI will be allowed.
|
||||
bool mForceAllowDataURI;
|
||||
|
@ -209,6 +267,27 @@ protected:
|
|||
// Used for srcdoc loads to give view-source knowledge of the load's base URI
|
||||
// as this information isn't embedded in the load's URI.
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
|
||||
// Set of Load Flags, taken from nsDocShellLoadTypes.h
|
||||
uint32_t mLoadFlags;
|
||||
|
||||
// Is this a First Party Load?
|
||||
bool mFirstParty;
|
||||
|
||||
// A hint as to the content-type of the resulting data. If no hint, IsVoid()
|
||||
// should return true.
|
||||
nsCString mTypeHint;
|
||||
|
||||
// Non-void when the link should be downloaded as the given filename.
|
||||
// mFileName being non-void but empty means that no filename hint was
|
||||
// specified, but link should still trigger a download. If not a download,
|
||||
// mFileName.IsVoid() should return true.
|
||||
nsString mFileName;
|
||||
|
||||
// LoadFlags calculated in nsDocShell::LoadURI and passed to
|
||||
// nsDocShell::InternalLoad, taken from the INTERNAL_LOAD consts in
|
||||
// nsIDocShell.idl
|
||||
uint32_t mDocShellInternalLoadFlags;
|
||||
};
|
||||
|
||||
#endif /* nsDocShellLoadInfo_h__ */
|
||||
#endif /* nsDocShellLoadState_h__ */
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "nsIURI.h"
|
||||
class nsPresContext;
|
||||
class nsIPresShell;
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDocShellLoadState;
|
||||
namespace mozilla {
|
||||
class Encoding;
|
||||
class HTMLEditor;
|
||||
|
@ -63,7 +63,7 @@ interface nsICommandManager;
|
|||
interface nsICommandParams;
|
||||
interface nsILoadURIDelegate;
|
||||
native TabChildRef(already_AddRefed<nsITabChild>);
|
||||
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
|
||||
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
|
||||
|
||||
webidl BrowsingContext;
|
||||
webidl ContentFrameMessageManager;
|
||||
|
@ -78,23 +78,9 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* however, the URL dispatcher will go through its normal process of content
|
||||
* loading.
|
||||
*
|
||||
* @param uri - The URI to load.
|
||||
* @param loadInfo - This is the extended load info for this load. This
|
||||
* most often will be null, but if you need to do
|
||||
* additional setup for this load you can get a loadInfo
|
||||
* object by calling createLoadInfo. Once you have this
|
||||
* object you can set the needed properties on it and
|
||||
* then pass it to loadURI.
|
||||
* @param aLoadFlags - Flags to modify load behaviour. Flags are defined in
|
||||
* nsIWebNavigation. Note that using flags outside
|
||||
* LOAD_FLAGS_MASK is only allowed if passing in a
|
||||
* non-null loadInfo. And even some of those might not
|
||||
* be allowed. Use at your own risk.
|
||||
* @param loadState - This is the extended load info for this load.
|
||||
*/
|
||||
[noscript]void loadURI(in nsIURI uri,
|
||||
in nsDocShellLoadInfoPtr loadInfo,
|
||||
in unsigned long aLoadFlags,
|
||||
in boolean firstParty);
|
||||
[noscript]void loadURI(in nsDocShellLoadStatePtr loadState);
|
||||
|
||||
const long INTERNAL_LOAD_FLAGS_NONE = 0x0;
|
||||
const long INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1;
|
||||
|
@ -105,6 +91,12 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
// @see nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD
|
||||
const long INTERNAL_LOAD_FLAGS_FIRST_LOAD = 0x8;
|
||||
|
||||
|
||||
// The set of flags that should not be set before calling into
|
||||
// nsDocShell::LoadURI and other nsDocShell loading functions.
|
||||
const long INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS = 0xf;
|
||||
|
||||
|
||||
const long INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER = 0x10;
|
||||
const long INTERNAL_LOAD_FLAGS_FORCE_ALLOW_COOKIES = 0x20;
|
||||
|
||||
|
@ -198,7 +190,7 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
in nsIPrincipal aPrincipalToInherit,
|
||||
in uint32_t aFlags,
|
||||
in AString aWindowTarget,
|
||||
in string aTypeHint,
|
||||
in ACString aTypeHint,
|
||||
in AString aFileName,
|
||||
in nsIInputStream aPostDataStream,
|
||||
in nsIInputStream aHeadersStream,
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <algorithm>
|
||||
|
||||
#include "nsDocShellEditorData.h"
|
||||
#include "nsDocShellLoadTypes.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "nsDocShell.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsILayoutHistoryState.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
@ -1575,7 +1575,7 @@ nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
|
|||
{
|
||||
NS_ENSURE_STATE(aFrameDS && aFrameEntry);
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
/* Set the loadType in the SHEntry too to what was passed on.
|
||||
* This will be passed on to child subframes later in nsDocShell,
|
||||
|
@ -1583,19 +1583,21 @@ nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
|
|||
*/
|
||||
aFrameEntry->SetLoadType(aLoadType);
|
||||
|
||||
loadInfo->SetLoadType(aLoadType);
|
||||
loadInfo->SetSHEntry(aFrameEntry);
|
||||
loadState->SetLoadType(aLoadType);
|
||||
loadState->SetSHEntry(aFrameEntry);
|
||||
|
||||
nsCOMPtr<nsIURI> originalURI = aFrameEntry->GetOriginalURI();
|
||||
loadInfo->SetOriginalURI(originalURI);
|
||||
loadState->SetOriginalURI(originalURI);
|
||||
|
||||
loadInfo->SetLoadReplace(aFrameEntry->GetLoadReplace());
|
||||
loadState->SetLoadReplace(aFrameEntry->GetLoadReplace());
|
||||
|
||||
nsCOMPtr<nsIURI> newURI = aFrameEntry->GetURI();
|
||||
loadState->SetURI(newURI);
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(false);
|
||||
|
||||
nsCOMPtr<nsIURI> nextURI = aFrameEntry->GetURI();
|
||||
// Time to initiate a document load
|
||||
return aFrameDS->LoadURI(nextURI, loadInfo,
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, false);
|
||||
|
||||
return aFrameDS->LoadURI(loadState);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsCDefaultURIFixup.h"
|
||||
#include "nsIURIFixup.h"
|
||||
|
@ -61,7 +61,7 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Location, mInnerWindow)
|
|||
NS_IMPL_CYCLE_COLLECTING_ADDREF(Location)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(Location)
|
||||
|
||||
already_AddRefed<nsDocShellLoadInfo>
|
||||
already_AddRefed<nsDocShellLoadState>
|
||||
Location::CheckURL(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
|
@ -152,16 +152,16 @@ Location::CheckURL(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
|||
}
|
||||
|
||||
// Create load info
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
loadInfo->SetTriggeringPrincipal(triggeringPrincipal);
|
||||
loadState->SetTriggeringPrincipal(triggeringPrincipal);
|
||||
|
||||
if (sourceURI) {
|
||||
loadInfo->SetReferrer(sourceURI);
|
||||
loadInfo->SetReferrerPolicy(referrerPolicy);
|
||||
loadState->SetReferrer(sourceURI);
|
||||
loadState->SetReferrerPolicy(referrerPolicy);
|
||||
}
|
||||
|
||||
return loadInfo.forget();
|
||||
return loadState.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -212,27 +212,31 @@ Location::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
|||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
if (docShell) {
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo =
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState =
|
||||
CheckURL(aURI, aSubjectPrincipal, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aReplace) {
|
||||
loadInfo->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
|
||||
} else {
|
||||
loadInfo->SetLoadType(LOAD_STOP_CONTENT);
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
||||
}
|
||||
|
||||
// Get the incumbent script's browsing context to set as source.
|
||||
nsCOMPtr<nsPIDOMWindowInner> sourceWindow =
|
||||
do_QueryInterface(mozilla::dom::GetIncumbentGlobal());
|
||||
if (sourceWindow) {
|
||||
loadInfo->SetSourceDocShell(sourceWindow->GetDocShell());
|
||||
loadState->SetSourceDocShell(sourceWindow->GetDocShell());
|
||||
}
|
||||
|
||||
nsresult rv = docShell->LoadURI(aURI, loadInfo,
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, true);
|
||||
loadState->SetURI(aURI);
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
nsresult rv = docShell->LoadURI(loadState);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
class nsIDocShell;
|
||||
class nsIURI;
|
||||
class nsDocShellLoadState;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -167,6 +168,7 @@ protected:
|
|||
// Note, this method can return NS_OK with a null value for aURL. This happens
|
||||
// if the docShell is null.
|
||||
nsresult GetURI(nsIURI** aURL, bool aGetInnermostURI = false);
|
||||
|
||||
void SetURI(nsIURI* aURL, nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv, bool aReplace = false);
|
||||
void SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
|
||||
|
@ -184,7 +186,7 @@ protected:
|
|||
// Check whether it's OK to load the given url with the given subject
|
||||
// principal, and if so construct the right nsDocShellLoadInfo for the load
|
||||
// and return it.
|
||||
already_AddRefed<nsDocShellLoadInfo> CheckURL(nsIURI *url,
|
||||
already_AddRefed<nsDocShellLoadState> CheckURL(nsIURI *url,
|
||||
nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "nsIWebProgress.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIBrowser.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
@ -390,9 +390,9 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
rv = CheckURILoad(mURIToLoad, mTriggeringPrincipal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
loadInfo->SetOriginalFrameSrc(mLoadingOriginalSrc);
|
||||
loadState->SetOriginalFrameSrc(mLoadingOriginalSrc);
|
||||
mLoadingOriginalSrc = false;
|
||||
|
||||
// If this frame is sandboxed with respect to origin we will set it up with
|
||||
|
@ -403,9 +403,9 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
// is very important; needed to prevent XSS attacks on documents loaded in
|
||||
// subframes!
|
||||
if (mTriggeringPrincipal) {
|
||||
loadInfo->SetTriggeringPrincipal(mTriggeringPrincipal);
|
||||
loadState->SetTriggeringPrincipal(mTriggeringPrincipal);
|
||||
} else {
|
||||
loadInfo->SetTriggeringPrincipal(mOwnerContent->NodePrincipal());
|
||||
loadState->SetTriggeringPrincipal(mOwnerContent->NodePrincipal());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
|
@ -420,9 +420,9 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
mOwnerContent->OwnerDoc()->GetReferrer(referrerStr);
|
||||
rv = NS_NewURI(getter_AddRefs(referrer), referrerStr);
|
||||
|
||||
loadInfo->SetSrcdocData(srcdoc);
|
||||
loadState->SetSrcdocData(srcdoc);
|
||||
nsCOMPtr<nsIURI> baseURI = mOwnerContent->GetBaseURI();
|
||||
loadInfo->SetBaseURI(baseURI);
|
||||
loadState->SetBaseURI(baseURI);
|
||||
}
|
||||
else {
|
||||
rv = mOwnerContent->NodePrincipal()->GetURI(getter_AddRefs(referrer));
|
||||
|
@ -437,7 +437,7 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
bool isNullPrincipalScheme;
|
||||
rv = referrer->SchemeIs(NS_NULLPRINCIPAL_SCHEME, &isNullPrincipalScheme);
|
||||
if (NS_SUCCEEDED(rv) && !isNullPrincipalScheme) {
|
||||
loadInfo->SetReferrer(referrer);
|
||||
loadState->SetReferrer(referrer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
referrerPolicy = iframeReferrerPolicy;
|
||||
}
|
||||
}
|
||||
loadInfo->SetReferrerPolicy(referrerPolicy);
|
||||
loadState->SetReferrerPolicy(referrerPolicy);
|
||||
|
||||
// Default flags:
|
||||
int32_t flags = nsIWebNavigation::LOAD_FLAGS_NONE;
|
||||
|
@ -467,8 +467,10 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
// Kick off the load...
|
||||
bool tmpState = mNeedsAsyncDestroy;
|
||||
mNeedsAsyncDestroy = true;
|
||||
nsCOMPtr<nsIURI> uriToLoad = mURIToLoad;
|
||||
rv = mDocShell->LoadURI(uriToLoad, loadInfo, flags, false);
|
||||
loadState->SetURI(mURIToLoad);
|
||||
loadState->SetLoadFlags(flags);
|
||||
loadState->SetFirstParty(false);
|
||||
rv = mDocShell->LoadURI(loadState);
|
||||
mNeedsAsyncDestroy = tmpState;
|
||||
mURIToLoad = nullptr;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
#include "nsPrintfCString.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
#include "WindowDestroyedEvent.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
|
||||
// Helper Classes
|
||||
#include "nsJSUtils.h"
|
||||
|
@ -5520,7 +5520,7 @@ nsGlobalWindowOuter::OpenOuter(const nsAString& aUrl, const nsAString& aName,
|
|||
|
||||
nsresult
|
||||
nsGlobalWindowOuter::Open(const nsAString& aUrl, const nsAString& aName,
|
||||
const nsAString& aOptions, nsDocShellLoadInfo* aLoadInfo,
|
||||
const nsAString& aOptions, nsDocShellLoadState* aLoadState,
|
||||
bool aForceNoOpener, nsPIDOMWindowOuter **_retval)
|
||||
{
|
||||
return OpenInternal(aUrl, aName, aOptions,
|
||||
|
@ -5530,7 +5530,7 @@ nsGlobalWindowOuter::Open(const nsAString& aUrl, const nsAString& aName,
|
|||
false, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
nullptr, nullptr, // No args
|
||||
aLoadInfo,
|
||||
aLoadState,
|
||||
aForceNoOpener,
|
||||
_retval);
|
||||
}
|
||||
|
@ -5546,7 +5546,7 @@ nsGlobalWindowOuter::OpenJS(const nsAString& aUrl, const nsAString& aName,
|
|||
true, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
nullptr, nullptr, // No args
|
||||
nullptr, // aLoadInfo
|
||||
nullptr, // aLoadState
|
||||
false, // aForceNoOpener
|
||||
_retval);
|
||||
}
|
||||
|
@ -5566,7 +5566,7 @@ nsGlobalWindowOuter::OpenDialog(const nsAString& aUrl, const nsAString& aName,
|
|||
false, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
nullptr, aExtraArgument, // Arguments
|
||||
nullptr, // aLoadInfo
|
||||
nullptr, // aLoadState
|
||||
false, // aForceNoOpener
|
||||
_retval);
|
||||
}
|
||||
|
@ -5585,7 +5585,7 @@ nsGlobalWindowOuter::OpenNoNavigate(const nsAString& aUrl,
|
|||
false, // aDoJSFixups
|
||||
false, // aNavigate
|
||||
nullptr, nullptr, // No args
|
||||
nullptr, // aLoadInfo
|
||||
nullptr, // aLoadState
|
||||
false, // aForceNoOpener
|
||||
_retval);
|
||||
|
||||
|
@ -5613,7 +5613,7 @@ nsGlobalWindowOuter::OpenDialogOuter(JSContext* aCx, const nsAString& aUrl,
|
|||
false, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
argvArray, nullptr, // Arguments
|
||||
nullptr, // aLoadInfo
|
||||
nullptr, // aLoadState
|
||||
false, // aForceNoOpener
|
||||
getter_AddRefs(dialog));
|
||||
return dialog.forget();
|
||||
|
@ -6937,7 +6937,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
bool aDoJSFixups, bool aNavigate,
|
||||
nsIArray *argv,
|
||||
nsISupports *aExtraArgument,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **aReturn)
|
||||
{
|
||||
|
@ -7086,7 +7086,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
aDialog, aNavigate, argv,
|
||||
isPopupSpamWindow,
|
||||
forceNoOpener,
|
||||
aLoadInfo,
|
||||
aLoadState,
|
||||
getter_AddRefs(domReturn));
|
||||
} else {
|
||||
// Force a system caller here so that the window watcher won't screw us
|
||||
|
@ -7109,7 +7109,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
aDialog, aNavigate, aExtraArgument,
|
||||
isPopupSpamWindow,
|
||||
forceNoOpener,
|
||||
aLoadInfo,
|
||||
aLoadState,
|
||||
getter_AddRefs(domReturn));
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class nsITimeoutHandler;
|
|||
class nsIWebBrowserChrome;
|
||||
class mozIDOMWindowProxy;
|
||||
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDocShellLoadState;
|
||||
class nsDOMWindowList;
|
||||
class nsScreen;
|
||||
class nsHistory;
|
||||
|
@ -607,7 +607,7 @@ public:
|
|||
mozilla::ErrorResult& aError);
|
||||
nsresult Open(const nsAString& aUrl, const nsAString& aName,
|
||||
const nsAString& aOptions,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **_retval) override;
|
||||
mozilla::dom::Navigator* GetNavigator() override;
|
||||
|
@ -879,7 +879,7 @@ private:
|
|||
* @param aExtraArgument Another way to pass arguments in. This is mutually
|
||||
* exclusive with the argv approach.
|
||||
*
|
||||
* @param aLoadInfo to be passed on along to the windowwatcher.
|
||||
* @param aLoadState to be passed on along to the windowwatcher.
|
||||
*
|
||||
* @param aForceNoOpener if true, will act as if "noopener" were passed in
|
||||
* aOptions, but without affecting any other window
|
||||
|
@ -901,7 +901,7 @@ private:
|
|||
bool aNavigate,
|
||||
nsIArray *argv,
|
||||
nsISupports *aExtraArgument,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **aReturn);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class nsIChannel;
|
|||
class nsIContent;
|
||||
class nsICSSDeclaration;
|
||||
class nsIDocShell;
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDocShellLoadState;
|
||||
class nsIDocument;
|
||||
class nsIPrincipal;
|
||||
class nsIScriptTimeoutHandler;
|
||||
|
@ -1121,12 +1121,12 @@ public:
|
|||
|
||||
virtual nsDOMWindowList* GetFrames() = 0;
|
||||
|
||||
// aLoadInfo will be passed on through to the windowwatcher.
|
||||
// aLoadState will be passed on through to the windowwatcher.
|
||||
// aForceNoOpener will act just like a "noopener" feature in aOptions except
|
||||
// will not affect any other window features.
|
||||
virtual nsresult Open(const nsAString& aUrl, const nsAString& aName,
|
||||
const nsAString& aOptions,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **_retval) = 0;
|
||||
virtual nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "ClientState.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
@ -236,13 +236,16 @@ ClientNavigateOpChild::DoNavigate(const ClientNavigateOpConstructorArgs& aArgs)
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
|
||||
loadInfo->SetTriggeringPrincipal(principal);
|
||||
loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
|
||||
loadInfo->SetLoadType(LOAD_STOP_CONTENT);
|
||||
loadInfo->SetSourceDocShell(docShell);
|
||||
rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, true);
|
||||
loadState->SetTriggeringPrincipal(principal);
|
||||
loadState->SetReferrerPolicy(doc->GetReferrerPolicy());
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
||||
loadState->SetSourceDocShell(docShell);
|
||||
loadState->SetURI(url);
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(true);
|
||||
rv = docShell->LoadURI(loadState);
|
||||
if (NS_FAILED(rv)) {
|
||||
ref = ClientOpPromise::CreateAndReject(rv, __func__);
|
||||
return ref.forget();
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
|
||||
#include "mozInlineSpellChecker.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIConsoleListener.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsICycleCollectorListener.h"
|
||||
|
@ -774,19 +774,19 @@ ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
|
||||
aCalledFromJS, aPositionSpecified,
|
||||
aSizeSpecified, aURI, aName, aFeatures,
|
||||
aForceNoOpener, aLoadInfo, aWindowIsNew, aReturn);
|
||||
aForceNoOpener, aLoadState, aWindowIsNew, aReturn);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetCreateWindowParams(mozIDOMWindowProxy* aParent,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsACString& aBaseURIString, float* aFullZoom,
|
||||
uint32_t* aReferrerPolicy,
|
||||
nsIPrincipal** aTriggeringPrincipal)
|
||||
|
@ -814,11 +814,11 @@ GetCreateWindowParams(mozIDOMWindowProxy* aParent,
|
|||
|
||||
baseURI->GetSpec(aBaseURIString);
|
||||
|
||||
if (aLoadInfo) {
|
||||
if (!aLoadInfo->SendReferrer()) {
|
||||
if (aLoadState) {
|
||||
if (!aLoadState->SendReferrer()) {
|
||||
*aReferrerPolicy = mozilla::net::RP_No_Referrer;
|
||||
} else {
|
||||
*aReferrerPolicy = aLoadInfo->ReferrerPolicy();
|
||||
*aReferrerPolicy = aLoadState->ReferrerPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -849,7 +849,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
|
@ -896,7 +896,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
|||
float fullZoom;
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
uint32_t referrerPolicy = mozilla::net::RP_Unset;
|
||||
rv = GetCreateWindowParams(aParent, aLoadInfo, baseURIString, &fullZoom,
|
||||
rv = GetCreateWindowParams(aParent, aLoadState, baseURIString, &fullZoom,
|
||||
&referrerPolicy,
|
||||
getter_AddRefs(triggeringPrincipal));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -1110,7 +1110,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
|||
float fullZoom;
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
uint32_t referrerPolicy = mozilla::net::RP_Unset;
|
||||
rv = GetCreateWindowParams(aParent, aLoadInfo, baseURIString, &fullZoom,
|
||||
rv = GetCreateWindowParams(aParent, aLoadState, baseURIString, &fullZoom,
|
||||
&referrerPolicy,
|
||||
getter_AddRefs(triggeringPrincipal));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
|
|
@ -34,7 +34,7 @@ struct OverrideMapping;
|
|||
class nsIDomainPolicy;
|
||||
class nsIURIClassifierCallback;
|
||||
struct LookAndFeelInt;
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDocShellLoadState;
|
||||
|
||||
namespace mozilla {
|
||||
class RemoteSpellcheckEngineChild;
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
#include "nsString.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsWebBrowser.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
@ -960,7 +960,7 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
bool aPositionSpecified, bool aSizeSpecified,
|
||||
nsIURI* aURI, const nsAString& aName,
|
||||
const nsACString& aFeatures, bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo, bool* aWindowIsNew,
|
||||
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
*aReturn = nullptr;
|
||||
|
@ -1004,7 +1004,7 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
aName,
|
||||
aFeatures,
|
||||
aForceNoOpener,
|
||||
aLoadInfo,
|
||||
aLoadState,
|
||||
aWindowIsNew,
|
||||
aReturn);
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDocShellLoadState;
|
||||
%}
|
||||
|
||||
interface mozIDOMWindowProxy;
|
||||
interface nsIURI;
|
||||
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
|
||||
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
|
||||
|
||||
/**
|
||||
* The nsIWindowProvider interface exists so that the window watcher's default
|
||||
|
@ -76,7 +76,7 @@ interface nsIWindowProvider : nsISupports
|
|||
* the feature string to the window it returns in any way it sees fit.
|
||||
* See the nsIWindowWatcher interface for details on feature strings.
|
||||
*
|
||||
* @param aLoadInfo Specify setup information of the load in the new window
|
||||
* @param aLoadState Specify setup information of the load in the new window
|
||||
*
|
||||
* @param aWindowIsNew [out] Whether the window being returned was just
|
||||
* created by the window provider implementation. This can be used by
|
||||
|
@ -106,6 +106,6 @@ interface nsIWindowProvider : nsISupports
|
|||
in AString aName,
|
||||
in AUTF8String aFeatures,
|
||||
in boolean aForceNoOpener,
|
||||
in nsDocShellLoadInfoPtr aLoadInfo,
|
||||
in nsDocShellLoadStatePtr aLoadState,
|
||||
out boolean aWindowIsNew);
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDocShellLoadState;
|
||||
%}
|
||||
|
||||
interface mozIDOMWindowProxy;
|
||||
|
@ -21,7 +21,7 @@ interface nsIWebBrowserChrome;
|
|||
interface nsIDocShellTreeItem;
|
||||
interface nsIArray;
|
||||
interface nsITabParent;
|
||||
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
|
||||
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
|
||||
|
||||
[uuid(d162f9c4-19d5-4723-931f-f1e51bfa9f68)]
|
||||
|
||||
|
@ -66,8 +66,8 @@ interface nsPIWindowWatcher : nsISupports
|
|||
looking for existing windows with the given name,
|
||||
not setting an opener on the newly opened window,
|
||||
and returning null from this method.
|
||||
@param aLoadInfo if aNavigate is true, this allows the caller to pass in
|
||||
an nsIDocShellLoadInfo to use for the navigation.
|
||||
@param aLoadState if aNavigate is true, this allows the caller to pass in
|
||||
an nsIDocShellLoadState to use for the navigation.
|
||||
Callers can pass in null if they want the windowwatcher
|
||||
to just construct a loadinfo itself. If aNavigate is
|
||||
false, this argument is ignored.
|
||||
|
@ -90,7 +90,7 @@ interface nsPIWindowWatcher : nsISupports
|
|||
in nsISupports aArgs,
|
||||
in boolean aIsPopupSpam,
|
||||
in boolean aForceNoOpener,
|
||||
in nsDocShellLoadInfoPtr aLoadInfo);
|
||||
in nsDocShellLoadStatePtr aLoadState);
|
||||
|
||||
/**
|
||||
* Opens a new window so that the window that aOpeningTab belongs to
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "nsIBaseWindow.h"
|
||||
#include "nsIBrowserDOMWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
|
@ -325,7 +325,7 @@ nsWindowWatcher::OpenWindow(mozIDOMWindowProxy* aParent,
|
|||
/* navigate = */ true, argv,
|
||||
/* aIsPopupSpam = */ false,
|
||||
/* aForceNoOpener = */ false,
|
||||
/* aLoadInfo = */ nullptr,
|
||||
/* aLoadState = */ nullptr,
|
||||
aResult);
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ nsWindowWatcher::OpenWindow2(mozIDOMWindowProxy* aParent,
|
|||
nsISupports* aArguments,
|
||||
bool aIsPopupSpam,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
mozIDOMWindowProxy** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIArray> argv = ConvertArgsToArray(aArguments);
|
||||
|
@ -412,7 +412,7 @@ nsWindowWatcher::OpenWindow2(mozIDOMWindowProxy* aParent,
|
|||
return OpenWindowInternal(aParent, aUrl, aName, aFeatures,
|
||||
aCalledFromScript, dialog,
|
||||
aNavigate, argv, aIsPopupSpam,
|
||||
aForceNoOpener, aLoadInfo, aResult);
|
||||
aForceNoOpener, aLoadState, aResult);
|
||||
}
|
||||
|
||||
// This static function checks if the aDocShell uses an UserContextId equal to
|
||||
|
@ -637,7 +637,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
nsIArray* aArgv,
|
||||
bool aIsPopupSpam,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
mozIDOMWindowProxy** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -821,7 +821,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
sizeSpec.PositionSpecified(),
|
||||
sizeSpec.SizeSpecified(),
|
||||
uriToLoad, name, features, aForceNoOpener,
|
||||
aLoadInfo, &windowIsNew,
|
||||
aLoadState, &windowIsNew,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -1118,12 +1118,12 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = aLoadInfo;
|
||||
if (uriToLoad && aNavigate && !loadInfo) {
|
||||
loadInfo = new nsDocShellLoadInfo();
|
||||
RefPtr<nsDocShellLoadState> loadState = aLoadState;
|
||||
if (uriToLoad && aNavigate && !loadState) {
|
||||
loadState = new nsDocShellLoadState();
|
||||
|
||||
if (subjectPrincipal) {
|
||||
loadInfo->SetTriggeringPrincipal(subjectPrincipal);
|
||||
loadState->SetTriggeringPrincipal(subjectPrincipal);
|
||||
}
|
||||
|
||||
/* use the URL from the *extant* document, if any. The usual accessor
|
||||
|
@ -1138,8 +1138,8 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
}
|
||||
if (doc) {
|
||||
// Set the referrer
|
||||
loadInfo->SetReferrer(doc->GetDocumentURI());
|
||||
loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
|
||||
loadState->SetReferrer(doc->GetDocumentURI());
|
||||
loadState->SetReferrerPolicy(doc->GetReferrerPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1181,13 +1181,13 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
}
|
||||
|
||||
if (uriToLoad && aNavigate) {
|
||||
newDocShell->LoadURI(
|
||||
uriToLoad,
|
||||
loadInfo,
|
||||
windowIsNew ?
|
||||
loadState->SetURI(uriToLoad);
|
||||
loadState->SetLoadFlags(windowIsNew ?
|
||||
static_cast<uint32_t>(nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD) :
|
||||
static_cast<uint32_t>(nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
true);
|
||||
static_cast<uint32_t>(nsIWebNavigation::LOAD_FLAGS_NONE));
|
||||
loadState->SetFirstParty(true);
|
||||
// Should this pay attention to errors returned by LoadURI?
|
||||
newDocShell->LoadURI(loadState);
|
||||
}
|
||||
|
||||
// Copy the current session storage for the current domain. Don't perform the
|
||||
|
|
|
@ -88,7 +88,7 @@ protected:
|
|||
nsIArray* aArgv,
|
||||
bool aIsPopupSpam,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
mozIDOMWindowProxy** aResult);
|
||||
|
||||
static nsresult URIfromURL(const char* aURL,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "nsWindowWatcher.h"
|
||||
#include "mozilla/BrowserElementParent.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
|
@ -766,7 +766,7 @@ nsContentTreeOwner::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче