зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset fa8487b94a38 due to a=BUSTAGE on comm-central
This commit is contained in:
Родитель
fc26d6a38a
Коммит
ee8ccacb05
|
@ -38,24 +38,19 @@ NS_IMPL_CI_INTERFACE_GETTER(NullPrincipal,
|
|||
/* static */ already_AddRefed<NullPrincipal>
|
||||
NullPrincipal::CreateWithInheritedAttributes(nsIPrincipal* aInheritFrom)
|
||||
{
|
||||
MOZ_ASSERT(aInheritFrom);
|
||||
return CreateWithInheritedAttributes(Cast(aInheritFrom)->OriginAttributesRef(), false);
|
||||
RefPtr<NullPrincipal> nullPrin = new NullPrincipal();
|
||||
nsresult rv = nullPrin->Init(Cast(aInheritFrom)->OriginAttributesRef());
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
return nullPrin.forget();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<NullPrincipal>
|
||||
NullPrincipal::CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty)
|
||||
{
|
||||
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(aOriginAttributes, aIsFirstParty);
|
||||
nsresult rv = nullPrin->Init(attrs, aIsFirstParty);
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
|
||||
return nullPrin.forget();
|
||||
}
|
||||
|
|
|
@ -56,19 +56,14 @@ 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);
|
||||
static already_AddRefed<NullPrincipal>
|
||||
CreateWithInheritedAttributes(const OriginAttributes& aOriginAttributes,
|
||||
bool aIsFirstParty = false);
|
||||
CreateWithInheritedAttributes(nsIDocShell* aDocShell, bool aIsFirstParty = false);
|
||||
|
||||
static already_AddRefed<NullPrincipal>
|
||||
Create(const OriginAttributes& aOriginAttributes,
|
||||
|
@ -90,8 +85,7 @@ 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',
|
||||
'nsDocShellLoadState.h',
|
||||
'nsDocShellLoadInfo.h',
|
||||
'nsDocShellLoadTypes.h',
|
||||
'nsDocShellTreeOwner.h',
|
||||
'nsILinkHandler.h',
|
||||
|
@ -88,7 +88,7 @@ UNIFIED_SOURCES += [
|
|||
'nsDocShell.cpp',
|
||||
'nsDocShellEditorData.cpp',
|
||||
'nsDocShellEnumerator.cpp',
|
||||
'nsDocShellLoadState.cpp',
|
||||
'nsDocShellLoadInfo.cpp',
|
||||
'nsDocShellTreeOwner.cpp',
|
||||
'nsDSURIContentListener.cpp',
|
||||
'nsPingListener.cpp',
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
#include "nsDocShellCID.h"
|
||||
#include "nsDocShellEditorData.h"
|
||||
#include "nsDocShellEnumerator.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsDocShellLoadTypes.h"
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
|
@ -643,12 +643,14 @@ nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURI(nsDocShellLoadState* aLoadState)
|
||||
nsDocShell::LoadURI(nsIURI* aURI,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
uint32_t aLoadFlags,
|
||||
bool aFirstParty)
|
||||
{
|
||||
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");
|
||||
MOZ_ASSERT(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
|
||||
"Unexpected flags");
|
||||
MOZ_ASSERT((aLoadFlags & 0xf) == 0, "Should not have these flags set");
|
||||
|
||||
// Note: we allow loads to get through here even if mFiredUnloadEvent is
|
||||
// true; that case will get handled in LoadInternal or LoadHistoryEntry,
|
||||
|
@ -660,121 +662,86 @@ nsDocShell::LoadURI(nsDocShellLoadState* aLoadState)
|
|||
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(aLoadState->URI())) {
|
||||
mItemType == typeContent && !NS_IsAboutBlank(aURI)) {
|
||||
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, aLoadState->URI()->GetSpecOrDefault().get(),
|
||||
aLoadState->LoadFlags()));
|
||||
this, aURI->GetSpecOrDefault().get(), aLoadFlags));
|
||||
|
||||
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.
|
||||
if (!shEntry &&
|
||||
!LOAD_TYPE_HAS_FLAGS(loadType, LOAD_FLAGS_REPLACE_HISTORY)) {
|
||||
// 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)) {
|
||||
// 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.
|
||||
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.
|
||||
*/
|
||||
|
||||
// Get the parent's load type
|
||||
uint32_t parentLoadType;
|
||||
parentDS->GetLoadType(&parentLoadType);
|
||||
|
||||
// Get the ShEntry for the child from the parent
|
||||
|
@ -782,17 +749,13 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
|
|||
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
|
||||
|
@ -805,13 +768,58 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
|
|||
// currentSHEntry is null.
|
||||
nsCOMPtr<nsISHEntry> currentChildEntry;
|
||||
GetCurrentSHEntry(getter_AddRefs(currentChildEntry), &oshe);
|
||||
|
||||
if (mCurrentURI && (!NS_IsAboutBlank(mCurrentURI) || currentChildEntry)) {
|
||||
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 {
|
||||
// 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), which we checked with the above assert, and
|
||||
// loaded), 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
|
||||
|
@ -823,57 +831,187 @@ nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState)
|
|||
GetBusyFlags(&selfBusy);
|
||||
if (parentBusy & BUSY_FLAGS_BUSY ||
|
||||
selfBusy & BUSY_FLAGS_BUSY) {
|
||||
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
aLoadState->SetSHEntry(nullptr);
|
||||
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.
|
||||
bool inOnLoadHandler = false;
|
||||
GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
if (inOnLoadHandler) {
|
||||
loadType = LOAD_NORMAL_REPLACE;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} // !shEntry
|
||||
|
||||
if (shEntry) {
|
||||
#ifdef DEBUG
|
||||
MOZ_LOG(gDocShellLog, LogLevel::Debug,
|
||||
("nsDocShell[%p]: loading from session history", this));
|
||||
#endif
|
||||
|
||||
return LoadHistoryEntry(shEntry, loadType);
|
||||
}
|
||||
|
||||
// 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;
|
||||
parentDS->GetIsExecutingOnLoadHandler(&inOnLoadHandler);
|
||||
if (inOnLoadHandler) {
|
||||
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
aLoadState->SetSHEntry(nullptr);
|
||||
}
|
||||
} 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
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4088,7 +4226,7 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI,
|
|||
nsIURI* aBaseURI,
|
||||
nsIPrincipal* aTriggeringPrincipal)
|
||||
{
|
||||
NS_ASSERTION((aLoadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0, "Unexpected flags");
|
||||
NS_ASSERTION((aLoadFlags & 0xf) == 0, "Unexpected flags");
|
||||
|
||||
if (!IsNavigationAllowed()) {
|
||||
return NS_OK; // JS may not handle returning of an error code
|
||||
|
@ -4183,28 +4321,27 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI,
|
|||
uint32_t extraFlags = (aLoadFlags & EXTRA_LOAD_FLAGS);
|
||||
aLoadFlags &= ~EXTRA_LOAD_FLAGS;
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
/*
|
||||
* 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) {
|
||||
loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags));
|
||||
loadType = MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags);
|
||||
} else {
|
||||
loadState->SetLoadType(MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags));
|
||||
loadType = MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
if (fixupInfo) {
|
||||
nsAutoString searchProvider, keyword;
|
||||
|
@ -4213,7 +4350,7 @@ nsDocShell::LoadURIWithOptions(const nsAString& aURI,
|
|||
MaybeNotifyKeywordSearchLoading(searchProvider, keyword);
|
||||
}
|
||||
|
||||
rv = LoadURI(loadState);
|
||||
rv = LoadURI(uri, loadInfo, extraFlags, true);
|
||||
|
||||
// Save URI string in case it's needed later when
|
||||
// sending to search engine service in EndPageLoad()
|
||||
|
@ -4785,7 +4922,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(),
|
||||
VoidCString(), VoidString(), nullptr, nullptr,
|
||||
nullptr, VoidString(), nullptr, nullptr,
|
||||
LOAD_ERROR_PAGE, nullptr, true, VoidString(), this,
|
||||
nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
@ -4797,7 +4934,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
return NS_OK; // JS may not handle returning of an error code
|
||||
}
|
||||
nsresult rv;
|
||||
NS_ASSERTION(((aReloadFlags & INTERNAL_LOAD_FLAGS_LOADURI_SETUP_FLAGS) == 0),
|
||||
NS_ASSERTION(((aReloadFlags & 0xf) == 0),
|
||||
"Reload command not updated to use load flags!");
|
||||
NS_ASSERTION((aReloadFlags & EXTRA_LOAD_FLAGS) == 0,
|
||||
"Don't pass these flags to Reload");
|
||||
|
@ -4885,7 +5022,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
triggeringPrincipal,
|
||||
flags,
|
||||
EmptyString(), // No window target
|
||||
NS_LossyConvertUTF16toASCII(contentTypeHint),
|
||||
NS_LossyConvertUTF16toASCII(contentTypeHint).get(),
|
||||
VoidString(), // No forced download
|
||||
nullptr, // No post data
|
||||
nullptr, // No headers data
|
||||
|
@ -6137,22 +6274,22 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
{
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
/* We do need to pass in a referrer, but we don't want it to
|
||||
* be sent to the server.
|
||||
*/
|
||||
loadState->SetSendReferrer(false);
|
||||
loadInfo->SetSendReferrer(false);
|
||||
|
||||
/* for most refreshes the current URI is an appropriate
|
||||
* internal referrer
|
||||
*/
|
||||
loadState->SetReferrer(mCurrentURI);
|
||||
loadInfo->SetReferrer(mCurrentURI);
|
||||
|
||||
loadState->SetOriginalURI(mCurrentURI);
|
||||
loadState->SetResultPrincipalURI(aURI);
|
||||
loadState->SetResultPrincipalURIIsSome(true);
|
||||
loadState->SetKeepResultPrincipalURIIfSet(true);
|
||||
loadInfo->SetOriginalURI(mCurrentURI);
|
||||
loadInfo->SetResultPrincipalURI(aURI);
|
||||
loadInfo->SetResultPrincipalURIIsSome(true);
|
||||
loadInfo->SetKeepResultPrincipalURIIfSet(true);
|
||||
|
||||
// Set the triggering pricipal to aPrincipal if available, or current
|
||||
// document's principal otherwise.
|
||||
|
@ -6164,8 +6301,8 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
}
|
||||
principal = doc->NodePrincipal();
|
||||
}
|
||||
loadState->SetTriggeringPrincipal(principal);
|
||||
loadState->SetPrincipalIsExplicit(true);
|
||||
loadInfo->SetTriggeringPrincipal(principal);
|
||||
loadInfo->SetPrincipalIsExplicit(true);
|
||||
|
||||
/* Check if this META refresh causes a redirection
|
||||
* to another site.
|
||||
|
@ -6178,7 +6315,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().
|
||||
*/
|
||||
loadState->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
loadInfo->SetLoadType(LOAD_NORMAL_REPLACE);
|
||||
|
||||
/* for redirects we mimic HTTP, which passes the
|
||||
* original referrer
|
||||
|
@ -6186,21 +6323,17 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
|
|||
nsCOMPtr<nsIURI> internalReferrer;
|
||||
GetReferringURI(getter_AddRefs(internalReferrer));
|
||||
if (internalReferrer) {
|
||||
loadState->SetReferrer(internalReferrer);
|
||||
loadInfo->SetReferrer(internalReferrer);
|
||||
}
|
||||
} else {
|
||||
loadState->SetLoadType(LOAD_REFRESH);
|
||||
loadInfo->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(loadState);
|
||||
LoadURI(aURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL, true);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -8967,7 +9100,7 @@ public:
|
|||
nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIPrincipal* aPrincipalToInherit,
|
||||
uint32_t aFlags,
|
||||
const nsACString& aTypeHint,
|
||||
const char* aTypeHint,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
uint32_t aLoadType,
|
||||
|
@ -8977,7 +9110,6 @@ public:
|
|||
nsIDocShell* aSourceDocShell,
|
||||
nsIURI* aBaseURI)
|
||||
: mozilla::Runnable("InternalLoadEvent")
|
||||
, mTypeHint(aTypeHint)
|
||||
, mSrcdoc(aSrcdoc)
|
||||
, mDocShell(aDocShell)
|
||||
, mURI(aURI)
|
||||
|
@ -8998,6 +9130,12 @@ public:
|
|||
, mSourceDocShell(aSourceDocShell)
|
||||
, mBaseURI(aBaseURI)
|
||||
{
|
||||
// Make sure to keep null things null as needed
|
||||
if (aTypeHint) {
|
||||
mTypeHint = aTypeHint;
|
||||
} else {
|
||||
mTypeHint.SetIsVoid(true);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
|
@ -9010,7 +9148,8 @@ public:
|
|||
mReferrerPolicy,
|
||||
mTriggeringPrincipal, mPrincipalToInherit,
|
||||
mFlags, EmptyString(),
|
||||
mTypeHint,
|
||||
mTypeHint.IsVoid() ? nullptr
|
||||
: mTypeHint.get(),
|
||||
VoidString(), mPostData,
|
||||
mHeadersData, mLoadType, mSHEntry,
|
||||
mFirstParty, mSrcdoc, mSourceDocShell,
|
||||
|
@ -9081,7 +9220,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
nsIPrincipal* aPrincipalToInherit,
|
||||
uint32_t aFlags,
|
||||
const nsAString& aWindowTarget,
|
||||
const nsACString& aTypeHint,
|
||||
const char* aTypeHint,
|
||||
const nsAString& aFileName,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
|
@ -9362,31 +9501,31 @@ nsDocShell::InternalLoad(nsIURI* aURI,
|
|||
MOZ_ASSERT(!aSHEntry);
|
||||
MOZ_ASSERT(aFirstParty); // Windowwatcher will assume this.
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
// Set up our loadinfo so it will do the load as much like we would have
|
||||
// as possible.
|
||||
loadState->SetReferrer(aReferrer);
|
||||
loadState->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadState->SetSendReferrer(!(aFlags &
|
||||
loadInfo->SetReferrer(aReferrer);
|
||||
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
|
||||
loadInfo->SetSendReferrer(!(aFlags &
|
||||
INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER));
|
||||
loadState->SetOriginalURI(aOriginalURI);
|
||||
loadState->SetMaybeResultPrincipalURI(aResultPrincipalURI);
|
||||
loadState->SetKeepResultPrincipalURIIfSet(aKeepResultPrincipalURIIfSet);
|
||||
loadState->SetLoadReplace(aLoadReplace);
|
||||
loadState->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadState->SetInheritPrincipal(
|
||||
loadInfo->SetOriginalURI(aOriginalURI);
|
||||
loadInfo->SetMaybeResultPrincipalURI(aResultPrincipalURI);
|
||||
loadInfo->SetKeepResultPrincipalURIIfSet(aKeepResultPrincipalURIIfSet);
|
||||
loadInfo->SetLoadReplace(aLoadReplace);
|
||||
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
|
||||
loadInfo->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.
|
||||
loadState->SetPrincipalIsExplicit(true);
|
||||
loadState->SetLoadType(LOAD_LINK);
|
||||
loadState->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
|
||||
loadInfo->SetPrincipalIsExplicit(true);
|
||||
loadInfo->SetLoadType(LOAD_LINK);
|
||||
loadInfo->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
|
||||
|
||||
rv = win->Open(NS_ConvertUTF8toUTF16(spec),
|
||||
aWindowTarget, // window name
|
||||
EmptyString(), // Features
|
||||
loadState,
|
||||
loadInfo,
|
||||
true, // aForceNoOpener
|
||||
getter_AddRefs(newWin));
|
||||
MOZ_ASSERT(!newWin);
|
||||
|
@ -10197,7 +10336,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
uint32_t aReferrerPolicy,
|
||||
nsIPrincipal* aTriggeringPrincipal,
|
||||
nsIPrincipal* aPrincipalToInherit,
|
||||
const nsACString& aTypeHint,
|
||||
const char* aTypeHint,
|
||||
const nsAString& aFileName,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
|
@ -10546,8 +10685,8 @@ nsDocShell::DoURILoad(nsIURI* aURI,
|
|||
loadInfo->SetResultPrincipalURI(aResultPrincipalURI.ref());
|
||||
}
|
||||
|
||||
if (!aTypeHint.IsVoid()) {
|
||||
channel->SetContentType(aTypeHint);
|
||||
if (aTypeHint && *aTypeHint) {
|
||||
channel->SetContentType(nsDependentCString(aTypeHint));
|
||||
mContentTypeHint = aTypeHint;
|
||||
} else {
|
||||
mContentTypeHint.Truncate();
|
||||
|
@ -12101,7 +12240,7 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
|
|||
principalToInherit,
|
||||
flags,
|
||||
EmptyString(), // No window target
|
||||
contentType, // Type hint
|
||||
contentType.get(), // Type hint
|
||||
VoidString(), // No forced file download
|
||||
postData, // Post data stream
|
||||
nullptr, // No headers stream
|
||||
|
@ -13289,7 +13428,7 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
|
|||
aContent->NodePrincipal(),
|
||||
flags,
|
||||
target, // Window target
|
||||
NS_LossyConvertUTF16toASCII(typeHint),
|
||||
NS_LossyConvertUTF16toASCII(typeHint).get(),
|
||||
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 nsACString& aTypeHint,
|
||||
const char* aTypeHint,
|
||||
const nsAString& aFileName,
|
||||
nsIInputStream* aPostData,
|
||||
nsIInputStream* aHeadersData,
|
||||
|
@ -905,14 +905,6 @@ 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;
|
||||
|
||||
|
|
|
@ -0,0 +1,318 @@
|
|||
/* -*- 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());
|
||||
}
|
|
@ -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 nsDocShellLoadState_h__
|
||||
#define nsDocShellLoadState_h__
|
||||
#ifndef nsDocShellLoadInfo_h__
|
||||
#define nsDocShellLoadInfo_h__
|
||||
|
||||
// Helper Classes
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -17,29 +17,22 @@ class nsIInputStream;
|
|||
class nsISHEntry;
|
||||
class nsIURI;
|
||||
class nsIDocShell;
|
||||
class OriginAttibutes;
|
||||
|
||||
/**
|
||||
* nsDocShellLoadState contains setup information used in a nsIDocShell::loadURI
|
||||
* nsDocShellLoadInfo contains setup information used in a nsIDocShell::loadURI
|
||||
* call.
|
||||
*/
|
||||
class nsDocShellLoadState final
|
||||
class nsDocShellLoadInfo
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadState);
|
||||
NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadInfo);
|
||||
|
||||
nsDocShellLoadState();
|
||||
|
||||
// Getters and Setters
|
||||
nsDocShellLoadInfo();
|
||||
|
||||
nsIURI* Referrer() const;
|
||||
|
||||
void SetReferrer(nsIURI* aReferrer);
|
||||
|
||||
nsIURI* URI() const;
|
||||
|
||||
void SetURI(nsIURI* aURI);
|
||||
|
||||
nsIURI* OriginalURI() const;
|
||||
|
||||
void SetOriginalURI(nsIURI* aOriginalURI);
|
||||
|
@ -56,10 +49,6 @@ public:
|
|||
|
||||
void SetKeepResultPrincipalURIIfSet(bool aKeep);
|
||||
|
||||
nsIPrincipal* PrincipalToInherit() const;
|
||||
|
||||
void SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit);
|
||||
|
||||
bool LoadReplace() const;
|
||||
|
||||
void SetLoadReplace(bool aLoadReplace);
|
||||
|
@ -92,7 +81,7 @@ public:
|
|||
|
||||
void SetSHEntry(nsISHEntry* aSHEntry);
|
||||
|
||||
const nsString& Target() const;
|
||||
void GetTarget(nsAString& aTarget) const;
|
||||
|
||||
void SetTarget(const nsAString& aTarget);
|
||||
|
||||
|
@ -114,7 +103,7 @@ public:
|
|||
|
||||
bool IsSrcdocLoad() const;
|
||||
|
||||
const nsString& SrcdocData() const;
|
||||
void GetSrcdocData(nsAString& aSrcdocData) const;
|
||||
|
||||
void SetSrcdocData(const nsAString& aSrcdocData);
|
||||
|
||||
|
@ -134,54 +123,13 @@ 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:
|
||||
// Destructor can't be defaulted or inlined, as header doesn't have all type
|
||||
// includes it needs to do so.
|
||||
~nsDocShellLoadState();
|
||||
virtual ~nsDocShellLoadInfo();
|
||||
|
||||
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;
|
||||
|
||||
|
@ -214,12 +162,6 @@ 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;
|
||||
|
@ -267,27 +209,6 @@ 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 /* nsDocShellLoadState_h__ */
|
||||
#endif /* nsDocShellLoadInfo_h__ */
|
|
@ -1,554 +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 "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 (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
||||
}
|
||||
|
||||
if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD) {
|
||||
mDocShellInternalLoadFlags |= nsIDocShell::INTERNAL_LOAD_FLAGS_FIRST_LOAD;
|
||||
}
|
||||
|
||||
if (mLoadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CLASSIFIER) {
|
||||
mDocShellInternalLoadFlags |=
|
||||
nsIDocShell::INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER;
|
||||
}
|
||||
|
||||
if (mLoadFlags & 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;
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "nsIURI.h"
|
||||
class nsPresContext;
|
||||
class nsIPresShell;
|
||||
class nsDocShellLoadState;
|
||||
class nsDocShellLoadInfo;
|
||||
namespace mozilla {
|
||||
class Encoding;
|
||||
class HTMLEditor;
|
||||
|
@ -63,7 +63,7 @@ interface nsICommandManager;
|
|||
interface nsICommandParams;
|
||||
interface nsILoadURIDelegate;
|
||||
native TabChildRef(already_AddRefed<nsITabChild>);
|
||||
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
|
||||
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
|
||||
|
||||
webidl BrowsingContext;
|
||||
webidl ContentFrameMessageManager;
|
||||
|
@ -78,9 +78,23 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
* however, the URL dispatcher will go through its normal process of content
|
||||
* loading.
|
||||
*
|
||||
* @param loadState - This is the extended load info for this load.
|
||||
* @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.
|
||||
*/
|
||||
[noscript]void loadURI(in nsDocShellLoadStatePtr loadState);
|
||||
[noscript]void loadURI(in nsIURI uri,
|
||||
in nsDocShellLoadInfoPtr loadInfo,
|
||||
in unsigned long aLoadFlags,
|
||||
in boolean firstParty);
|
||||
|
||||
const long INTERNAL_LOAD_FLAGS_NONE = 0x0;
|
||||
const long INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL = 0x1;
|
||||
|
@ -91,12 +105,6 @@ 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;
|
||||
|
||||
|
@ -190,7 +198,7 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
in nsIPrincipal aPrincipalToInherit,
|
||||
in uint32_t aFlags,
|
||||
in AString aWindowTarget,
|
||||
in ACString aTypeHint,
|
||||
in string 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 "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.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<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
/* Set the loadType in the SHEntry too to what was passed on.
|
||||
* This will be passed on to child subframes later in nsDocShell,
|
||||
|
@ -1583,21 +1583,19 @@ nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
|
|||
*/
|
||||
aFrameEntry->SetLoadType(aLoadType);
|
||||
|
||||
loadState->SetLoadType(aLoadType);
|
||||
loadState->SetSHEntry(aFrameEntry);
|
||||
loadInfo->SetLoadType(aLoadType);
|
||||
loadInfo->SetSHEntry(aFrameEntry);
|
||||
|
||||
nsCOMPtr<nsIURI> originalURI = aFrameEntry->GetOriginalURI();
|
||||
loadState->SetOriginalURI(originalURI);
|
||||
loadInfo->SetOriginalURI(originalURI);
|
||||
|
||||
loadState->SetLoadReplace(aFrameEntry->GetLoadReplace());
|
||||
|
||||
nsCOMPtr<nsIURI> newURI = aFrameEntry->GetURI();
|
||||
loadState->SetURI(newURI);
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(false);
|
||||
loadInfo->SetLoadReplace(aFrameEntry->GetLoadReplace());
|
||||
|
||||
nsCOMPtr<nsIURI> nextURI = aFrameEntry->GetURI();
|
||||
// Time to initiate a document load
|
||||
return aFrameDS->LoadURI(loadState);
|
||||
return aFrameDS->LoadURI(nextURI, loadInfo,
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, false);
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(void)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.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<nsDocShellLoadState>
|
||||
already_AddRefed<nsDocShellLoadInfo>
|
||||
Location::CheckURL(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
|
@ -152,16 +152,16 @@ Location::CheckURL(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
|||
}
|
||||
|
||||
// Create load info
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
loadState->SetTriggeringPrincipal(triggeringPrincipal);
|
||||
loadInfo->SetTriggeringPrincipal(triggeringPrincipal);
|
||||
|
||||
if (sourceURI) {
|
||||
loadState->SetReferrer(sourceURI);
|
||||
loadState->SetReferrerPolicy(referrerPolicy);
|
||||
loadInfo->SetReferrer(sourceURI);
|
||||
loadInfo->SetReferrerPolicy(referrerPolicy);
|
||||
}
|
||||
|
||||
return loadState.forget();
|
||||
return loadInfo.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -212,31 +212,27 @@ Location::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
|||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
if (docShell) {
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState =
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo =
|
||||
CheckURL(aURI, aSubjectPrincipal, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aReplace) {
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
|
||||
loadInfo->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
|
||||
} else {
|
||||
loadState->SetLoadType(LOAD_STOP_CONTENT);
|
||||
loadInfo->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) {
|
||||
loadState->SetSourceDocShell(sourceWindow->GetDocShell());
|
||||
loadInfo->SetSourceDocShell(sourceWindow->GetDocShell());
|
||||
}
|
||||
|
||||
loadState->SetURI(aURI);
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
nsresult rv = docShell->LoadURI(loadState);
|
||||
nsresult rv = docShell->LoadURI(aURI, loadInfo,
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, true);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
class nsIDocShell;
|
||||
class nsIURI;
|
||||
class nsDocShellLoadState;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -168,7 +167,6 @@ 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,
|
||||
|
@ -186,7 +184,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<nsDocShellLoadState> CheckURL(nsIURI *url,
|
||||
already_AddRefed<nsDocShellLoadInfo> CheckURL(nsIURI *url,
|
||||
nsIPrincipal& aSubjectPrincipal,
|
||||
ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "nsIWebProgress.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.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<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
loadState->SetOriginalFrameSrc(mLoadingOriginalSrc);
|
||||
loadInfo->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) {
|
||||
loadState->SetTriggeringPrincipal(mTriggeringPrincipal);
|
||||
loadInfo->SetTriggeringPrincipal(mTriggeringPrincipal);
|
||||
} else {
|
||||
loadState->SetTriggeringPrincipal(mOwnerContent->NodePrincipal());
|
||||
loadInfo->SetTriggeringPrincipal(mOwnerContent->NodePrincipal());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
|
@ -420,9 +420,9 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
mOwnerContent->OwnerDoc()->GetReferrer(referrerStr);
|
||||
rv = NS_NewURI(getter_AddRefs(referrer), referrerStr);
|
||||
|
||||
loadState->SetSrcdocData(srcdoc);
|
||||
loadInfo->SetSrcdocData(srcdoc);
|
||||
nsCOMPtr<nsIURI> baseURI = mOwnerContent->GetBaseURI();
|
||||
loadState->SetBaseURI(baseURI);
|
||||
loadInfo->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) {
|
||||
loadState->SetReferrer(referrer);
|
||||
loadInfo->SetReferrer(referrer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
referrerPolicy = iframeReferrerPolicy;
|
||||
}
|
||||
}
|
||||
loadState->SetReferrerPolicy(referrerPolicy);
|
||||
loadInfo->SetReferrerPolicy(referrerPolicy);
|
||||
|
||||
// Default flags:
|
||||
int32_t flags = nsIWebNavigation::LOAD_FLAGS_NONE;
|
||||
|
@ -467,10 +467,8 @@ nsFrameLoader::ReallyStartLoadingInternal()
|
|||
// Kick off the load...
|
||||
bool tmpState = mNeedsAsyncDestroy;
|
||||
mNeedsAsyncDestroy = true;
|
||||
loadState->SetURI(mURIToLoad);
|
||||
loadState->SetLoadFlags(flags);
|
||||
loadState->SetFirstParty(false);
|
||||
rv = mDocShell->LoadURI(loadState);
|
||||
nsCOMPtr<nsIURI> uriToLoad = mURIToLoad;
|
||||
rv = mDocShell->LoadURI(uriToLoad, loadInfo, flags, false);
|
||||
mNeedsAsyncDestroy = tmpState;
|
||||
mURIToLoad = nullptr;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
#include "nsPrintfCString.h"
|
||||
#include "mozilla/intl/LocaleService.h"
|
||||
#include "WindowDestroyedEvent.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
|
||||
// Helper Classes
|
||||
#include "nsJSUtils.h"
|
||||
|
@ -5526,7 +5526,7 @@ nsGlobalWindowOuter::OpenOuter(const nsAString& aUrl, const nsAString& aName,
|
|||
|
||||
nsresult
|
||||
nsGlobalWindowOuter::Open(const nsAString& aUrl, const nsAString& aName,
|
||||
const nsAString& aOptions, nsDocShellLoadState* aLoadState,
|
||||
const nsAString& aOptions, nsDocShellLoadInfo* aLoadInfo,
|
||||
bool aForceNoOpener, nsPIDOMWindowOuter **_retval)
|
||||
{
|
||||
return OpenInternal(aUrl, aName, aOptions,
|
||||
|
@ -5536,7 +5536,7 @@ nsGlobalWindowOuter::Open(const nsAString& aUrl, const nsAString& aName,
|
|||
false, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
nullptr, nullptr, // No args
|
||||
aLoadState,
|
||||
aLoadInfo,
|
||||
aForceNoOpener,
|
||||
_retval);
|
||||
}
|
||||
|
@ -5552,7 +5552,7 @@ nsGlobalWindowOuter::OpenJS(const nsAString& aUrl, const nsAString& aName,
|
|||
true, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
nullptr, nullptr, // No args
|
||||
nullptr, // aLoadState
|
||||
nullptr, // aLoadInfo
|
||||
false, // aForceNoOpener
|
||||
_retval);
|
||||
}
|
||||
|
@ -5572,7 +5572,7 @@ nsGlobalWindowOuter::OpenDialog(const nsAString& aUrl, const nsAString& aName,
|
|||
false, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
nullptr, aExtraArgument, // Arguments
|
||||
nullptr, // aLoadState
|
||||
nullptr, // aLoadInfo
|
||||
false, // aForceNoOpener
|
||||
_retval);
|
||||
}
|
||||
|
@ -5591,7 +5591,7 @@ nsGlobalWindowOuter::OpenNoNavigate(const nsAString& aUrl,
|
|||
false, // aDoJSFixups
|
||||
false, // aNavigate
|
||||
nullptr, nullptr, // No args
|
||||
nullptr, // aLoadState
|
||||
nullptr, // aLoadInfo
|
||||
false, // aForceNoOpener
|
||||
_retval);
|
||||
|
||||
|
@ -5619,7 +5619,7 @@ nsGlobalWindowOuter::OpenDialogOuter(JSContext* aCx, const nsAString& aUrl,
|
|||
false, // aDoJSFixups
|
||||
true, // aNavigate
|
||||
argvArray, nullptr, // Arguments
|
||||
nullptr, // aLoadState
|
||||
nullptr, // aLoadInfo
|
||||
false, // aForceNoOpener
|
||||
getter_AddRefs(dialog));
|
||||
return dialog.forget();
|
||||
|
@ -6973,7 +6973,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
bool aDoJSFixups, bool aNavigate,
|
||||
nsIArray *argv,
|
||||
nsISupports *aExtraArgument,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **aReturn)
|
||||
{
|
||||
|
@ -7122,7 +7122,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
aDialog, aNavigate, argv,
|
||||
isPopupSpamWindow,
|
||||
forceNoOpener,
|
||||
aLoadState,
|
||||
aLoadInfo,
|
||||
getter_AddRefs(domReturn));
|
||||
} else {
|
||||
// Force a system caller here so that the window watcher won't screw us
|
||||
|
@ -7145,7 +7145,7 @@ nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
aDialog, aNavigate, aExtraArgument,
|
||||
isPopupSpamWindow,
|
||||
forceNoOpener,
|
||||
aLoadState,
|
||||
aLoadInfo,
|
||||
getter_AddRefs(domReturn));
|
||||
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class nsITimeoutHandler;
|
|||
class nsIWebBrowserChrome;
|
||||
class mozIDOMWindowProxy;
|
||||
|
||||
class nsDocShellLoadState;
|
||||
class nsDocShellLoadInfo;
|
||||
class nsDOMWindowList;
|
||||
class nsScreen;
|
||||
class nsHistory;
|
||||
|
@ -606,7 +606,7 @@ public:
|
|||
mozilla::ErrorResult& aError);
|
||||
nsresult Open(const nsAString& aUrl, const nsAString& aName,
|
||||
const nsAString& aOptions,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **_retval) override;
|
||||
mozilla::dom::Navigator* GetNavigator() override;
|
||||
|
@ -878,7 +878,7 @@ private:
|
|||
* @param aExtraArgument Another way to pass arguments in. This is mutually
|
||||
* exclusive with the argv approach.
|
||||
*
|
||||
* @param aLoadState to be passed on along to the windowwatcher.
|
||||
* @param aLoadInfo 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
|
||||
|
@ -900,7 +900,7 @@ private:
|
|||
bool aNavigate,
|
||||
nsIArray *argv,
|
||||
nsISupports *aExtraArgument,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool aForceNoOpener,
|
||||
nsPIDOMWindowOuter **aReturn);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class nsIChannel;
|
|||
class nsIContent;
|
||||
class nsICSSDeclaration;
|
||||
class nsIDocShell;
|
||||
class nsDocShellLoadState;
|
||||
class nsDocShellLoadInfo;
|
||||
class nsIDocument;
|
||||
class nsIPrincipal;
|
||||
class nsIScriptTimeoutHandler;
|
||||
|
@ -1120,12 +1120,12 @@ public:
|
|||
|
||||
virtual nsDOMWindowList* GetFrames() = 0;
|
||||
|
||||
// aLoadState will be passed on through to the windowwatcher.
|
||||
// aLoadInfo 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,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
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 "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
|
@ -236,16 +236,13 @@ ClientNavigateOpChild::DoNavigate(const ClientNavigateOpConstructorArgs& aArgs)
|
|||
return ref.forget();
|
||||
}
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
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);
|
||||
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);
|
||||
if (NS_FAILED(rv)) {
|
||||
ref = ClientOpPromise::CreateAndReject(rv, __func__);
|
||||
return ref.forget();
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
|
||||
#include "mozInlineSpellChecker.h"
|
||||
#include "nsDocShell.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsIConsoleListener.h"
|
||||
#include "nsIContentViewer.h"
|
||||
#include "nsICycleCollectorListener.h"
|
||||
|
@ -775,19 +775,19 @@ ContentChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
|
||||
aCalledFromJS, aPositionSpecified,
|
||||
aSizeSpecified, aURI, aName, aFeatures,
|
||||
aForceNoOpener, aLoadState, aWindowIsNew, aReturn);
|
||||
aForceNoOpener, aLoadInfo, aWindowIsNew, aReturn);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
GetCreateWindowParams(mozIDOMWindowProxy* aParent,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
nsACString& aBaseURIString, float* aFullZoom,
|
||||
uint32_t* aReferrerPolicy,
|
||||
nsIPrincipal** aTriggeringPrincipal)
|
||||
|
@ -815,11 +815,11 @@ GetCreateWindowParams(mozIDOMWindowProxy* aParent,
|
|||
|
||||
baseURI->GetSpec(aBaseURIString);
|
||||
|
||||
if (aLoadState) {
|
||||
if (!aLoadState->SendReferrer()) {
|
||||
if (aLoadInfo) {
|
||||
if (!aLoadInfo->SendReferrer()) {
|
||||
*aReferrerPolicy = mozilla::net::RP_No_Referrer;
|
||||
} else {
|
||||
*aReferrerPolicy = aLoadState->ReferrerPolicy();
|
||||
*aReferrerPolicy = aLoadInfo->ReferrerPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -850,7 +850,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
|
@ -897,7 +897,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
|||
float fullZoom;
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
uint32_t referrerPolicy = mozilla::net::RP_Unset;
|
||||
rv = GetCreateWindowParams(aParent, aLoadState, baseURIString, &fullZoom,
|
||||
rv = GetCreateWindowParams(aParent, aLoadInfo, baseURIString, &fullZoom,
|
||||
&referrerPolicy,
|
||||
getter_AddRefs(triggeringPrincipal));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -1111,7 +1111,7 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener,
|
|||
float fullZoom;
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
uint32_t referrerPolicy = mozilla::net::RP_Unset;
|
||||
rv = GetCreateWindowParams(aParent, aLoadState, baseURIString, &fullZoom,
|
||||
rv = GetCreateWindowParams(aParent, aLoadInfo, 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 nsDocShellLoadState;
|
||||
class nsDocShellLoadInfo;
|
||||
|
||||
namespace mozilla {
|
||||
class RemoteSpellcheckEngineChild;
|
||||
|
@ -119,7 +119,7 @@ public:
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn);
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@
|
|||
#include "nsString.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
#include "nsWebBrowser.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
@ -958,7 +958,7 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
bool aPositionSpecified, bool aSizeSpecified,
|
||||
nsIURI* aURI, const nsAString& aName,
|
||||
const nsACString& aFeatures, bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState, bool* aWindowIsNew,
|
||||
nsDocShellLoadInfo* aLoadInfo, bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
*aReturn = nullptr;
|
||||
|
@ -1002,7 +1002,7 @@ TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
aName,
|
||||
aFeatures,
|
||||
aForceNoOpener,
|
||||
aLoadState,
|
||||
aLoadInfo,
|
||||
aWindowIsNew,
|
||||
aReturn);
|
||||
}
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
class nsDocShellLoadState;
|
||||
class nsDocShellLoadInfo;
|
||||
%}
|
||||
|
||||
interface mozIDOMWindowProxy;
|
||||
interface nsIURI;
|
||||
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
|
||||
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
|
||||
|
||||
/**
|
||||
* 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 aLoadState Specify setup information of the load in the new window
|
||||
* @param aLoadInfo 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 nsDocShellLoadStatePtr aLoadState,
|
||||
in nsDocShellLoadInfoPtr aLoadInfo,
|
||||
out boolean aWindowIsNew);
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
%{ C++
|
||||
class nsDocShellLoadState;
|
||||
class nsDocShellLoadInfo;
|
||||
%}
|
||||
|
||||
interface mozIDOMWindowProxy;
|
||||
|
@ -21,7 +21,7 @@ interface nsIWebBrowserChrome;
|
|||
interface nsIDocShellTreeItem;
|
||||
interface nsIArray;
|
||||
interface nsITabParent;
|
||||
native nsDocShellLoadStatePtr(nsDocShellLoadState*);
|
||||
native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
|
||||
|
||||
[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 aLoadState if aNavigate is true, this allows the caller to pass in
|
||||
an nsIDocShellLoadState to use for the navigation.
|
||||
@param aLoadInfo if aNavigate is true, this allows the caller to pass in
|
||||
an nsIDocShellLoadInfo 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 nsDocShellLoadStatePtr aLoadState);
|
||||
in nsDocShellLoadInfoPtr aLoadInfo);
|
||||
|
||||
/**
|
||||
* 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 "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.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,
|
||||
/* aLoadState = */ nullptr,
|
||||
/* aLoadInfo = */ nullptr,
|
||||
aResult);
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ nsWindowWatcher::OpenWindow2(mozIDOMWindowProxy* aParent,
|
|||
nsISupports* aArguments,
|
||||
bool aIsPopupSpam,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
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, aLoadState, aResult);
|
||||
aForceNoOpener, aLoadInfo, 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,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
mozIDOMWindowProxy** aResult)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -821,7 +821,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
sizeSpec.PositionSpecified(),
|
||||
sizeSpec.SizeSpecified(),
|
||||
uriToLoad, name, features, aForceNoOpener,
|
||||
aLoadState, &windowIsNew,
|
||||
aLoadInfo, &windowIsNew,
|
||||
getter_AddRefs(newWindow));
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -1118,12 +1118,12 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
}
|
||||
}
|
||||
|
||||
RefPtr<nsDocShellLoadState> loadState = aLoadState;
|
||||
if (uriToLoad && aNavigate && !loadState) {
|
||||
loadState = new nsDocShellLoadState();
|
||||
RefPtr<nsDocShellLoadInfo> loadInfo = aLoadInfo;
|
||||
if (uriToLoad && aNavigate && !loadInfo) {
|
||||
loadInfo = new nsDocShellLoadInfo();
|
||||
|
||||
if (subjectPrincipal) {
|
||||
loadState->SetTriggeringPrincipal(subjectPrincipal);
|
||||
loadInfo->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
|
||||
loadState->SetReferrer(doc->GetDocumentURI());
|
||||
loadState->SetReferrerPolicy(doc->GetReferrerPolicy());
|
||||
loadInfo->SetReferrer(doc->GetDocumentURI());
|
||||
loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1181,13 +1181,13 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
|
|||
}
|
||||
|
||||
if (uriToLoad && aNavigate) {
|
||||
loadState->SetURI(uriToLoad);
|
||||
loadState->SetLoadFlags(windowIsNew ?
|
||||
newDocShell->LoadURI(
|
||||
uriToLoad,
|
||||
loadInfo,
|
||||
windowIsNew ?
|
||||
static_cast<uint32_t>(nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD) :
|
||||
static_cast<uint32_t>(nsIWebNavigation::LOAD_FLAGS_NONE));
|
||||
loadState->SetFirstParty(true);
|
||||
// Should this pay attention to errors returned by LoadURI?
|
||||
newDocShell->LoadURI(loadState);
|
||||
static_cast<uint32_t>(nsIWebNavigation::LOAD_FLAGS_NONE),
|
||||
true);
|
||||
}
|
||||
|
||||
// Copy the current session storage for the current domain. Don't perform the
|
||||
|
|
|
@ -88,7 +88,7 @@ protected:
|
|||
nsIArray* aArgv,
|
||||
bool aIsPopupSpam,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
mozIDOMWindowProxy** aResult);
|
||||
|
||||
static nsresult URIfromURL(const char* aURL,
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "nsWindowWatcher.h"
|
||||
#include "mozilla/BrowserElementParent.h"
|
||||
#include "mozilla/NullPrincipal.h"
|
||||
#include "nsDocShellLoadState.h"
|
||||
#include "nsDocShellLoadInfo.h"
|
||||
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsIURI.h"
|
||||
|
@ -766,7 +766,7 @@ nsContentTreeOwner::ProvideWindow(mozIDOMWindowProxy* aParent,
|
|||
const nsAString& aName,
|
||||
const nsACString& aFeatures,
|
||||
bool aForceNoOpener,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsDocShellLoadInfo* aLoadInfo,
|
||||
bool* aWindowIsNew,
|
||||
mozIDOMWindowProxy** aReturn)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче