/* -*- 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/. */
namespace mozilla { class LogModule; class nsRFPTargetSetIDL;
namespace dom {
class WindowGlobalChild; class WindowGlobalParent; class WindowGlobalInit; class BrowsingContext; class BrowsingContextGroup;
#define MOZ_EACH_WC_FIELD(FIELD) \ /* Whether the SHEntry associated with the current top-level \ * window has already seen user interaction. \ * As such, this will be reset to false when a new SHEntry is \ * created without changing the WC (e.g. when using pushState or \ * sub-frame navigation) \ * This flag is set for optimization purposes, to avoid \ * having to get the top SHEntry and update it on every \ * user interaction. \
* This is only meaningful on the top-level WC. */
FIELD(SHEntryHasUserInteraction, bool) \
FIELD(CookieBehavior, Maybe<uint32_t>) \
FIELD(IsOnContentBlockingAllowList, bool) \ /* Whether the given window hierarchy is third party. See \
* ThirdPartyUtil::IsThirdPartyWindow for details */
FIELD(IsThirdPartyWindow, bool) \ /* Whether this window's channel has been marked as a third-party \
* tracking resource */
FIELD(IsThirdPartyTrackingResourceWindow, bool) \ /* Whether this window is using its unpartitioned cookies due to \
* the Storage Access API */
FIELD(UsingStorageAccess, bool) \
FIELD(ShouldResistFingerprinting, bool) \
FIELD(OverriddenFingerprintingSettings, Maybe<RFPTargetSet>) \
FIELD(IsSecureContext, bool) \
FIELD(IsOriginalFrameSource, bool) \ /* Mixed-Content: If the corresponding documentURI is https, \
* then this flag is true. */
FIELD(IsSecure, bool) \ /* Whether the user has overriden the mixed content blocker to allow \
* mixed content loads to happen */
FIELD(AllowMixedContent, bool) \ /* Whether this window has registered a "beforeunload" event \
* handler */
FIELD(HasBeforeUnload, bool) \ /* Controls whether the WindowContext is currently considered to be \
* activated by a gesture */
FIELD(UserActivationStateAndModifiers, \
UserActivation::StateAndModifiers::DataT) \
FIELD(EmbedderPolicy, nsILoadInfo::CrossOriginEmbedderPolicy) \ /* True if this document tree contained at least a HTMLMediaElement. \
* This should only be set on top level context. */
FIELD(DocTreeHadMedia, bool) \
FIELD(AutoplayPermission, uint32_t) \
FIELD(ShortcutsPermission, uint32_t) \ /* Store the Id of the browsing context where active media session \
* exists on the top level window context */
FIELD(ActiveMediaSessionContextId, Maybe<uint64_t>) \ /* ALLOW_ACTION if it is allowed to open popups for the sub-tree \
* starting and including the current WindowContext */
FIELD(PopupPermission, uint32_t) \
FIELD(DelegatedPermissions, \
PermissionDelegateHandler::DelegatedPermissionList) \
FIELD(DelegatedExactHostMatchPermissions, \
PermissionDelegateHandler::DelegatedPermissionList) \
FIELD(HasReportedShadowDOMUsage, bool) \ /* Whether the principal of this window is for a local \
* IP address */
FIELD(IsLocalIP, bool) \ /* Whether any of the windows in the subtree rooted at this window has \
* active peer connections or not (only set on the top window). */
FIELD(HasActivePeerConnections, bool) \ /* Whether we can execute scripts in this WindowContext. Has no effect \
* unless scripts are also allowed in the BrowsingContext. */
FIELD(AllowJavascript, bool) \ /* If this field is `true`, it means that this WindowContext's \ * WindowState was saved to be stored in the legacy (non-SHIP) BFCache \
* implementation. Always false for SHIP */
FIELD(WindowStateSaved, bool)
class WindowContext : public nsISupports, public nsWrapperCache {
MOZ_DECL_SYNCED_CONTEXT(WindowContext, MOZ_EACH_WC_FIELD)
// Get the parent WindowContext of this WindowContext, taking the BFCache into // account. This will not cross chrome/content <browser> boundaries.
WindowContext* GetParentWindowContext();
WindowContext* TopWindowContext();
// The filtered version of `Children()`, which contains no browsing contexts // for synthetic documents as created by object loading content.
Span<RefPtr<BrowsingContext>> NonSyntheticChildren() { return mNonSyntheticChildren;
}
// Cast this object to it's parent-process canonical form.
WindowGlobalParent* Canonical();
// Add new security state flags. // These should be some of the nsIWebProgressListener 'HTTPS_ONLY_MODE' or // 'MIXED' state flags, and should only be called on the top window context. void AddSecurityState(uint32_t aStateFlags);
// This function would be called when its corresponding window is activated // by user gesture. void NotifyUserGestureActivation(
UserActivation::Modifiers aModifiers = UserActivation::Modifiers::None());
// This function would be called when we want to reset the user gesture // activation flag. void NotifyResetUserGestureActivation();
// Return true if its corresponding window has been activated by user // gesture. bool HasBeenUserGestureActivated();
// Return true if its corresponding window has transient user gesture // activation and the transient user gesture activation haven't yet timed // out. bool HasValidTransientUserGestureActivation();
// See `mUserGestureStart`. const TimeStamp& GetUserGestureStart() const;
// Return true if the corresponding window has valid transient user gesture // activation and the transient user gesture activation had been consumed // successfully. bool ConsumeTransientUserGestureActivation();
// Return true if its corresponding window has history activation. bool HasValidHistoryActivation() const;
// Return true if the corresponding window has valid history activation // and the history activation had been consumed successfully. bool ConsumeHistoryActivation();
// Update non-synthetic children based on whether `aBrowsingContext` // is synthetic or not. Regardless the synthetic of `aBrowsingContext`, it is // kept in this WindowContext's all children list. void UpdateChildSynthetic(BrowsingContext* aBrowsingContext, bool aIsSynthetic);
// Send a given `BaseTransaction` object to the correct remote. void SendCommitTransaction(ContentParent* aParent, const BaseTransaction& aTxn, uint64_t aEpoch); void SendCommitTransaction(ContentChild* aChild, const BaseTransaction& aTxn,
uint64_t aEpoch);
// Overload `CanSet` to get notifications for a particular field being set. bool CanSet(FieldIndex<IDX_IsSecure>, constbool& aIsSecure,
ContentParent* aSource); bool CanSet(FieldIndex<IDX_AllowMixedContent>, constbool& aAllowMixedContent,
ContentParent* aSource);
// Overload `DidSet` to get notifications for a particular field being set. // // You can also overload the variant that gets the old value if you need it. template <size_t I> void DidSet(FieldIndex<I>) {} template <size_t I, typename T> void DidSet(FieldIndex<I>, T&& aOldValue) {} void DidSet(FieldIndex<IDX_UserActivationStateAndModifiers>);
// Recomputes whether we can execute scripts in this WindowContext based on // the value of AllowJavascript() and whether scripts are allowed in the // BrowsingContext. void RecomputeCanExecuteScripts(bool aApplyChanges = true);
// --- NEVER CHANGE `mChildren` DIRECTLY! --- // Changes to this list need to be synchronized to the list within our // `mBrowsingContext`, and should only be performed through the // `AppendChildBrowsingContext` and `RemoveChildBrowsingContext` methods.
nsTArray<RefPtr<BrowsingContext>> mChildren;
// --- NEVER CHANGE `mNonSyntheticChildren` DIRECTLY! --- // Same reason as for mChildren. // mNonSyntheticChildren contains the same browsing contexts except browsing // contexts created by the synthetic document for object loading contents // loading images. This is used to discern browsing contexts created when // loading images in <object> or <embed> elements, so that they can be hidden // from named targeting, `Window.frames` etc.
nsTArray<RefPtr<BrowsingContext>> mNonSyntheticChildren;
// Determines if we can execute scripts in this WindowContext. True if // AllowJavascript() is true and script execution is allowed in the // BrowsingContext. bool mCanExecuteScripts = true;
// The start time of user gesture, this is only available if the window // context is in process.
TimeStamp mUserGestureStart;
using WindowContextTransaction = WindowContext::BaseTransaction; using WindowContextInitializer = WindowContext::IPCInitializer; using MaybeDiscardedWindowContext = MaybeDiscarded<WindowContext>;
// Don't specialize the `Transaction` object for every translation unit it's // used in. This should help keep code size down. externtemplateclass syncedcontext::Transaction<WindowContext>;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.