/* -*- 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/. */
class nsIBrowserDOMWindow; class nsISHistory; class nsIWidget; class nsIPrintSettings; class nsSHistory; class nsBrowserStatusFilter; class nsSecureBrowserUI; class CallerWillNotifyHistoryIndexAndLengthChanges; class nsITimer;
namespace mozilla { enumclass CallState; class BounceTrackingState;
namespace embedding { class PrintData;
}
namespace net { class DocumentLoadListener;
}
namespace dom {
class BrowserParent; class BrowserBridgeParent; class FeaturePolicy; struct LoadURIOptions; class MediaController; struct LoadingSessionHistoryInfo; class SSCacheCopy; class WindowGlobalParent; class SessionStoreFormData; class SessionStoreScrollData;
// CanonicalBrowsingContext is a BrowsingContext living in the parent // process, with whatever extra data that a BrowsingContext in the // parent needs. class CanonicalBrowsingContext final : public BrowsingContext { public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
CanonicalBrowsingContext, BrowsingContext)
// The ID of the BrowsingContext which caused this BrowsingContext to be // opened, or `0` if this is unknown. // Only set for toplevel content BrowsingContexts, and may be from a different // BrowsingContextGroup.
uint64_t GetCrossGroupOpenerId() const { return mCrossGroupOpenerId; }
already_AddRefed<CanonicalBrowsingContext> GetCrossGroupOpener() const; void SetCrossGroupOpenerId(uint64_t aOpenerId); void SetCrossGroupOpener(CanonicalBrowsingContext* aCrossGroupOpener,
ErrorResult& aRv);
// The current active WindowGlobal.
WindowGlobalParent* GetCurrentWindowGlobal() const;
// Same as the methods on `BrowsingContext`, but with the types already cast // to the parent process type.
CanonicalBrowsingContext* GetParent() { return Cast(BrowsingContext::GetParent());
}
CanonicalBrowsingContext* Top() { return Cast(BrowsingContext::Top()); }
WindowGlobalParent* GetParentWindowContext();
WindowGlobalParent* GetTopWindowContext();
// Same as `GetParentWindowContext`, but will also cross <browser> and // content/chrome boundaries.
already_AddRefed<WindowGlobalParent> GetEmbedderWindowGlobal() const;
using PrintPromise =
MozPromise<MaybeDiscardedBrowsingContext, nsresult, false>;
MOZ_CAN_RUN_SCRIPT RefPtr<PrintPromise> Print(nsIPrintSettings*);
MOZ_CAN_RUN_SCRIPT already_AddRefed<Promise> PrintJS(nsIPrintSettings*,
ErrorResult&);
MOZ_CAN_RUN_SCRIPT RefPtr<PrintPromise> PrintWithNoContentAnalysis(
nsIPrintSettings* aPrintSettings, bool aForceStaticDocument, const MaybeDiscardedBrowsingContext& aClonedStaticBrowsingContext);
MOZ_CAN_RUN_SCRIPT void ReleaseClonedPrint( const MaybeDiscardedBrowsingContext& aClonedStaticBrowsingContext); // Call the given callback on all top-level descendant BrowsingContexts. // Return Callstate::Stop from the callback to stop calling further children. // // If aIncludeNestedBrowsers is true, then all top descendants are included, // even those inside a nested top browser. void CallOnAllTopDescendants( const FunctionRef<CallState(CanonicalBrowsingContext*)>& aCallback, bool aIncludeNestedBrowsers);
// Calls the session history listeners' OnHistoryReload, storing the result in // aCanReload. If aCanReload is set to true and we have an active or a loading // entry then aLoadState will be initialized from that entry, and // aReloadActiveEntry will be true if we have an active entry. If aCanReload // is true and aLoadState and aReloadActiveEntry are not set then we should // attempt to reload based on the current document in the docshell. void NotifyOnHistoryReload( bool aForceReload, bool& aCanReload,
Maybe<NotNull<RefPtr<nsDocShellLoadState>>>& aLoadState,
Maybe<bool>& aReloadActiveEntry);
// Dispatches a wheel zoom change to the embedder element. void DispatchWheelZoomChange(bool aIncrease);
// This function is used to start the autoplay media which are delayed to // start. If needed, it would also notify the content browsing context which // are related with the canonical browsing content tree to start delayed // autoplay media. void NotifyStartDelayedAutoplayMedia();
// This function is used to mute or unmute all media within a tab. It would // set the media mute property for the top level window and propagate it to // other top level windows in other processes. void NotifyMediaMutedChanged(bool aMuted, ErrorResult& aRv);
// Return the number of unique site origins by iterating all given BCs, // including their subtrees. static uint32_t CountSiteOrigins(
GlobalObject& aGlobal, const Sequence<mozilla::OwningNonNull<BrowsingContext>>& aRoots);
// Return true if a private browsing session is active. staticbool IsPrivateBrowsingActive();
// This function would propogate the action to its all child browsing contexts // in content processes. void UpdateMediaControlAction(const MediaControlAction& aAction);
// Triggers a load in the process using BrowsingContext::LoadURI; void FixupAndLoadURIString(const nsAString& aURI, const LoadURIOptions& aOptions,
ErrorResult& aError); void LoadURI(nsIURI* aURI, const LoadURIOptions& aOptions,
ErrorResult& aError);
// Get the publicly exposed current URI loaded in this BrowsingContext.
already_AddRefed<nsIURI> GetCurrentURI() const; void SetCurrentRemoteURI(nsIURI* aCurrentRemoteURI);
// Internal method to change which process a BrowsingContext is being loaded // in. The returned promise will resolve when the process switch is completed. // // A NOT_REMOTE_TYPE aRemoteType argument will perform a process switch into // the parent process, and the method will resolve with a null BrowserParent. using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
MOZ_CAN_RUN_SCRIPT
RefPtr<RemotenessPromise> ChangeRemoteness( const NavigationIsolationOptions& aOptions, uint64_t aPendingSwitchId);
// Return a media controller from the top-level browsing context that can // control all media belonging to this browsing context tree. Return nullptr // if the top-level browsing context has been discarded.
MediaController* GetMediaController(); bool HasCreatedMediaController() const;
// Attempts to start loading the given load state in this BrowsingContext, // without requiring any communication from a docshell. This will handle // computing the right process to load in, and organising handoff to // the right docshell when we get a response. bool LoadInParent(nsDocShellLoadState* aLoadState, bool aSetNavigating);
// Attempts to start loading the given load state in this BrowsingContext, // in parallel with a DocumentChannelChild being created in the docshell. // Requires the DocumentChannel to connect with this load for it to // complete successfully. bool AttemptSpeculativeLoadInParent(nsDocShellLoadState* aLoadState);
// Get or create a secure browser UI for this BrowsingContext
nsISecureBrowserUI* GetSecureBrowserUI();
// Called when the current URI changes (from an // nsIWebProgressListener::OnLocationChange event, so that we // can update our security UI for the new location, or when the // mixed content/https-only state for our current window is changed. void UpdateSecurityState();
// Called when a navigation forces us to recreate our browsing // context (for example, when switching in or out of the parent // process). // aNewContext is the newly created BrowsingContext that is replacing // us. void ReplacedBy(CanonicalBrowsingContext* aNewContext, const NavigationIsolationOptions& aRemotenessOptions);
// Called when a BrowserParent for this BrowsingContext has been fully // destroyed (i.e. `ActorDestroy` was called). void BrowserParentDestroyed(BrowserParent* aBrowserParent, bool aAbnormalShutdown);
// Methods for getting and setting the active state for top level // browsing contexts, for the process priority manager. bool IsPriorityActive() const {
MOZ_RELEASE_ASSERT(IsTop()); return mPriorityActive;
} void SetPriorityActive(bool aIsActive) {
MOZ_RELEASE_ASSERT(IsTop());
mPriorityActive = aIsActive;
}
// When request for page awake, it would increase a count that is used to // prevent whole browsing context tree from being suspended. The request can // be called multiple times. When calling the revoke, it would decrease the // count and once the count reaches to zero, the browsing context tree could // be suspended when the tree is inactive. void AddPageAwakeRequest(); void RemovePageAwakeRequest();
// Returns a Promise which resolves when cloning documents for printing // finished if this browsing context is cloning document tree.
RefPtr<GenericNonExclusivePromise> GetClonePromise() const { return mClonePromise;
}
protected: // Called when the browsing context is being discarded. void CanonicalDiscard();
// Called when the browsing context is being attached. void CanonicalAttach();
// Called when the browsing context private mode is changed after // being attached, but before being discarded. void AdjustPrivateBrowsingCount(bool aPrivateBrowsing);
using Type = BrowsingContext::Type;
CanonicalBrowsingContext(WindowContext* aParentWindow,
BrowsingContextGroup* aGroup,
uint64_t aBrowsingContextId,
uint64_t aOwnerProcessId,
uint64_t aEmbedderProcessId, Type aType,
FieldValues&& aInit);
private: friendclass BrowsingContext;
virtual ~CanonicalBrowsingContext();
class PendingRemotenessChange { public:
NS_INLINE_DECL_REFCOUNTING(PendingRemotenessChange)
friendclass net::DocumentLoadListener; // Called when a DocumentLoadListener is created to start a load for // this browsing context. Returns false if a higher priority load is // already in-progress and the new one has been rejected. bool StartDocumentLoad(net::DocumentLoadListener* aLoad); // Called once DocumentLoadListener completes handling a load, and it // is either complete, or handed off to the final channel to deliver // data to the destination docshell. // If aContinueNavigating it set, the reference to the DocumentLoadListener // will be cleared to prevent it being cancelled, however the current load ID // will be preserved until `EndDocumentLoad` is called again. void EndDocumentLoad(bool aContinueNavigating);
// Called when we want to show the subframe crashed UI as our previous browser // has become unloaded for one reason or another. void ShowSubframeCrashedUI(BrowserBridgeParent* aBridge);
// XXX(farre): Store a ContentParent pointer here rather than mProcessId? // Indicates which process owns the docshell.
uint64_t mProcessId;
// Indicates which process owns the embedder element.
uint64_t mEmbedderProcessId;
uint64_t mCrossGroupOpenerId = 0;
// This function will make the top window context reset its // "SHEntryHasUserInteraction" cache that prevents documents from repeatedly // setting user interaction on SH entries. Should be called anytime SH // entries are added or replaced. void ResetSHEntryHasUserInteractionCache();
RefPtr<BrowserParent> mCurrentBrowserParent;
nsTArray<UnloadingHost> mUnloadingHosts;
// The current URI loaded in this BrowsingContext. This value is only set for // BrowsingContexts loaded in content processes.
nsCOMPtr<nsIURI> mCurrentRemoteURI;
// The current remoteness change which is in a pending state.
RefPtr<PendingRemotenessChange> mPendingRemotenessChange;
RefPtr<nsSHistory> mSessionHistory;
// Tab media controller is used to control all media existing in the same // browsing context tree, so it would only exist in the top level browsing // context.
RefPtr<MediaController> mTabMediaController;
// If this is a top level context, this is true if our browser ID is marked as // active in the process priority manager. bool mPriorityActive = false;
// See CanonicalBrowsingContext.forceAppWindowActive. bool mForceAppWindowActive = false;
bool mIsReplaced = false;
// A Promise created when cloning documents for printing.
RefPtr<GenericNonExclusivePromise> mClonePromise;
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.