tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

LoadInfo.h (29935B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_LoadInfo_h
      8 #define mozilla_LoadInfo_h
      9 
     10 #include "mozilla/dom/FeaturePolicy.h"
     11 #include "mozilla/dom/ReferrerPolicyBinding.h"
     12 #include "mozilla/dom/UserNavigationInvolvement.h"
     13 #include "nsIInterceptionInfo.h"
     14 #include "nsILoadInfo.h"
     15 #include "nsIPrincipal.h"
     16 #include "nsIWeakReferenceUtils.h"  // for nsWeakPtr
     17 #include "nsIURI.h"
     18 #include "nsContentUtils.h"
     19 #include "nsString.h"
     20 #include "nsTArray.h"
     21 
     22 #include "mozilla/BasePrincipal.h"
     23 #include "mozilla/Result.h"
     24 #include "mozilla/dom/ClientInfo.h"
     25 #include "mozilla/dom/ServiceWorkerDescriptor.h"
     26 
     27 class nsDocShell;
     28 class nsICookieJarSettings;
     29 class nsIPolicyContainer;
     30 class nsINode;
     31 class nsPIDOMWindowOuter;
     32 
     33 namespace mozilla {
     34 
     35 namespace dom {
     36 class PerformanceStorage;
     37 class XMLHttpRequestMainThread;
     38 class CanonicalBrowsingContext;
     39 class WindowGlobalParent;
     40 }  // namespace dom
     41 
     42 namespace net {
     43 class EarlyHintPreloader;
     44 class LoadInfoArgs;
     45 class LoadInfo;
     46 class WebTransportSessionProxy;
     47 }  // namespace net
     48 
     49 namespace ipc {
     50 // we have to forward declare that function so we can use it as a friend.
     51 nsresult LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
     52                                const nsACString& aOriginRemoteType,
     53                                nsINode* aCspToInheritLoadingContext,
     54                                net::LoadInfo** outLoadInfo);
     55 
     56 }  // namespace ipc
     57 
     58 #define LOADINFO_DUMMY_SETTER(type, name)
     59 
     60 #define LOADINFO_FOR_EACH_FIELD(GETTER, SETTER)                                \
     61  /*     Type  Name                  LoadInfoArgs Name     Default         */  \
     62  GETTER(uint32_t, TriggeringSandboxFlags, triggeringSandboxFlags, 0)          \
     63  SETTER(uint32_t, TriggeringSandboxFlags)                                     \
     64                                                                               \
     65  GETTER(uint64_t, TriggeringWindowId, triggeringWindowId, 0)                  \
     66  SETTER(uint64_t, TriggeringWindowId)                                         \
     67                                                                               \
     68  GETTER(bool, TriggeringStorageAccess, triggeringStorageAccess, false)        \
     69  SETTER(bool, TriggeringStorageAccess)                                        \
     70                                                                               \
     71  GETTER(uint32_t, TriggeringFirstPartyClassificationFlags,                    \
     72         triggeringFirstPartyClassificationFlags, 0)                           \
     73  SETTER(uint32_t, TriggeringFirstPartyClassificationFlags)                    \
     74                                                                               \
     75  GETTER(uint32_t, TriggeringThirdPartyClassificationFlags,                    \
     76         triggeringThirdPartyClassificationFlags, 0)                           \
     77  SETTER(uint32_t, TriggeringThirdPartyClassificationFlags)                    \
     78                                                                               \
     79  GETTER(bool, BlockAllMixedContent, blockAllMixedContent, false)              \
     80                                                                               \
     81  GETTER(bool, UpgradeInsecureRequests, upgradeInsecureRequests, false)        \
     82                                                                               \
     83  GETTER(bool, BrowserUpgradeInsecureRequests, browserUpgradeInsecureRequests, \
     84         false)                                                                \
     85                                                                               \
     86  GETTER(bool, BrowserDidUpgradeInsecureRequests,                              \
     87         browserDidUpgradeInsecureRequests, false)                             \
     88  SETTER(bool, BrowserDidUpgradeInsecureRequests)                              \
     89                                                                               \
     90  GETTER(bool, BrowserWouldUpgradeInsecureRequests,                            \
     91         browserWouldUpgradeInsecureRequests, false)                           \
     92                                                                               \
     93  GETTER(bool, ForceAllowDataURI, forceAllowDataURI, false)                    \
     94  SETTER(bool, ForceAllowDataURI)                                              \
     95                                                                               \
     96  GETTER(bool, AllowInsecureRedirectToDataURI, allowInsecureRedirectToDataURI, \
     97         false)                                                                \
     98  SETTER(bool, AllowInsecureRedirectToDataURI)                                 \
     99                                                                               \
    100  GETTER(dom::ForceMediaDocument, ForceMediaDocument, forceMediaDocument,      \
    101         /* ForceMediaDocument::None */ dom::ForceMediaDocument(0))            \
    102  SETTER(dom::ForceMediaDocument, ForceMediaDocument)                          \
    103                                                                               \
    104  GETTER(bool, SkipContentPolicyCheckForWebRequest,                            \
    105         skipContentPolicyCheckForWebRequest, false)                           \
    106  SETTER(bool, SkipContentPolicyCheckForWebRequest)                            \
    107                                                                               \
    108  GETTER(bool, OriginalFrameSrcLoad, originalFrameSrcLoad, false)              \
    109  SETTER(bool, OriginalFrameSrcLoad)                                           \
    110                                                                               \
    111  GETTER(bool, ForceInheritPrincipalDropped, forceInheritPrincipalDropped,     \
    112         false)                                                                \
    113                                                                               \
    114  GETTER(uint64_t, InnerWindowID, innerWindowID, 0)                            \
    115                                                                               \
    116  GETTER(uint64_t, BrowsingContextID, browsingContextID, 0)                    \
    117                                                                               \
    118  GETTER(uint64_t, FrameBrowsingContextID, frameBrowsingContextID, 0)          \
    119                                                                               \
    120  GETTER(bool, IsOn3PCBExceptionList, isOn3PCBExceptionList, false)            \
    121  SETTER(bool, IsOn3PCBExceptionList)                                          \
    122                                                                               \
    123  GETTER(bool, IsFormSubmission, isFormSubmission, false)                      \
    124  SETTER(bool, IsFormSubmission)                                               \
    125                                                                               \
    126  GETTER(bool, IsGETRequest, isGETRequest, true)                               \
    127  SETTER(bool, IsGETRequest)                                                   \
    128                                                                               \
    129  GETTER(bool, SendCSPViolationEvents, sendCSPViolationEvents, true)           \
    130  SETTER(bool, SendCSPViolationEvents)                                         \
    131                                                                               \
    132  GETTER(uint32_t, RequestBlockingReason, requestBlockingReason,               \
    133         BLOCKING_REASON_NONE)                                                 \
    134  SETTER(uint32_t, RequestBlockingReason)                                      \
    135                                                                               \
    136  GETTER(bool, ForcePreflight, forcePreflight, false)                          \
    137                                                                               \
    138  GETTER(bool, IsPreflight, isPreflight, false)                                \
    139                                                                               \
    140  GETTER(bool, ServiceWorkerTaintingSynthesized,                               \
    141         serviceWorkerTaintingSynthesized, false)                              \
    142                                                                               \
    143  GETTER(bool, DocumentHasUserInteracted, documentHasUserInteracted, false)    \
    144  SETTER(bool, DocumentHasUserInteracted)                                      \
    145                                                                               \
    146  GETTER(bool, AllowListFutureDocumentsCreatedFromThisRedirectChain,           \
    147         allowListFutureDocumentsCreatedFromThisRedirectChain, false)          \
    148  SETTER(bool, AllowListFutureDocumentsCreatedFromThisRedirectChain)           \
    149                                                                               \
    150  GETTER(bool, NeedForCheckingAntiTrackingHeuristic,                           \
    151         needForCheckingAntiTrackingHeuristic, false)                          \
    152  SETTER(bool, NeedForCheckingAntiTrackingHeuristic)                           \
    153                                                                               \
    154  GETTER(bool, SkipContentSniffing, skipContentSniffing, false)                \
    155  SETTER(bool, SkipContentSniffing)                                            \
    156                                                                               \
    157  GETTER(uint32_t, HttpsOnlyStatus, httpsOnlyStatus,                           \
    158         nsILoadInfo::HTTPS_ONLY_UNINITIALIZED)                                \
    159  SETTER(uint32_t, HttpsOnlyStatus)                                            \
    160                                                                               \
    161  GETTER(bool, HstsStatus, httpsOnlyStatus, false)                             \
    162  SETTER(bool, HstsStatus)                                                     \
    163                                                                               \
    164  GETTER(bool, HasValidUserGestureActivation, hasValidUserGestureActivation,   \
    165         false)                                                                \
    166  SETTER(bool, HasValidUserGestureActivation)                                  \
    167                                                                               \
    168  GETTER(bool, TextDirectiveUserActivation, textDirectiveUserActivation,       \
    169         false)                                                                \
    170  SETTER(bool, TextDirectiveUserActivation)                                    \
    171                                                                               \
    172  GETTER(bool, AllowDeprecatedSystemRequests, allowDeprecatedSystemRequests,   \
    173         false)                                                                \
    174  SETTER(bool, AllowDeprecatedSystemRequests)                                  \
    175                                                                               \
    176  GETTER(bool, IsInDevToolsContext, isInDevToolsContext, false)                \
    177  SETTER(bool, IsInDevToolsContext)                                            \
    178                                                                               \
    179  GETTER(bool, ParserCreatedScript, parserCreatedScript, false)                \
    180  SETTER(bool, ParserCreatedScript)                                            \
    181                                                                               \
    182  GETTER(Maybe<dom::RequestMode>, RequestMode, requestMode, Nothing())         \
    183  SETTER(Maybe<dom::RequestMode>, RequestMode)                                 \
    184                                                                               \
    185  GETTER(nsILoadInfo::StoragePermissionState, StoragePermission,               \
    186         storagePermission, nsILoadInfo::NoStoragePermission)                  \
    187  SETTER(nsILoadInfo::StoragePermissionState, StoragePermission)               \
    188                                                                               \
    189  GETTER(nsILoadInfo::IPAddressSpace, ParentIpAddressSpace,                    \
    190         parentIPAddressSpace, nsILoadInfo::Unknown)                           \
    191  SETTER(nsILoadInfo::IPAddressSpace, ParentIpAddressSpace)                    \
    192                                                                               \
    193  GETTER(nsILoadInfo::IPAddressSpace, IpAddressSpace, ipAddressSpace,          \
    194         nsILoadInfo::Unknown)                                                 \
    195  SETTER(nsILoadInfo::IPAddressSpace, IpAddressSpace)                          \
    196                                                                               \
    197  GETTER(bool, IsMetaRefresh, isMetaRefresh, false)                            \
    198  SETTER(bool, IsMetaRefresh)                                                  \
    199                                                                               \
    200  GETTER(bool, IsFromProcessingFrameAttributes,                                \
    201         isFromProcessingFrameAttributes, false)                               \
    202                                                                               \
    203  GETTER(bool, IsMediaRequest, isMediaRequest, false)                          \
    204  SETTER(bool, IsMediaRequest)                                                 \
    205                                                                               \
    206  GETTER(bool, IsMediaInitialRequest, isMediaInitialRequest, false)            \
    207  SETTER(bool, IsMediaInitialRequest)                                          \
    208                                                                               \
    209  GETTER(bool, IsFromObjectOrEmbed, isFromObjectOrEmbed, false)                \
    210  SETTER(bool, IsFromObjectOrEmbed)                                            \
    211                                                                               \
    212  GETTER(nsILoadInfo::CrossOriginEmbedderPolicy, LoadingEmbedderPolicy,        \
    213         loadingEmbedderPolicy, nsILoadInfo::EMBEDDER_POLICY_NULL)             \
    214  SETTER(nsILoadInfo::CrossOriginEmbedderPolicy, LoadingEmbedderPolicy)        \
    215                                                                               \
    216  GETTER(bool, IsOriginTrialCoepCredentiallessEnabledForTopLevel,              \
    217         originTrialCoepCredentiallessEnabledForTopLevel, false)               \
    218  SETTER(bool, IsOriginTrialCoepCredentiallessEnabledForTopLevel)              \
    219                                                                               \
    220  GETTER(bool, HasInjectedCookieForCookieBannerHandling,                       \
    221         hasInjectedCookieForCookieBannerHandling, false)                      \
    222  SETTER(bool, HasInjectedCookieForCookieBannerHandling)                       \
    223                                                                               \
    224  GETTER(nsILoadInfo::HTTPSUpgradeTelemetryType, HttpsUpgradeTelemetry,        \
    225         httpsUpgradeTelemetry, nsILoadInfo::NOT_INITIALIZED)                  \
    226  SETTER(nsILoadInfo::HTTPSUpgradeTelemetryType, HttpsUpgradeTelemetry)        \
    227                                                                               \
    228  GETTER(bool, IsNewWindowTarget, isNewWindowTarget, false)                    \
    229  SETTER(bool, IsNewWindowTarget)
    230 
    231 // Heads-up: LoadInfoToLoadInfoArgs still needs to be manually updated.
    232 
    233 namespace net {
    234 using RedirectHistoryArray = nsTArray<nsCOMPtr<nsIRedirectHistoryEntry>>;
    235 
    236 /**
    237 * Class that provides an nsILoadInfo implementation.
    238 */
    239 class LoadInfo final : public nsILoadInfo {
    240  template <typename T, typename... Args>
    241  friend already_AddRefed<T> mozilla::MakeAndAddRef(Args&&... aArgs);
    242 
    243 public:
    244  NS_DECL_ISUPPORTS
    245  NS_DECL_NSILOADINFO
    246 
    247  // Currently used for most load types, but prefer the specialized
    248  // factories below when possible. aLoadingPrincipal MUST NOT BE NULL.
    249  static mozilla::Result<already_AddRefed<LoadInfo>, nsresult> Create(
    250      nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
    251      nsINode* aLoadingContext, nsSecurityFlags aSecurityFlags,
    252      nsContentPolicyType aContentPolicyType,
    253      const Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo =
    254          Maybe<mozilla::dom::ClientInfo>(),
    255      const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController =
    256          Maybe<mozilla::dom::ServiceWorkerDescriptor>(),
    257      uint32_t aSandboxFlags = 0);
    258 
    259  // Used for TYPE_DOCUMENT load.
    260  static already_AddRefed<LoadInfo> CreateForDocument(
    261      dom::CanonicalBrowsingContext* aBrowsingContext, nsIURI* aURI,
    262      nsIPrincipal* aTriggeringPrincipal,
    263      const nsACString& aTriggeringRemoteType,
    264      const OriginAttributes& aOriginAttributes, nsSecurityFlags aSecurityFlags,
    265      uint32_t aSandboxFlags);
    266 
    267  // Used for TYPE_FRAME or TYPE_IFRAME load.
    268  static already_AddRefed<LoadInfo> CreateForFrame(
    269      dom::CanonicalBrowsingContext* aBrowsingContext,
    270      nsIPrincipal* aTriggeringPrincipal,
    271      const nsACString& aTriggeringRemoteType, nsSecurityFlags aSecurityFlags,
    272      uint32_t aSandboxFlags);
    273 
    274  // Use for non-{TYPE_DOCUMENT|TYPE_FRAME|TYPE_IFRAME} load.
    275  static already_AddRefed<LoadInfo> CreateForNonDocument(
    276      dom::WindowGlobalParent* aParentWGP, nsIPrincipal* aTriggeringPrincipal,
    277      nsContentPolicyType aContentPolicyType, nsSecurityFlags aSecurityFlags,
    278      uint32_t aSandboxFlags);
    279 
    280  // Constructor used for TYPE_DOCUMENT loads which have a different
    281  // loadingContext than other loads. This ContextForTopLevelLoad is
    282  // only used for content policy checks.
    283  LoadInfo(nsPIDOMWindowOuter* aOuterWindow, nsIURI* aURI,
    284           nsIPrincipal* aTriggeringPrincipal,
    285           nsISupports* aContextForTopLevelLoad, nsSecurityFlags aSecurityFlags,
    286           uint32_t aSandboxFlags);
    287 
    288 private:
    289  // Use factory function Create.
    290  // aLoadingPrincipal MUST NOT BE NULL.
    291  LoadInfo(nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
    292           nsINode* aLoadingContext, nsSecurityFlags aSecurityFlags,
    293           nsContentPolicyType aContentPolicyType,
    294           const Maybe<mozilla::dom::ClientInfo>& aLoadingClientInfo,
    295           const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
    296           uint32_t aSandboxFlags);
    297 
    298  // Use factory function CreateForDocument
    299  // Used for TYPE_DOCUMENT load.
    300  LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext, nsIURI* aURI,
    301           nsIPrincipal* aTriggeringPrincipal,
    302           const nsACString& aTriggeringRemoteType,
    303           const OriginAttributes& aOriginAttributes,
    304           nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
    305 
    306  // Use factory function CreateForFrame
    307  // Used for TYPE_FRAME or TYPE_IFRAME load.
    308  LoadInfo(dom::CanonicalBrowsingContext* aBrowsingContext,
    309           nsIPrincipal* aTriggeringPrincipal,
    310           const nsACString& aTriggeringRemoteType,
    311           nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
    312 
    313  // Used for loads initiated by DocumentLoadListener that are not
    314  // TYPE_DOCUMENT | TYPE_FRAME | TYPE_FRAME.
    315  LoadInfo(dom::WindowGlobalParent* aParentWGP,
    316           nsIPrincipal* aTriggeringPrincipal,
    317           const nsACString& aTriggeringRemoteType,
    318           nsContentPolicyType aContentPolicyType,
    319           nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags);
    320 
    321 public:
    322  // Compute a list of ancestor principals and BrowsingContext IDs.
    323  // See methods AncestorPrincipals and AncestorBrowsingContextIDs
    324  // in nsILoadInfo.idl for details.
    325  static void ComputeAncestors(
    326      dom::CanonicalBrowsingContext* aBC,
    327      nsTArray<nsCOMPtr<nsIPrincipal>>& aAncestorPrincipals,
    328      nsTArray<uint64_t>& aBrowsingContextIDs);
    329 
    330  // create an exact copy of the loadinfo
    331  already_AddRefed<nsILoadInfo> Clone() const;
    332 
    333  // hands off!!! don't use CloneWithNewSecFlags unless you know
    334  // exactly what you are doing - it should only be used within
    335  // nsBaseChannel::Redirect()
    336  already_AddRefed<nsILoadInfo> CloneWithNewSecFlags(
    337      nsSecurityFlags aSecurityFlags) const;
    338  // creates a copy of the loadinfo which is appropriate to use for a
    339  // separate request. I.e. not for a redirect or an inner channel, but
    340  // when a separate request is made with the same security properties.
    341  already_AddRefed<nsILoadInfo> CloneForNewRequest() const;
    342 
    343  // The `nsContentPolicyType GetExternalContentPolicyType()` version
    344  // in the base class is hidden by the implementation of
    345  // `GetExternalContentPolicyType(nsContentPolicyType* aResult)` in
    346  // LoadInfo.cpp. Explicit mark it visible.
    347  using nsILoadInfo::GetExternalContentPolicyType;
    348 
    349  void SetIsPreflight();
    350  void SetUpgradeInsecureRequests(bool aValue);
    351  void SetBrowserUpgradeInsecureRequests();
    352  void SetBrowserWouldUpgradeInsecureRequests();
    353  void SetIsFromProcessingFrameAttributes();
    354 
    355  dom::ReferrerPolicy GetFrameReferrerPolicySnapshot() const;
    356  void SetFrameReferrerPolicySnapshot(dom::ReferrerPolicy aPolicy);
    357 
    358  // Hands off from the cspToInherit functionality!
    359  //
    360  // For navigations, GetCSPToInherit returns what the spec calls the
    361  // "request's client's global object's CSP list", or more precisely
    362  // a snapshot of it taken when the navigation starts.  For
    363  // navigations that need to inherit their CSP, this is the right CSP
    364  // to use for the new document.  We need a way to transfer the CSP
    365  // from the docshell (where the navigation starts) to the point where
    366  // the new document is created and decides whether to inherit its
    367  // CSP, and this is the mechanism we use for that.
    368  //
    369  // For example:
    370  // A document with a CSP triggers a new top-level data: URI load.
    371  // We pass the CSP of the document that triggered the load all the
    372  // way to docshell. Within docshell we call SetCSPToInherit() on the
    373  // loadinfo. Within Document::InitCSP() we check if the newly created
    374  // document needs to inherit the CSP. If so, we call
    375  // GetCSPToInherit() and set the inherited CSP as the CSP for the new
    376  // document. Please note that any additonal Meta CSP in that document
    377  // will be merged into that CSP. Any subresource loads within that
    378  // document subesquently will receive the correct CSP by querying
    379  // loadinfo->GetCsp() from that point on.
    380  void SetPolicyContainerToInherit(
    381      nsIPolicyContainer* aPolicyContainerToInherit);
    382 
    383  bool HasIsThirdPartyContextToTopWindowSet() {
    384    return mIsThirdPartyContextToTopWindow.isSome();
    385  }
    386  void ClearIsThirdPartyContextToTopWindow() {
    387    mIsThirdPartyContextToTopWindow.reset();
    388  }
    389 
    390  void SetContinerFeaturePolicy(
    391      const Maybe<dom::FeaturePolicyInfo>& aContainerFeaturePolicy) {
    392    mContainerFeaturePolicyInfo = aContainerFeaturePolicy;
    393  }
    394 
    395 #ifdef DEBUG
    396  void MarkOverriddenFingerprintingSettingsAsSet() {
    397    mOverriddenFingerprintingSettingsIsSet = true;
    398  }
    399 #endif
    400 
    401 private:
    402  // Private constructor that is only allowed to be called from within
    403  // mozilla::ipc::LoadInfoArgsToLoadInfo declared as friends undeneath.
    404  // In e10s we can not serialize nsINode, hence we store the innerWindowID.
    405  // Please note that aRedirectChain uses swapElements.
    406  LoadInfo(nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aTriggeringPrincipal,
    407           nsIPrincipal* aPrincipalToInherit, nsIPrincipal* aTopLevelPrincipal,
    408           nsIURI* aResultPrincipalURI,
    409           nsICookieJarSettings* aCookieJarSettings,
    410           nsIPolicyContainer* aPolicyContainerToInherit,
    411           const Maybe<dom::FeaturePolicyInfo>& aContainerFeaturePolicyInfo,
    412           const nsACString& aTriggeringRemoteType,
    413           const nsID& aSandboxedNullPrincipalID,
    414           const Maybe<mozilla::dom::ClientInfo>& aClientInfo,
    415           const Maybe<mozilla::dom::ClientInfo>& aReservedClientInfo,
    416           const Maybe<mozilla::dom::ClientInfo>& aInitialClientInfo,
    417           const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
    418           nsSecurityFlags aSecurityFlags, uint32_t aSandboxFlags,
    419           nsContentPolicyType aContentPolicyType, LoadTainting aTainting,
    420 
    421 #define DEFINE_PARAMETER(type, name, _n, _d) type a##name,
    422           LOADINFO_FOR_EACH_FIELD(DEFINE_PARAMETER, LOADINFO_DUMMY_SETTER)
    423 #undef DEFINE_PARAMETER
    424 
    425               bool aInitialSecurityCheckDone,
    426           bool aIsThirdPartyContext,
    427           const Maybe<bool>& aIsThirdPartyContextToTopWindow,
    428           const OriginAttributes& aOriginAttributes,
    429           RedirectHistoryArray&& aRedirectChainIncludingInternalRedirects,
    430           RedirectHistoryArray&& aRedirectChain,
    431           nsTArray<nsCOMPtr<nsIPrincipal>>&& aAncestorPrincipals,
    432           const nsTArray<uint64_t>& aAncestorBrowsingContextIDs,
    433           const nsTArray<nsCString>& aCorsUnsafeHeaders,
    434           bool aLoadTriggeredFromExternal, const nsAString& aCspNonce,
    435           const nsAString& aIntegrityMetadata, bool aIsSameDocumentNavigation,
    436           const Maybe<RFPTargetSet>& aOverriddenFingerprintingSettings,
    437           nsINode* aLoadingContext, nsIURI* aUnstrippedURI,
    438           nsIInterceptionInfo* aInterceptionInfo,
    439           nsILoadInfo::SchemelessInputType aSchemelessInput,
    440           dom::UserNavigationInvolvement aUserNavigationInvolvement);
    441 
    442  LoadInfo(const LoadInfo& rhs);
    443 
    444  NS_IMETHOD GetRedirects(JSContext* aCx,
    445                          JS::MutableHandle<JS::Value> aRedirects,
    446                          const RedirectHistoryArray& aArra);
    447 
    448  friend nsresult mozilla::ipc::LoadInfoArgsToLoadInfo(
    449      const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
    450      const nsACString& aOriginRemoteType, nsINode* aCspToInheritLoadingContext,
    451      net::LoadInfo** outLoadInfo);
    452 
    453  ~LoadInfo();
    454 
    455  void ComputeIsThirdPartyContext(nsPIDOMWindowOuter* aOuterWindow);
    456  void ComputeIsThirdPartyContext(dom::WindowGlobalParent* aGlobal);
    457 
    458  bool IsDocumentMissingClientInfo();
    459 
    460  // This function is the *only* function which can change the securityflags
    461  // of a loadinfo. It only exists because of the XHR code. Don't call it
    462  // from anywhere else!
    463  void SetIncludeCookiesSecFlag();
    464  friend class mozilla::dom::XMLHttpRequestMainThread;
    465 
    466  // nsDocShell::OpenInitializedChannel, EarlyHintPreloader::OpenChannel and
    467  // WebTransportSessionProxy::AsyncConnectWithClient need to update the
    468  // loadInfo with the correct browsingContext.
    469  friend class ::nsDocShell;
    470  friend class mozilla::net::EarlyHintPreloader;
    471  friend class mozilla::net::WebTransportSessionProxy;
    472  void UpdateBrowsingContextID(uint64_t aBrowsingContextID) {
    473    mBrowsingContextID = aBrowsingContextID;
    474  }
    475  void UpdateFrameBrowsingContextID(uint64_t aFrameBrowsingContextID) {
    476    mFrameBrowsingContextID = aFrameBrowsingContextID;
    477  }
    478 
    479  void UpdateParentAddressSpaceInfo();
    480  MOZ_NEVER_INLINE void ReleaseMembers();
    481 
    482  // if you add a member, please also update the copy constructor and consider
    483  // if it should be merged from parent channel through
    484  // ParentLoadInfoForwarderArgs.
    485  nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
    486  nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
    487  nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
    488  nsCOMPtr<nsIPrincipal> mTopLevelPrincipal;
    489  nsCOMPtr<nsIURI> mResultPrincipalURI;
    490  nsCOMPtr<nsIURI> mChannelCreationOriginalURI;
    491  nsCOMPtr<nsICSPEventListener> mCSPEventListener;
    492  nsCOMPtr<nsICookieJarSettings> mCookieJarSettings;
    493  nsCOMPtr<nsIPolicyContainer> mPolicyContainerToInherit;
    494  Maybe<dom::FeaturePolicyInfo> mContainerFeaturePolicyInfo;
    495  nsCString mTriggeringRemoteType;
    496  nsID mSandboxedNullPrincipalID;
    497 
    498  Maybe<mozilla::dom::ClientInfo> mClientInfo;
    499  UniquePtr<mozilla::dom::ClientSource> mReservedClientSource;
    500  Maybe<mozilla::dom::ClientInfo> mReservedClientInfo;
    501  Maybe<mozilla::dom::ClientInfo> mInitialClientInfo;
    502  Maybe<mozilla::dom::ServiceWorkerDescriptor> mController;
    503  RefPtr<mozilla::dom::PerformanceStorage> mPerformanceStorage;
    504 
    505  nsWeakPtr mLoadingContext;
    506  nsWeakPtr mContextForTopLevelLoad;
    507  nsSecurityFlags mSecurityFlags;
    508  uint32_t mSandboxFlags;
    509  dom::ReferrerPolicy mFrameReferrerPolicySnapshot =
    510      dom::ReferrerPolicy::_empty;
    511  nsContentPolicyType mInternalContentPolicyType;
    512  LoadTainting mTainting = LoadTainting::Basic;
    513 
    514 #define DEFINE_FIELD(type, name, _, default_init) type m##name = default_init;
    515  LOADINFO_FOR_EACH_FIELD(DEFINE_FIELD, LOADINFO_DUMMY_SETTER)
    516 #undef DEFINE_FIELD
    517 
    518  uint64_t mWorkerAssociatedBrowsingContextID = 0;
    519  bool mInitialSecurityCheckDone = false;
    520  // NB: TYPE_DOCUMENT implies !third-party.
    521  bool mIsThirdPartyContext = false;
    522  Maybe<bool> mIsThirdPartyContextToTopWindow;
    523  OriginAttributes mOriginAttributes;
    524  RedirectHistoryArray mRedirectChainIncludingInternalRedirects;
    525  RedirectHistoryArray mRedirectChain;
    526  nsTArray<nsCOMPtr<nsIPrincipal>> mAncestorPrincipals;
    527  nsTArray<uint64_t> mAncestorBrowsingContextIDs;
    528  nsTArray<nsCString> mCorsUnsafeHeaders;
    529  bool mLoadTriggeredFromExternal = false;
    530  nsString mCspNonce;
    531  nsString mIntegrityMetadata;
    532  bool mIsSameDocumentNavigation = false;
    533  bool mIsUserTriggeredSave = false;
    534 
    535  Maybe<RFPTargetSet> mOverriddenFingerprintingSettings;
    536 #ifdef DEBUG
    537  // A boolean used to ensure the mOverriddenFingerprintingSettings is set
    538  // before use it.
    539  bool mOverriddenFingerprintingSettingsIsSet = false;
    540 #endif
    541 
    542  nsCOMPtr<nsIURI> mUnstrippedURI;
    543 
    544  nsCOMPtr<nsIInterceptionInfo> mInterceptionInfo;
    545 
    546  nsILoadInfo::SchemelessInputType mSchemelessInput =
    547      nsILoadInfo::SchemelessInputTypeUnset;
    548 
    549  dom::UserNavigationInvolvement mUserNavigationInvolvement =
    550      dom::UserNavigationInvolvement::None;
    551 
    552  bool mSkipHTTPSUpgrade = false;
    553 };
    554 // This is exposed solely for testing purposes and should not be used outside of
    555 // LoadInfo
    556 already_AddRefed<nsIPrincipal> CreateTruncatedPrincipal(nsIPrincipal*);
    557 
    558 }  // namespace net
    559 
    560 }  // namespace mozilla
    561 
    562 #endif  // mozilla_LoadInfo_h