tor-browser

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

nsDocShellLoadState.h (26868B)


      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 nsDocShellLoadState_h__
      8 #define nsDocShellLoadState_h__
      9 
     10 #include "mozilla/dom/BrowsingContext.h"
     11 #include "mozilla/dom/NavigationBinding.h"
     12 #include "mozilla/dom/SessionHistoryEntry.h"
     13 #include "mozilla/dom/UserNavigationInvolvement.h"
     14 #include "mozilla/dom/LoadURIOptionsBinding.h"
     15 
     16 #include "nsIClassifiedChannel.h"
     17 #include "nsILoadInfo.h"
     18 
     19 // Helper Classes
     20 #include "mozilla/Maybe.h"
     21 #include "nsCOMPtr.h"
     22 #include "nsString.h"
     23 #include "nsDocShellLoadTypes.h"
     24 #include "nsTArrayForwardDeclare.h"
     25 
     26 class nsIInputStream;
     27 class nsISHEntry;
     28 class nsIURI;
     29 class nsIDocShell;
     30 class nsIChannel;
     31 class nsIReferrerInfo;
     32 struct HTTPSFirstDowngradeData;
     33 namespace mozilla {
     34 class OriginAttributes;
     35 namespace dom {
     36 class FormData;
     37 class DocShellLoadStateInit;
     38 struct NavigationAPIMethodTracker;
     39 }  // namespace dom
     40 }  // namespace mozilla
     41 
     42 /**
     43 * nsDocShellLoadState contains setup information used in a nsIDocShell::loadURI
     44 * call.
     45 */
     46 class nsDocShellLoadState final {
     47  using BrowsingContext = mozilla::dom::BrowsingContext;
     48  template <typename T>
     49  using MaybeDiscarded = mozilla::dom::MaybeDiscarded<T>;
     50 
     51 public:
     52  NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadState);
     53 
     54  explicit nsDocShellLoadState(nsIURI* aURI);
     55  explicit nsDocShellLoadState(
     56      const mozilla::dom::DocShellLoadStateInit& aLoadState,
     57      mozilla::ipc::IProtocol* aActor, bool* aReadSuccess);
     58  explicit nsDocShellLoadState(const nsDocShellLoadState& aOther);
     59  nsDocShellLoadState(nsIURI* aURI, uint64_t aLoadIdentifier);
     60 
     61  static nsresult CreateFromPendingChannel(nsIChannel* aPendingChannel,
     62                                           uint64_t aLoadIdentifier,
     63                                           uint64_t aRegistarId,
     64                                           nsDocShellLoadState** aResult);
     65 
     66  static nsresult CreateFromLoadURIOptions(
     67      BrowsingContext* aBrowsingContext, const nsAString& aURI,
     68      const mozilla::dom::LoadURIOptions& aLoadURIOptions,
     69      nsDocShellLoadState** aResult);
     70  static nsresult CreateFromLoadURIOptions(
     71      BrowsingContext* aBrowsingContext, nsIURI* aURI,
     72      const mozilla::dom::LoadURIOptions& aLoadURIOptions,
     73      nsDocShellLoadState** aResult);
     74 
     75  // Getters and Setters
     76 
     77  nsIReferrerInfo* GetReferrerInfo() const;
     78 
     79  void SetReferrerInfo(nsIReferrerInfo* aReferrerInfo);
     80 
     81  nsIURI* URI() const;
     82 
     83  void SetURI(nsIURI* aURI);
     84 
     85  nsIURI* OriginalURI() const;
     86 
     87  void SetOriginalURI(nsIURI* aOriginalURI);
     88 
     89  nsIURI* ResultPrincipalURI() const;
     90 
     91  void SetResultPrincipalURI(nsIURI* aResultPrincipalURI);
     92 
     93  bool ResultPrincipalURIIsSome() const;
     94 
     95  void SetResultPrincipalURIIsSome(bool aIsSome);
     96 
     97  bool KeepResultPrincipalURIIfSet() const;
     98 
     99  void SetKeepResultPrincipalURIIfSet(bool aKeep);
    100 
    101  nsIPrincipal* PrincipalToInherit() const;
    102 
    103  void SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit);
    104 
    105  nsIPrincipal* PartitionedPrincipalToInherit() const;
    106 
    107  void SetPartitionedPrincipalToInherit(
    108      nsIPrincipal* aPartitionedPrincipalToInherit);
    109 
    110  bool LoadReplace() const;
    111 
    112  void SetLoadReplace(bool aLoadReplace);
    113 
    114  nsIPrincipal* TriggeringPrincipal() const;
    115 
    116  void SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal);
    117 
    118  uint32_t TriggeringSandboxFlags() const;
    119 
    120  void SetTriggeringSandboxFlags(uint32_t aTriggeringSandboxFlags);
    121 
    122  uint64_t TriggeringWindowId() const;
    123 
    124  void SetTriggeringWindowId(uint64_t aTriggeringWindowId);
    125 
    126  bool TriggeringStorageAccess() const;
    127 
    128  void SetTriggeringStorageAccess(bool aTriggeringStorageAccess);
    129 
    130  mozilla::net::ClassificationFlags TriggeringClassificationFlags() const;
    131  void SetTriggeringClassificationFlags(
    132      mozilla::net::ClassificationFlags aFlags);
    133 
    134  nsIPolicyContainer* PolicyContainer() const;
    135 
    136  void SetPolicyContainer(nsIPolicyContainer* aPolicyContainer);
    137 
    138  bool InheritPrincipal() const;
    139 
    140  void SetInheritPrincipal(bool aInheritPrincipal);
    141 
    142  bool PrincipalIsExplicit() const;
    143 
    144  void SetPrincipalIsExplicit(bool aPrincipalIsExplicit);
    145 
    146  // If true, "beforeunload" event listeners were notified by the creater of the
    147  // LoadState and given the chance to abort the navigation, and should not be
    148  // notified again.
    149  bool NotifiedBeforeUnloadListeners() const;
    150 
    151  void SetNotifiedBeforeUnloadListeners(bool aNotifiedBeforeUnloadListeners);
    152 
    153  bool ForceAllowDataURI() const;
    154 
    155  void SetForceAllowDataURI(bool aForceAllowDataURI);
    156 
    157  bool IsExemptFromHTTPSFirstMode() const;
    158 
    159  void SetIsExemptFromHTTPSFirstMode(bool aIsExemptFromHTTPSFirstMode);
    160 
    161  RefPtr<HTTPSFirstDowngradeData> GetHttpsFirstDowngradeData() const;
    162 
    163  void SetHttpsFirstDowngradeData(
    164      RefPtr<HTTPSFirstDowngradeData> const& aHttpsFirstTelemetryData);
    165 
    166  bool OriginalFrameSrc() const;
    167 
    168  void SetOriginalFrameSrc(bool aOriginalFrameSrc);
    169 
    170  bool ShouldCheckForRecursion() const;
    171 
    172  void SetShouldCheckForRecursion(bool aShouldCheckForRecursion);
    173 
    174  bool IsFormSubmission() const;
    175 
    176  void SetIsFormSubmission(bool aIsFormSubmission);
    177 
    178  bool NeedsCompletelyLoadedDocument() const;
    179 
    180  void SetNeedsCompletelyLoadedDocument(bool aNeedsCompletelyLoadedDocument);
    181 
    182  mozilla::Maybe<mozilla::dom::NavigationHistoryBehavior> HistoryBehavior()
    183      const;
    184 
    185  void SetHistoryBehavior(
    186      mozilla::dom::NavigationHistoryBehavior aHistoryBehavior);
    187 
    188  void ResetHistoryBehavior();
    189 
    190  uint32_t LoadType() const;
    191 
    192  void SetLoadType(uint32_t aLoadType);
    193 
    194  mozilla::dom::UserNavigationInvolvement UserNavigationInvolvement() const;
    195 
    196  void SetUserNavigationInvolvement(
    197      mozilla::dom::UserNavigationInvolvement aUserNavigationInvolvement);
    198 
    199  nsISHEntry* SHEntry() const;
    200 
    201  void SetSHEntry(nsISHEntry* aSHEntry);
    202 
    203  const mozilla::dom::LoadingSessionHistoryInfo* GetLoadingSessionHistoryInfo()
    204      const;
    205 
    206  // Copies aLoadingInfo and stores the copy in this nsDocShellLoadState.
    207  void SetLoadingSessionHistoryInfo(
    208      const mozilla::dom::LoadingSessionHistoryInfo& aLoadingInfo);
    209 
    210  // Stores aLoadingInfo in this nsDocShellLoadState.
    211  void SetLoadingSessionHistoryInfo(
    212      mozilla::UniquePtr<mozilla::dom::LoadingSessionHistoryInfo> aLoadingInfo);
    213 
    214  bool LoadIsFromSessionHistory() const;
    215 
    216  const nsString& Target() const;
    217 
    218  void SetTarget(const nsAString& aTarget);
    219 
    220  nsIInputStream* PostDataStream() const;
    221 
    222  void SetPostDataStream(nsIInputStream* aStream);
    223 
    224  nsIInputStream* HeadersStream() const;
    225 
    226  void SetHeadersStream(nsIInputStream* aHeadersStream);
    227 
    228  bool IsSrcdocLoad() const;
    229 
    230  const nsString& SrcdocData() const;
    231 
    232  void SetSrcdocData(const nsAString& aSrcdocData);
    233 
    234  const MaybeDiscarded<BrowsingContext>& SourceBrowsingContext() const {
    235    return mSourceBrowsingContext;
    236  }
    237 
    238  void SetSourceBrowsingContext(BrowsingContext*);
    239 
    240  void SetAllowFocusMove(bool aAllow) { mAllowFocusMove = aAllow; }
    241 
    242  bool AllowFocusMove() const { return mAllowFocusMove; }
    243 
    244  const MaybeDiscarded<BrowsingContext>& TargetBrowsingContext() const {
    245    return mTargetBrowsingContext;
    246  }
    247 
    248  void SetTargetBrowsingContext(BrowsingContext* aTargetBrowsingContext);
    249 
    250  nsIURI* BaseURI() const;
    251 
    252  void SetBaseURI(nsIURI* aBaseURI);
    253 
    254  // Helper function allowing convenient work with mozilla::Maybe in C++, hiding
    255  // resultPrincipalURI and resultPrincipalURIIsSome attributes from the
    256  // consumer.
    257  void GetMaybeResultPrincipalURI(
    258      mozilla::Maybe<nsCOMPtr<nsIURI>>& aRPURI) const;
    259 
    260  void SetMaybeResultPrincipalURI(
    261      mozilla::Maybe<nsCOMPtr<nsIURI>> const& aRPURI);
    262 
    263  uint32_t LoadFlags() const;
    264 
    265  void SetLoadFlags(uint32_t aFlags);
    266 
    267  void SetLoadFlag(uint32_t aFlag);
    268 
    269  void UnsetLoadFlag(uint32_t aFlag);
    270 
    271  bool HasLoadFlags(uint32_t aFlag);
    272 
    273  uint32_t InternalLoadFlags() const;
    274 
    275  void SetInternalLoadFlags(uint32_t aFlags);
    276 
    277  void SetInternalLoadFlag(uint32_t aFlag);
    278 
    279  void UnsetInternalLoadFlag(uint32_t aFlag);
    280 
    281  bool HasInternalLoadFlags(uint32_t aFlag);
    282 
    283  bool FirstParty() const;
    284 
    285  void SetFirstParty(bool aFirstParty);
    286 
    287  bool HasValidUserGestureActivation() const;
    288 
    289  void SetHasValidUserGestureActivation(bool HasValidUserGestureActivation);
    290 
    291  void SetTextDirectiveUserActivation(bool aTextDirectiveUserActivation);
    292 
    293  bool GetTextDirectiveUserActivation();
    294 
    295  const nsCString& TypeHint() const;
    296 
    297  void SetTypeHint(const nsCString& aTypeHint);
    298 
    299  const nsString& FileName() const;
    300 
    301  void SetFileName(const nsAString& aFileName);
    302 
    303  nsIURI* GetUnstrippedURI() const;
    304 
    305  void SetUnstrippedURI(nsIURI* aUnstrippedURI);
    306 
    307  // Give the type of DocShell we're loading into (chrome/content/etc) and
    308  // origin attributes for the URI we're loading, figure out if we should
    309  // inherit our principal from the document the load was requested from, or
    310  // else if the principal should be set up later in the process (after loads).
    311  // See comments in function for more info on principal selection algorithm
    312  nsresult SetupInheritingPrincipal(
    313      mozilla::dom::BrowsingContext::Type aType,
    314      const mozilla::OriginAttributes& aOriginAttributes);
    315 
    316  // If no triggering principal exists at the moment, create one using referrer
    317  // information and origin attributes.
    318  nsresult SetupTriggeringPrincipal(
    319      const mozilla::OriginAttributes& aOriginAttributes);
    320 
    321  void SetIsFromProcessingFrameAttributes() {
    322    mIsFromProcessingFrameAttributes = true;
    323  }
    324  bool GetIsFromProcessingFrameAttributes() const {
    325    return mIsFromProcessingFrameAttributes;
    326  }
    327 
    328  nsIChannel* GetPendingRedirectedChannel() {
    329    return mPendingRedirectedChannel;
    330  }
    331 
    332  uint64_t GetPendingRedirectChannelRegistrarId() const {
    333    return mChannelRegistrarId;
    334  }
    335 
    336  void SetOriginalURIString(const nsCString& aOriginalURI) {
    337    mOriginalURIString.emplace(aOriginalURI);
    338  }
    339  const mozilla::Maybe<nsCString>& GetOriginalURIString() const {
    340    return mOriginalURIString;
    341  }
    342 
    343  void SetCancelContentJSEpoch(int32_t aCancelEpoch) {
    344    mCancelContentJSEpoch.emplace(aCancelEpoch);
    345  }
    346  const mozilla::Maybe<int32_t>& GetCancelContentJSEpoch() const {
    347    return mCancelContentJSEpoch;
    348  }
    349 
    350  uint64_t GetLoadIdentifier() const { return mLoadIdentifier; }
    351 
    352  void SetChannelInitialized(bool aInitilized) {
    353    mChannelInitialized = aInitilized;
    354  }
    355 
    356  bool GetChannelInitialized() const { return mChannelInitialized; }
    357 
    358  void SetIsMetaRefresh(bool aMetaRefresh) { mIsMetaRefresh = aMetaRefresh; }
    359 
    360  bool IsMetaRefresh() const { return mIsMetaRefresh; }
    361 
    362  const mozilla::Maybe<nsCString>& GetRemoteTypeOverride() const {
    363    return mRemoteTypeOverride;
    364  }
    365 
    366  void SetRemoteTypeOverride(const nsCString& aRemoteTypeOverride);
    367 
    368  void SetSchemelessInput(nsILoadInfo::SchemelessInputType aSchemelessInput) {
    369    mSchemelessInput = aSchemelessInput;
    370  }
    371 
    372  nsILoadInfo::SchemelessInputType GetSchemelessInput() {
    373    return mSchemelessInput;
    374  }
    375 
    376  void SetForceMediaDocument(
    377      mozilla::dom::ForceMediaDocument aForceMediaDocument) {
    378    mForceMediaDocument = aForceMediaDocument;
    379  }
    380 
    381  mozilla::dom::ForceMediaDocument GetForceMediaDocument() const {
    382    return mForceMediaDocument;
    383  }
    384 
    385  void SetHttpsUpgradeTelemetry(
    386      nsILoadInfo::HTTPSUpgradeTelemetryType aHttpsUpgradeTelemetry) {
    387    mHttpsUpgradeTelemetry = aHttpsUpgradeTelemetry;
    388  }
    389 
    390  nsILoadInfo::HTTPSUpgradeTelemetryType GetHttpsUpgradeTelemetry() {
    391    return mHttpsUpgradeTelemetry;
    392  }
    393 
    394  // Determine the remote type of the process which should be considered
    395  // responsible for this load for the purposes of security checks.
    396  //
    397  // This will generally be the process which created the nsDocShellLoadState
    398  // originally, however non-errorpage history loads are always considered to be
    399  // triggered by the parent process, as we can validate them against the
    400  // history entry.
    401  const nsCString& GetEffectiveTriggeringRemoteType() const;
    402 
    403  void SetTriggeringRemoteType(const nsACString& aTriggeringRemoteType);
    404 
    405  // Diagnostic assert if this is a system-principal triggered load, and it is
    406  // trivial to determine that the effective triggering remote type would not be
    407  // allowed to perform this load.
    408  //
    409  // This is called early during the load to crash as close to the cause as
    410  // possible. See bug 1838686 for details.
    411 #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
    412  void AssertProcessCouldTriggerLoadIfSystem();
    413 #else
    414  void AssertProcessCouldTriggerLoadIfSystem() {}
    415 #endif
    416 
    417  // When loading a document through nsDocShell::LoadURI(), a special set of
    418  // flags needs to be set based on other values in nsDocShellLoadState. This
    419  // function calculates those flags, before the LoadState is passed to
    420  // nsDocShell::InternalLoad.
    421  void CalculateLoadURIFlags();
    422 
    423  // Compute the load flags to be used by creating channel.  aUriModified and
    424  // aIsEmbeddingBlockedError are expected to be Nothing when called from parent
    425  // process.
    426  nsLoadFlags CalculateChannelLoadFlags(
    427      mozilla::dom::BrowsingContext* aBrowsingContext, bool aUriModified,
    428      mozilla::Maybe<bool> aIsEmbeddingBlockedError);
    429 
    430  mozilla::dom::DocShellLoadStateInit Serialize(
    431      mozilla::ipc::IProtocol* aActor);
    432 
    433  void SetLoadIsFromSessionHistory(int32_t aOffset, bool aLoadingCurrentEntry);
    434  void ClearLoadIsFromSessionHistory();
    435 
    436  void MaybeStripTrackerQueryStrings(mozilla::dom::BrowsingContext* aContext);
    437 
    438  // This is used as the parameter for https://html.spec.whatwg.org/#navigate
    439  void SetSourceElement(mozilla::dom::Element* aElement);
    440  already_AddRefed<mozilla::dom::Element> GetSourceElement() const;
    441 
    442  // This is used as the parameter for https://html.spec.whatwg.org/#navigate
    443  nsIStructuredCloneContainer* GetNavigationAPIState() const;
    444  void SetNavigationAPIState(nsIStructuredCloneContainer* aNavigationAPIState);
    445 
    446  // This is used to pass the navigation API method tracker through the
    447  // navigation pipeline for navigate().
    448  // See https://html.spec.whatwg.org/#navigation-api-method-tracker
    449  mozilla::dom::NavigationAPIMethodTracker* GetNavigationAPIMethodTracker()
    450      const;
    451  void SetNavigationAPIMethodTracker(
    452      mozilla::dom::NavigationAPIMethodTracker* aTracker);
    453 
    454  // This is used as the parameter for https://html.spec.whatwg.org/#navigate
    455  mozilla::dom::NavigationType GetNavigationType() const;
    456 
    457  // This is used as the parameter for https://html.spec.whatwg.org/#navigate
    458  // It should only ever be set if the method is POST.
    459  mozilla::dom::FormData* GetFormDataEntryList();
    460  void SetFormDataEntryList(mozilla::dom::FormData* aFormDataEntryList);
    461 
    462  // This is used as the getter/setter for the app link intent launch type
    463  // for the load.
    464  uint32_t GetAppLinkLaunchType() const;
    465  void SetAppLinkLaunchType(uint32_t aAppLinkLaunchType);
    466 
    467  // This is used as the getter/setter for the captive portal tab flag.
    468  bool GetIsCaptivePortalTab() const;
    469  void SetIsCaptivePortalTab(bool aIsCaptivePortalTab);
    470 
    471  void ProhibitInitialAboutBlankHandling() {
    472    mIsInitialAboutBlankHandlingProhibited = true;
    473  }
    474  bool IsInitialAboutBlankHandlingProhibited() {
    475    return mIsInitialAboutBlankHandlingProhibited;
    476  }
    477 
    478 protected:
    479  // Destructor can't be defaulted or inlined, as header doesn't have all type
    480  // includes it needs to do so.
    481  ~nsDocShellLoadState();
    482 
    483  // Given the original `nsDocShellLoadState` which was sent to a content
    484  // process, validate that they corespond to the same load.
    485  // Returns a static (telemetry-safe) string naming what did not match, or
    486  // nullptr if it succeeds.
    487  const char* ValidateWithOriginalState(nsDocShellLoadState* aOriginalState);
    488 
    489  static nsresult CreateFromLoadURIOptions(
    490      BrowsingContext* aBrowsingContext, nsIURI* aURI,
    491      const mozilla::dom::LoadURIOptions& aLoadURIOptions,
    492      uint32_t aLoadFlagsOverride, nsIInputStream* aPostDataOverride,
    493      nsDocShellLoadState** aResult);
    494 
    495  // This is the referrer for the load.
    496  nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
    497 
    498  // The URI we are navigating to. Will not be null once set.
    499  nsCOMPtr<nsIURI> mURI;
    500 
    501  // The URI to set as the originalURI on the channel that does the load. If
    502  // null, aURI will be set as the originalURI.
    503  nsCOMPtr<nsIURI> mOriginalURI;
    504 
    505  // The URI to be set to loadInfo.resultPrincipalURI
    506  // - When Nothing, there will be no change
    507  // - When Some, the principal URI will overwrite even
    508  //   with a null value.
    509  //
    510  // Valid only if mResultPrincipalURIIsSome is true (has the same meaning as
    511  // isSome() on mozilla::Maybe.)
    512  nsCOMPtr<nsIURI> mResultPrincipalURI;
    513  bool mResultPrincipalURIIsSome;
    514 
    515  // The principal of the load, that is, the entity responsible for causing the
    516  // load to occur. In most cases the referrer and the triggeringPrincipal's URI
    517  // will be identical.
    518  //
    519  // Please note that this is the principal that is used for security checks. If
    520  // the argument aURI is provided by the web, then please do not pass a
    521  // SystemPrincipal as the triggeringPrincipal.
    522  nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
    523 
    524  // The SandboxFlags of the load, that are, the SandboxFlags of the entity
    525  // responsible for causing the load to occur. Most likely this are the
    526  // SandboxFlags of the document that started the load.
    527  uint32_t mTriggeringSandboxFlags;
    528 
    529  // The window ID and current "has storage access" value of the entity
    530  // triggering the load. This allows the identification of self-initiated
    531  // same-origin navigations that should propogate unpartitioned storage access.
    532  uint64_t mTriggeringWindowId;
    533  bool mTriggeringStorageAccess;
    534 
    535  // The classification flags of the context responsible for causing
    536  // the load to start.
    537  mozilla::net::ClassificationFlags mTriggeringClassificationFlags;
    538 
    539  // The policyContainer of the load, that is, the policyContainer of the entity
    540  // responsible for causing the load to occur. Most likely this is the
    541  // policyContainer of the document that started the load. In case the entity
    542  // starting the load did not use a policyContainer, then mpPolicyContainer can
    543  // be null. Please note that this is also the policyContainer that will be
    544  // applied to the load in case the load encounters a server side redirect.
    545  nsCOMPtr<nsIPolicyContainer> mPolicyContainer;
    546 
    547  // If a refresh is caused by http-equiv="refresh" we want to set
    548  // aResultPrincipalURI, but we do not want to overwrite the channel's
    549  // ResultPrincipalURI, if it has already been set on the channel by a protocol
    550  // handler.
    551  bool mKeepResultPrincipalURIIfSet;
    552 
    553  // If set LOAD_REPLACE flag will be set on the channel. If aOriginalURI is
    554  // null, this argument is ignored.
    555  bool mLoadReplace;
    556 
    557  // If this attribute is true and no triggeringPrincipal is specified,
    558  // copy the principal from the referring document.
    559  bool mInheritPrincipal;
    560 
    561  // If this attribute is true only ever use the principal specified
    562  // by the triggeringPrincipal and inheritPrincipal attributes.
    563  // If there are security reasons for why this is unsafe, such
    564  // as trying to use a systemprincipal as the triggeringPrincipal
    565  // for a content docshell the load fails.
    566  bool mPrincipalIsExplicit;
    567 
    568  // If this attribute is true, any potential unload listeners have been
    569  // notified if applicable.
    570  bool mNotifiedBeforeUnloadListeners;
    571 
    572  // Principal we're inheriting. If null, this means the principal should be
    573  // inherited from the current document. If set to NullPrincipal, the channel
    574  // will fill in principal information later in the load. See internal comments
    575  // of SetupInheritingPrincipal for more info.
    576  //
    577  // When passed to InternalLoad, If this argument is null then
    578  // principalToInherit is computed differently. See nsDocShell::InternalLoad
    579  // for more comments.
    580 
    581  nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
    582 
    583  nsCOMPtr<nsIPrincipal> mPartitionedPrincipalToInherit;
    584 
    585  // If this attribute is true, then a top-level navigation
    586  // to a data URI will be allowed.
    587  bool mForceAllowDataURI;
    588 
    589  // If this attribute is true, then the top-level navigaion
    590  // will be exempt from HTTPS-Only-Mode upgrades.
    591  bool mIsExemptFromHTTPSFirstMode;
    592 
    593  // If set, this load is a HTTPS-First downgrade, and the downgrade data will
    594  // be submitted to telemetry later if the load succeeds.
    595  RefPtr<HTTPSFirstDowngradeData> mHttpsFirstDowngradeData;
    596 
    597  // If this attribute is true, this load corresponds to a frame
    598  // element loading its original src (or srcdoc) attribute.
    599  bool mOriginalFrameSrc;
    600 
    601  // If this attribute is true, this load corresponds to a frame, object, or
    602  // embed element that needs a recursion check when loading it's src (or data).
    603  // Unlike mOriginalFrameSrc, this attribute will always be set regardless
    604  // whether we've loaded the src already.
    605  bool mShouldCheckForRecursion;
    606 
    607  // If this attribute is true, then the load was initiated by a
    608  // form submission.
    609  bool mIsFormSubmission;
    610 
    611  // If this attribute is true, we need to check if the current document is
    612  // completely loaded to determine if we should perform a push or replace load.
    613  bool mNeedsCompletelyLoadedDocument;
    614 
    615  // If this attribute is `Auto`, we should determine if this should be a push
    616  // or replace load when actually loading.
    617  mozilla::Maybe<mozilla::dom::NavigationHistoryBehavior> mHistoryBehavior;
    618 
    619  // Contains a load type as specified by the nsDocShellLoadTypes::load*
    620  // constants
    621  uint32_t mLoadType;
    622 
    623  // https://html.spec.whatwg.org/#user-navigation-involvement
    624  mozilla::dom::UserNavigationInvolvement mUserNavigationInvolvement =
    625      mozilla::dom::UserNavigationInvolvement::None;
    626 
    627  // Active Session History entry (if loading from SH)
    628  nsCOMPtr<nsISHEntry> mSHEntry;
    629 
    630  // Loading session history info for the load
    631  mozilla::UniquePtr<mozilla::dom::LoadingSessionHistoryInfo>
    632      mLoadingSessionHistoryInfo;
    633 
    634  // Target for load, like _content, _blank etc.
    635  nsString mTarget;
    636 
    637  // When set, this is the Target Browsing Context for the navigation
    638  // after retargeting.
    639  MaybeDiscarded<BrowsingContext> mTargetBrowsingContext;
    640 
    641  // Post data stream (if POSTing)
    642  nsCOMPtr<nsIInputStream> mPostDataStream;
    643 
    644  // Additional Headers
    645  nsCOMPtr<nsIInputStream> mHeadersStream;
    646 
    647  // When set, the load will be interpreted as a srcdoc load, where contents of
    648  // this string will be loaded instead of the URI. Setting srcdocData sets
    649  // isSrcdocLoad to true
    650  nsString mSrcdocData;
    651 
    652  // When set, this is the Source Browsing Context for the navigation.
    653  MaybeDiscarded<BrowsingContext> mSourceBrowsingContext;
    654 
    655  // Used for srcdoc loads to give view-source knowledge of the load's base URI
    656  // as this information isn't embedded in the load's URI.
    657  nsCOMPtr<nsIURI> mBaseURI;
    658 
    659  // Set of Load Flags, taken from nsDocShellLoadTypes.h and nsIWebNavigation
    660  uint32_t mLoadFlags;
    661 
    662  // Set of internal load flags
    663  uint32_t mInternalLoadFlags;
    664 
    665  // Is this a First Party Load?
    666  bool mFirstParty;
    667 
    668  // Is this load triggered by a user gesture?
    669  bool mHasValidUserGestureActivation;
    670 
    671  // True if a text directive can be scrolled to. This is true either if the
    672  // load is triggered by a user, or the document has an unconsumed activation
    673  // (eg. client redirect).
    674  bool mTextDirectiveUserActivation = false;
    675 
    676  // Whether this load can steal the focus from the source browsing context.
    677  bool mAllowFocusMove;
    678 
    679  // A hint as to the content-type of the resulting data. If no hint, IsVoid()
    680  // should return true.
    681  nsCString mTypeHint;
    682 
    683  // Non-void when the link should be downloaded as the given filename.
    684  // mFileName being non-void but empty means that no filename hint was
    685  // specified, but link should still trigger a download. If not a download,
    686  // mFileName.IsVoid() should return true.
    687  nsString mFileName;
    688 
    689  // This will be true if this load is triggered by attribute changes.
    690  // See nsILoadInfo.isFromProcessingFrameAttributes
    691  bool mIsFromProcessingFrameAttributes;
    692 
    693  // If set, a pending cross-process redirected channel should be used to
    694  // perform the load. The channel will be stored in this value.
    695  nsCOMPtr<nsIChannel> mPendingRedirectedChannel;
    696 
    697  // An optional string representation of mURI, before any
    698  // fixups were applied, so that we can send it to a search
    699  // engine service if needed.
    700  mozilla::Maybe<nsCString> mOriginalURIString;
    701 
    702  // An optional value to pass to nsIDocShell::setCancelJSEpoch
    703  // when initiating the load.
    704  mozilla::Maybe<int32_t> mCancelContentJSEpoch;
    705 
    706  // If mPendingRedirectChannel is set, then this is the identifier
    707  // that the parent-process equivalent channel has been registered
    708  // with using RedirectChannelRegistrar.
    709  uint64_t mChannelRegistrarId;
    710 
    711  // An identifier to make it possible to examine if two loads are
    712  // equal, and which browsing context they belong to (see
    713  // BrowsingContext::{Get, Set}CurrentLoadIdentifier)
    714  const uint64_t mLoadIdentifier;
    715 
    716  // Optional value to indicate that a channel has been
    717  // pre-initialized in the parent process.
    718  bool mChannelInitialized;
    719 
    720  // True if the load was triggered by a meta refresh.
    721  bool mIsMetaRefresh;
    722 
    723  // True if the nsDocShellLoadState was received over IPC.
    724  bool mWasCreatedRemotely = false;
    725 
    726  // The original URI before query stripping happened. If it's present, it shows
    727  // the query stripping happened. Otherwise, it will be a nullptr.
    728  nsCOMPtr<nsIURI> mUnstrippedURI;
    729 
    730  // If set, the remote type which the load should be completed within.
    731  mozilla::Maybe<nsCString> mRemoteTypeOverride;
    732 
    733  // Remote type of the process which originally requested the load.
    734  nsCString mTriggeringRemoteType;
    735 
    736  // if the address had an intentional protocol
    737  nsILoadInfo::SchemelessInputType mSchemelessInput =
    738      nsILoadInfo::SchemelessInputTypeUnset;
    739 
    740  // If not None, force the load to result in a specific media document kind.
    741  mozilla::dom::ForceMediaDocument mForceMediaDocument =
    742      mozilla::dom::ForceMediaDocument::None;
    743 
    744  // Solely for the use of collecting Telemetry for HTTPS upgrades.
    745  nsILoadInfo::HTTPSUpgradeTelemetryType mHttpsUpgradeTelemetry =
    746      nsILoadInfo::NOT_INITIALIZED;
    747 
    748  nsWeakPtr mSourceElement;
    749 
    750  RefPtr<nsStructuredCloneContainer> mNavigationAPIState;
    751 
    752  RefPtr<mozilla::dom::NavigationAPIMethodTracker> mNavigationAPIMethodTracker;
    753 
    754  RefPtr<mozilla::dom::FormData> mFormDataEntryList;
    755 
    756  // App link intent launch type: 0 = unknown, 1 = cold, 2 = warm, 3 = hot.
    757  uint32_t mAppLinkLaunchType = 0;
    758 
    759  // Whether this is a captive portal tab.
    760  bool mIsCaptivePortalTab = false;
    761 
    762  // When this is the initial load and it is loading about:blank, force it
    763  // to take the regular load path. It will replace the previous document
    764  // and not load synchronous.
    765  bool mIsInitialAboutBlankHandlingProhibited;
    766 };
    767 
    768 #endif /* nsDocShellLoadState_h__ */