Bug 1626404: Part 4 - Remove now-redundant accessor args from BrowsingContext load methods. r=nika CLOSED TREE
Differential Revision: https://phabricator.services.mozilla.com/D69421
This commit is contained in:
@@ -1383,14 +1383,13 @@ nsresult BrowsingContext::CheckSandboxFlags(nsDocShellLoadState* aLoadState) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
|
||||
bool aSetNavigating) {
|
||||
// Per spec, most load attempts are silently ignored when a BrowsingContext is
|
||||
// null (which in our code corresponds to discarded), so we simply fail
|
||||
// silently in those cases. Regardless, we cannot trigger loads in/from
|
||||
// discarded BrowsingContexts via IPC, so we need to abort in any case.
|
||||
if (IsDiscarded() || (aAccessor && aAccessor->IsDiscarded())) {
|
||||
if (IsDiscarded()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -1405,41 +1404,41 @@ nsresult BrowsingContext::LoadURI(BrowsingContext* aAccessor,
|
||||
// BrowsingContext's sandbox flags.
|
||||
MOZ_TRY(CheckSandboxFlags(aLoadState));
|
||||
|
||||
if (!aAccessor && XRE_IsParentProcess()) {
|
||||
if (ContentParent* cp = Canonical()->GetContentParent()) {
|
||||
Unused << cp->SendLoadURI(this, aLoadState, aSetNavigating);
|
||||
}
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aAccessor);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aAccessor->Group() == Group());
|
||||
if (!aAccessor) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!aAccessor->CanAccess(this)) {
|
||||
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||
MOZ_DIAGNOSTIC_ASSERT(!sourceBC || sourceBC->Group() == Group());
|
||||
if (sourceBC && sourceBC->IsInProcess()) {
|
||||
if (!sourceBC->CanAccess(this)) {
|
||||
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win(aAccessor->GetDOMWindow());
|
||||
MOZ_DIAGNOSTIC_ASSERT(win);
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win(sourceBC->GetDOMWindow());
|
||||
if (WindowGlobalChild* wgc =
|
||||
win->GetCurrentInnerWindow()->GetWindowGlobalChild()) {
|
||||
wgc->SendLoadURI(this, aLoadState, aSetNavigating);
|
||||
}
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess());
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (ContentParent* cp = Canonical()->GetContentParent()) {
|
||||
Unused << cp->SendLoadURI(this, aLoadState, aSetNavigating);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult BrowsingContext::InternalLoad(BrowsingContext* aAccessor,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsresult BrowsingContext::InternalLoad(nsDocShellLoadState* aLoadState,
|
||||
nsIDocShell** aDocShell,
|
||||
nsIRequest** aRequest) {
|
||||
if (IsDiscarded() || (aAccessor && aAccessor->IsDiscarded())) {
|
||||
if (IsDiscarded()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const auto& sourceBC = aLoadState->SourceBrowsingContext();
|
||||
bool isActive =
|
||||
aAccessor && aAccessor->GetIsActive() && !GetIsActive() &&
|
||||
sourceBC && sourceBC->GetIsActive() && !GetIsActive() &&
|
||||
!Preferences::GetBool("browser.tabs.loadDivertedInBackground", false);
|
||||
if (mDocShell) {
|
||||
nsresult rv = nsDocShell::Cast(mDocShell)->InternalLoad(
|
||||
@@ -1472,15 +1471,14 @@ nsresult BrowsingContext::InternalLoad(BrowsingContext* aAccessor,
|
||||
Unused << cp->SendInternalLoad(this, aLoadState, isActive);
|
||||
}
|
||||
} else {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aAccessor);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aAccessor->Group() == Group());
|
||||
MOZ_DIAGNOSTIC_ASSERT(sourceBC);
|
||||
MOZ_DIAGNOSTIC_ASSERT(sourceBC->Group() == Group());
|
||||
|
||||
if (!aAccessor->CanAccess(this)) {
|
||||
if (!sourceBC->CanAccess(this)) {
|
||||
return NS_ERROR_DOM_PROP_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win(aAccessor->GetDOMWindow());
|
||||
MOZ_DIAGNOSTIC_ASSERT(win);
|
||||
nsCOMPtr<nsPIDOMWindowOuter> win(sourceBC->GetDOMWindow());
|
||||
if (WindowGlobalChild* wgc =
|
||||
win->GetCurrentInnerWindow()->GetWindowGlobalChild()) {
|
||||
wgc->SendInternalLoad(this, aLoadState);
|
||||
|
||||
@@ -257,13 +257,9 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
||||
void RestoreChildren(Children&& aChildren, bool aFromIPC = false);
|
||||
|
||||
// Triggers a load in the process which currently owns this BrowsingContext.
|
||||
// aAccessor is the context which initiated the load, and may be null only for
|
||||
// in-process BrowsingContexts.
|
||||
nsresult LoadURI(BrowsingContext* aAccessor, nsDocShellLoadState* aLoadState,
|
||||
bool aSetNavigating = false);
|
||||
nsresult LoadURI(nsDocShellLoadState* aLoadState, bool aSetNavigating = false);
|
||||
|
||||
nsresult InternalLoad(BrowsingContext* aAccessor,
|
||||
nsDocShellLoadState* aLoadState,
|
||||
nsresult InternalLoad(nsDocShellLoadState* aLoadState,
|
||||
nsIDocShell** aDocShell, nsIRequest** aRequest);
|
||||
|
||||
// If the load state includes a source BrowsingContext has been passed, check
|
||||
|
||||
@@ -270,9 +270,7 @@ void CanonicalBrowsingContext::LoadURI(const nsAString& aURI,
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: It's safe to call `LoadURI` without an accessor from the parent
|
||||
// process. The load will be performed with ambient "chrome" authority.
|
||||
LoadURI(nullptr, loadState, true);
|
||||
LoadURI(loadState, true);
|
||||
}
|
||||
|
||||
void CanonicalBrowsingContext::PendingRemotenessChange::Complete(
|
||||
|
||||
@@ -8354,8 +8354,7 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState,
|
||||
aLoadState->SetTarget(EmptyString());
|
||||
// No forced download
|
||||
aLoadState->SetFileName(VoidString());
|
||||
return targetContext->InternalLoad(mBrowsingContext, aLoadState, aDocShell,
|
||||
aRequest);
|
||||
return targetContext->InternalLoad(aLoadState, aDocShell, aRequest);
|
||||
}
|
||||
|
||||
bool nsDocShell::IsSameDocumentNavigation(nsDocShellLoadState* aLoadState,
|
||||
|
||||
@@ -1028,7 +1028,7 @@ nsSHistory::EvictAllContentViewers() {
|
||||
|
||||
static void LoadURIs(nsTArray<nsSHistory::LoadEntryResult>& aLoadResults) {
|
||||
for (nsSHistory::LoadEntryResult& loadEntry : aLoadResults) {
|
||||
loadEntry.mBrowsingContext->LoadURI(nullptr, loadEntry.mLoadState, false);
|
||||
loadEntry.mBrowsingContext->LoadURI(loadEntry.mLoadState, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,16 +129,14 @@ void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
|
||||
// Get the incumbent script's browsing context to set as source.
|
||||
nsCOMPtr<nsPIDOMWindowInner> sourceWindow =
|
||||
nsContentUtils::CallerInnerWindow();
|
||||
RefPtr<BrowsingContext> accessingBC;
|
||||
if (sourceWindow) {
|
||||
accessingBC = sourceWindow->GetBrowsingContext();
|
||||
loadState->SetSourceBrowsingContext(sourceWindow->GetBrowsingContext());
|
||||
}
|
||||
|
||||
loadState->SetLoadFlags(nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
nsresult rv = bc->LoadURI(accessingBC, loadState);
|
||||
nsresult rv = bc->LoadURI(loadState);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
aRv.Throw(rv);
|
||||
}
|
||||
|
||||
@@ -4084,7 +4084,7 @@ mozilla::ipc::IPCResult ContentChild::RecvLoadURI(
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
context->LoadURI(nullptr, aLoadState, aSetNavigating);
|
||||
context->LoadURI(aLoadState, aSetNavigating);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindowOuter> window = context->GetDOMWindow();
|
||||
BrowserChild* bc = BrowserChild::GetFrom(window);
|
||||
@@ -4121,7 +4121,7 @@ mozilla::ipc::IPCResult ContentChild::RecvInternalLoad(
|
||||
}
|
||||
BrowsingContext* context = aContext.get();
|
||||
|
||||
context->InternalLoad(nullptr, aLoadState, nullptr, nullptr);
|
||||
context->InternalLoad(aLoadState, nullptr, nullptr);
|
||||
|
||||
if (aTakeFocus) {
|
||||
if (nsCOMPtr<nsPIDOMWindowOuter> domWin = context->GetDOMWindow()) {
|
||||
|
||||
@@ -213,7 +213,7 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvLoadURI(
|
||||
// FIXME: We should really initiate the load in the parent before bouncing
|
||||
// back down to the child.
|
||||
|
||||
targetBC->LoadURI(nullptr, aLoadState, aSetNavigating);
|
||||
targetBC->LoadURI(aLoadState, aSetNavigating);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ mozilla::ipc::IPCResult WindowGlobalParent::RecvInternalLoad(
|
||||
// FIXME: We should really initiate the load in the parent before bouncing
|
||||
// back down to the child.
|
||||
|
||||
targetBC->InternalLoad(BrowsingContext(), aLoadState, nullptr, nullptr);
|
||||
targetBC->InternalLoad(aLoadState, nullptr, nullptr);
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
||||
@@ -1234,7 +1234,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
|
||||
loadState->SetFirstParty(true);
|
||||
|
||||
// Should this pay attention to errors returned by LoadURI?
|
||||
newBC->LoadURI(parentBC, loadState);
|
||||
newBC->LoadURI(loadState);
|
||||
}
|
||||
|
||||
// Copy the current session storage for the current domain. Don't perform the
|
||||
|
||||
Reference in New Issue
Block a user