Bug 1942630, part 2 - Navigation API: Implement user navigation involvement in nsDocShellLoadState and nsILoadInfo. r=farre,necko-reviewers,kershaw
This patch introduces `UserNavigationInvolvement` as an IPDL type, and adds the user navigation involvement flag to `nsDocShellLoadState` and `nsILoadInfo`. Differential Revision: https://phabricator.services.mozilla.com/D234851
This commit is contained in:
@@ -695,6 +695,16 @@ void nsDocShellLoadState::SetLoadType(uint32_t aLoadType) {
|
||||
mLoadType = aLoadType;
|
||||
}
|
||||
|
||||
mozilla::dom::UserNavigationInvolvement
|
||||
nsDocShellLoadState::UserNavigationInvolvement() const {
|
||||
return mUserNavigationInvolvement;
|
||||
}
|
||||
|
||||
void nsDocShellLoadState::SetUserNavigationInvolvement(
|
||||
mozilla::dom::UserNavigationInvolvement aUserNavigationInvolvement) {
|
||||
mUserNavigationInvolvement = aUserNavigationInvolvement;
|
||||
}
|
||||
|
||||
nsISHEntry* nsDocShellLoadState::SHEntry() const { return mSHEntry; }
|
||||
|
||||
void nsDocShellLoadState::SetSHEntry(nsISHEntry* aSHEntry) {
|
||||
@@ -1326,6 +1336,7 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize(
|
||||
loadState.ShouldCheckForRecursion() = mShouldCheckForRecursion;
|
||||
loadState.IsFormSubmission() = mIsFormSubmission;
|
||||
loadState.LoadType() = mLoadType;
|
||||
loadState.userNavigationInvolvement() = mUserNavigationInvolvement;
|
||||
loadState.Target() = mTarget;
|
||||
loadState.TargetBrowsingContext() = mTargetBrowsingContext;
|
||||
loadState.LoadFlags() = mLoadFlags;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "mozilla/dom/BrowsingContext.h"
|
||||
#include "mozilla/dom/SessionHistoryEntry.h"
|
||||
#include "mozilla/dom/UserNavigationInvolvement.h"
|
||||
|
||||
#include "nsILoadInfo.h"
|
||||
|
||||
@@ -172,6 +173,11 @@ class nsDocShellLoadState final {
|
||||
|
||||
void SetLoadType(uint32_t aLoadType);
|
||||
|
||||
mozilla::dom::UserNavigationInvolvement UserNavigationInvolvement() const;
|
||||
|
||||
void SetUserNavigationInvolvement(
|
||||
mozilla::dom::UserNavigationInvolvement aUserNavigationInvolvement);
|
||||
|
||||
nsISHEntry* SHEntry() const;
|
||||
|
||||
void SetSHEntry(nsISHEntry* aSHEntry);
|
||||
@@ -532,6 +538,10 @@ class nsDocShellLoadState final {
|
||||
// constants
|
||||
uint32_t mLoadType;
|
||||
|
||||
// https://html.spec.whatwg.org/#user-navigation-involvement
|
||||
mozilla::dom::UserNavigationInvolvement mUserNavigationInvolvement =
|
||||
mozilla::dom::UserNavigationInvolvement::None;
|
||||
|
||||
// Active Session History entry (if loading from SH)
|
||||
nsCOMPtr<nsISHEntry> mSHEntry;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ include "mozilla/dom/DomSecurityIPCUtils.h";
|
||||
include "mozilla/GfxMessageUtils.h";
|
||||
include "mozilla/dom/CSPMessageUtils.h";
|
||||
include "mozilla/dom/DocShellMessageUtils.h";
|
||||
include "mozilla/dom/NavigationAPIIPCUtils.h";
|
||||
include "mozilla/dom/PermissionMessageUtils.h";
|
||||
include "mozilla/dom/PropertyBagUtils.h";
|
||||
include "mozilla/dom/ReferrerInfoUtils.h";
|
||||
@@ -58,6 +59,7 @@ using mozilla::TimeStamp from "mozilla/TimeStamp.h";
|
||||
[RefCounted] using class mozilla::RemoteLazyInputStream from "mozilla/RemoteLazyInputStream.h";
|
||||
[MoveOnly] using class mozilla::ipc::BigBuffer from "mozilla/ipc/BigBuffer.h";
|
||||
using mozilla::dom::NotificationDirection from "mozilla/dom/NotificationBinding.h";
|
||||
using mozilla::dom::UserNavigationInvolvement from "mozilla/dom/UserNavigationInvolvement.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@@ -194,7 +196,10 @@ struct DocShellLoadStateInit
|
||||
uint32_t LoadFlags;
|
||||
uint32_t InternalLoadFlags;
|
||||
|
||||
// The TriggineringSandboxFlags are the SandboxFlags of the entity
|
||||
// https://html.spec.whatwg.org/#user-navigation-involvement
|
||||
UserNavigationInvolvement userNavigationInvolvement;
|
||||
|
||||
// The TriggeringSandboxFlags are the SandboxFlags of the entity
|
||||
// responsible for causing the load to occur.
|
||||
uint32_t TriggeringSandboxFlags;
|
||||
uint64_t TriggeringWindowId;
|
||||
|
||||
20
dom/ipc/NavigationAPIIPCUtils.h
Normal file
20
dom/ipc/NavigationAPIIPCUtils.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef mozilla_dom_navigation_api_ipc_utils_h__
|
||||
#define mozilla_dom_navigation_api_ipc_utils_h__
|
||||
#include "ipc/EnumSerializer.h"
|
||||
#include "mozilla/dom/UserNavigationInvolvement.h"
|
||||
|
||||
namespace IPC {
|
||||
template <>
|
||||
struct ParamTraits<mozilla::dom::UserNavigationInvolvement>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::dom::UserNavigationInvolvement,
|
||||
mozilla::dom::UserNavigationInvolvement::None,
|
||||
mozilla::dom::UserNavigationInvolvement::BrowserUI> {};
|
||||
} // namespace IPC
|
||||
#endif
|
||||
@@ -71,6 +71,7 @@ EXPORTS.mozilla.dom += [
|
||||
"MaybeDiscarded.h",
|
||||
"MemoryReportRequest.h",
|
||||
"NativeThreadId.h",
|
||||
"NavigationAPIIPCUtils.h",
|
||||
"PageLoadEventUtils.h",
|
||||
"PermissionMessageUtils.h",
|
||||
"ProcessActor.h",
|
||||
|
||||
@@ -602,7 +602,8 @@ nsresult LoadInfoToLoadInfoArgs(nsILoadInfo* aLoadInfo,
|
||||
aLoadInfo->GetStoragePermission(), overriddenFingerprintingSettingsArg,
|
||||
aLoadInfo->GetIsMetaRefresh(), aLoadInfo->GetLoadingEmbedderPolicy(),
|
||||
aLoadInfo->GetIsOriginTrialCoepCredentiallessEnabledForTopLevel(),
|
||||
unstrippedURI, interceptionInfoArg, aLoadInfo->GetIsNewWindowTarget());
|
||||
unstrippedURI, interceptionInfoArg, aLoadInfo->GetIsNewWindowTarget(),
|
||||
aLoadInfo->GetUserNavigationInvolvement());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -897,7 +898,8 @@ nsresult LoadInfoArgsToLoadInfo(const LoadInfoArgs& loadInfoArgs,
|
||||
loadInfoArgs.unstrippedURI(), interceptionInfo,
|
||||
loadInfoArgs.hasInjectedCookieForCookieBannerHandling(),
|
||||
loadInfoArgs.schemelessInput(), loadInfoArgs.httpsUpgradeTelemetry(),
|
||||
loadInfoArgs.isNewWindowTarget());
|
||||
loadInfoArgs.isNewWindowTarget(),
|
||||
loadInfoArgs.userNavigationInvolvement());
|
||||
|
||||
if (loadInfoArgs.isFromProcessingFrameAttributes()) {
|
||||
loadInfo->SetIsFromProcessingFrameAttributes();
|
||||
@@ -980,7 +982,8 @@ void LoadInfoToParentLoadInfoForwarder(
|
||||
aLoadInfo->GetRequestBlockingReason(), aLoadInfo->GetStoragePermission(),
|
||||
overriddenFingerprintingSettingsArg, aLoadInfo->GetIsMetaRefresh(),
|
||||
isThirdPartyContextToTopWindow, aLoadInfo->GetIsInThirdPartyContext(),
|
||||
aLoadInfo->GetIsOn3PCBExceptionList(), unstrippedURI);
|
||||
aLoadInfo->GetIsOn3PCBExceptionList(), unstrippedURI,
|
||||
aLoadInfo->GetUserNavigationInvolvement());
|
||||
}
|
||||
|
||||
nsresult MergeParentLoadInfoForwarder(
|
||||
@@ -1108,6 +1111,9 @@ nsresult MergeParentLoadInfoForwarder(
|
||||
*aForwarderArgs.containerFeaturePolicyInfo());
|
||||
}
|
||||
|
||||
aLoadInfo->SetUserNavigationInvolvement(
|
||||
uint8_t(aForwarderArgs.userNavigationInvolvement()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -749,7 +749,8 @@ LoadInfo::LoadInfo(
|
||||
bool aHasInjectedCookieForCookieBannerHandling,
|
||||
nsILoadInfo::SchemelessInputType aSchemelessInput,
|
||||
nsILoadInfo::HTTPSUpgradeTelemetryType aHttpsUpgradeTelemetry,
|
||||
bool aIsNewWindowTarget)
|
||||
bool aIsNewWindowTarget,
|
||||
dom::UserNavigationInvolvement aUserNavigationInvolvement)
|
||||
: mLoadingPrincipal(aLoadingPrincipal),
|
||||
mTriggeringPrincipal(aTriggeringPrincipal),
|
||||
mPrincipalToInherit(aPrincipalToInherit),
|
||||
@@ -833,6 +834,7 @@ LoadInfo::LoadInfo(
|
||||
aHasInjectedCookieForCookieBannerHandling),
|
||||
mSchemelessInput(aSchemelessInput),
|
||||
mHttpsUpgradeTelemetry(aHttpsUpgradeTelemetry),
|
||||
mUserNavigationInvolvement(aUserNavigationInvolvement),
|
||||
mIsNewWindowTarget(aIsNewWindowTarget) {
|
||||
// Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
|
||||
MOZ_ASSERT(mLoadingPrincipal ||
|
||||
@@ -997,6 +999,18 @@ LoadInfo::GetLoadingDocument(Document** aResult) {
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::GetUserNavigationInvolvement(uint8_t* aUserNavigationInvolvement) {
|
||||
*aUserNavigationInvolvement = uint8_t(mUserNavigationInvolvement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
LoadInfo::SetUserNavigationInvolvement(uint8_t aUserNavigationInvolvement) {
|
||||
mUserNavigationInvolvement =
|
||||
dom::UserNavigationInvolvement(aUserNavigationInvolvement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsINode* LoadInfo::LoadingNode() {
|
||||
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define mozilla_LoadInfo_h
|
||||
|
||||
#include "mozilla/dom/FeaturePolicy.h"
|
||||
#include "mozilla/dom/UserNavigationInvolvement.h"
|
||||
#include "nsIInterceptionInfo.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsIPrincipal.h"
|
||||
@@ -262,7 +263,8 @@ class LoadInfo final : public nsILoadInfo {
|
||||
bool aHasInjectedCookieForCookieBannerHandling,
|
||||
nsILoadInfo::SchemelessInputType aSchemelessInput,
|
||||
nsILoadInfo::HTTPSUpgradeTelemetryType aHttpsUpgradeTelemetry,
|
||||
bool aIsNewWindowTarget);
|
||||
bool aIsNewWindowTarget,
|
||||
dom::UserNavigationInvolvement aUserNavigationInvolvement);
|
||||
|
||||
LoadInfo(const LoadInfo& rhs);
|
||||
|
||||
@@ -422,6 +424,9 @@ class LoadInfo final : public nsILoadInfo {
|
||||
nsILoadInfo::HTTPSUpgradeTelemetryType mHttpsUpgradeTelemetry =
|
||||
nsILoadInfo::NOT_INITIALIZED;
|
||||
|
||||
dom::UserNavigationInvolvement mUserNavigationInvolvement =
|
||||
dom::UserNavigationInvolvement::None;
|
||||
|
||||
bool mIsNewWindowTarget = false;
|
||||
bool mSkipHTTPSUpgrade = false;
|
||||
};
|
||||
|
||||
@@ -54,6 +54,17 @@ TRRLoadInfo::SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRLoadInfo::GetUserNavigationInvolvement(
|
||||
uint8_t* aUserNavigationInvolvement) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
TRRLoadInfo::SetUserNavigationInvolvement(uint8_t aUserNavigationInvolvement) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsIPrincipal* TRRLoadInfo::PrincipalToInherit() { return nullptr; }
|
||||
|
||||
nsIPrincipal* TRRLoadInfo::FindPrincipalToInherit(nsIChannel* aChannel) {
|
||||
|
||||
@@ -22,6 +22,7 @@ webidl BrowsingContext;
|
||||
native LoadContextRef(already_AddRefed<nsISupports>);
|
||||
%{C++
|
||||
#include "nsTArray.h"
|
||||
#include "mozilla/dom/UserNavigationInvolvement.h"
|
||||
#include "mozilla/LoadTainting.h"
|
||||
#include "mozilla/OriginAttributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
@@ -1617,4 +1618,18 @@ interface nsILoadInfo : nsISupports
|
||||
* When true, this load will never be upgraded to HTTPS.
|
||||
*/
|
||||
[infallible] attribute boolean skipHTTPSUpgrade;
|
||||
|
||||
/**
|
||||
* see https://html.spec.whatwg.org/#user-navigation-involvement
|
||||
*/
|
||||
attribute uint8_t userNavigationInvolvement;
|
||||
%{C++
|
||||
mozilla::dom::UserNavigationInvolvement GetUserNavigationInvolvement() {
|
||||
uint8_t userNavigationInvolvement = 0;
|
||||
mozilla::DebugOnly<nsresult> rv = GetUserNavigationInvolvement(&userNavigationInvolvement);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
MOZ_DIAGNOSTIC_ASSERT(userNavigationInvolvement < 3);
|
||||
return static_cast<mozilla::dom::UserNavigationInvolvement>(userNavigationInvolvement);
|
||||
}
|
||||
%}
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ include ProtocolTypes;
|
||||
include "mozilla/dom/DomSecurityIPCUtils.h";
|
||||
include "mozilla/dom/FetchIPCTypes.h";
|
||||
include "mozilla/dom/FeaturePolicyUtils.h";
|
||||
include "mozilla/dom/NavigationAPIIPCUtils.h";
|
||||
include "mozilla/dom/PropertyBagUtils.h";
|
||||
include "mozilla/dom/ReferrerInfoUtils.h";
|
||||
include "mozilla/ipc/URIUtils.h";
|
||||
@@ -42,6 +43,7 @@ using mozilla::net::LinkHeader from "nsNetUtil.h";
|
||||
using mozilla::dom::FeaturePolicyInfo from "mozilla/dom/FeaturePolicy.h";
|
||||
using nsILoadInfo::HTTPSUpgradeTelemetryType from "nsILoadInfo.h";
|
||||
using nsILoadInfo::SchemelessInputType from "nsILoadInfo.h";
|
||||
using mozilla::dom::UserNavigationInvolvement from "mozilla/dom/UserNavigationInvolvement.h";
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@@ -200,6 +202,7 @@ struct LoadInfoArgs
|
||||
nullable nsIURI unstrippedURI;
|
||||
InterceptionInfoArg? interceptionInfo;
|
||||
bool isNewWindowTarget;
|
||||
UserNavigationInvolvement userNavigationInvolvement;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -295,6 +298,8 @@ struct ParentLoadInfoForwarderArgs
|
||||
|
||||
nullable nsIURI unstrippedURI;
|
||||
|
||||
UserNavigationInvolvement userNavigationInvolvement;
|
||||
|
||||
// IMPORTANT: when you add new properites here you must also update
|
||||
// LoadInfoToParentLoadInfoForwarder and MergeParentLoadInfoForwarder
|
||||
// in BackgroundUtils.cpp/.h!
|
||||
|
||||
Reference in New Issue
Block a user