/* -*- 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 for managing loading of a subframe (creation of the docshell, * handling of loads in it, recursion-checking). */ #ifndef nsFrameLoader_h_ #define nsFrameLoader_h_ #include "nsDocShell.h" #include "nsStringFwd.h" #include "nsPoint.h" #include "nsSize.h" #include "nsWrapperCache.h" #include "nsIURI.h" #include "nsFrameMessageManager.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ParentSHistory.h" #include "mozilla/dom/RemoteBrowser.h" #include "mozilla/Attributes.h" #include "mozilla/layers/LayersTypes.h" #include "nsStubMutationObserver.h" #include "Units.h" #include "nsIFrame.h" #include "nsPluginTags.h" class nsIURI; class nsSubDocumentFrame; class nsView; class AutoResetInShow; class AutoResetInFrameSwap; class nsFrameLoaderOwner; class nsIRemoteTab; class nsIDocShellTreeItem; class nsIDocShellTreeOwner; class nsILoadContext; class nsIMessageSender; class nsIPrintSettings; class nsIWebBrowserPersistDocumentReceiver; class nsIWebProgressListener; namespace mozilla { class OriginAttributes; namespace dom { class ChromeMessageSender; class ContentParent; class TabListener; class InProcessBrowserChildMessageManager; class MessageSender; class PBrowserParent; class ProcessMessageManager; class Promise; class BrowserParent; class MutableTabContext; class BrowserBridgeChild; class RemoteFrameChild; struct RemotenessOptions; namespace ipc { class StructuredCloneData; } // namespace ipc } // namespace dom namespace ipc { class MessageChannel; } // namespace ipc } // namespace mozilla #if defined(MOZ_WIDGET_GTK) typedef struct _GtkWidget GtkWidget; #endif // IID for nsFrameLoader, because some places want to QI to it. #define NS_FRAMELOADER_IID \ { \ 0x297fd0ea, 0x1b4a, 0x4c9a, { \ 0xa4, 0x04, 0xe5, 0x8b, 0xe8, 0x95, 0x10, 0x50 \ } \ } class nsFrameLoader final : public nsStubMutationObserver, public mozilla::dom::ipc::MessageManagerCallback, public nsWrapperCache { friend class AutoResetInShow; friend class AutoResetInFrameSwap; typedef mozilla::dom::Document Document; typedef mozilla::dom::BrowserParent BrowserParent; typedef mozilla::dom::BrowserBridgeChild BrowserBridgeChild; typedef mozilla::dom::BrowsingContext BrowsingContext; public: // Called by Frame Elements to create a new FrameLoader. static nsFrameLoader* Create(mozilla::dom::Element* aOwner, mozilla::dom::BrowsingContext* aOpener, bool aNetworkCreated); // Called by nsFrameLoaderOwner::ChangeRemoteness when switching out // FrameLoaders. static nsFrameLoader* Create(mozilla::dom::Element* aOwner, BrowsingContext* aPreservedBrowsingContext, const mozilla::dom::RemotenessOptions& aOptions); NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADER_IID) NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsFrameLoader) NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED nsresult CheckForRecursiveLoad(nsIURI* aURI); nsresult ReallyStartLoading(); void StartDestroy(); void DestroyDocShell(); void DestroyComplete(); nsIDocShell* GetExistingDocShell() const { return mBrowsingContext ? mBrowsingContext->GetDocShell() : nullptr; } mozilla::dom::InProcessBrowserChildMessageManager* GetBrowserChildMessageManager() const { return mChildMessageManager; } nsresult CreateStaticClone(nsFrameLoader* aDest); nsresult UpdatePositionAndSize(nsSubDocumentFrame* aIFrame); void SendIsUnderHiddenEmbedderElement(bool aIsUnderHiddenEmbedderElement); // WebIDL methods nsDocShell* GetDocShell(mozilla::ErrorResult& aRv); already_AddRefed GetRemoteTab(); already_AddRefed LoadContext(); already_AddRefed GetBrowsingContext(); /** * Start loading the frame. This method figures out what to load * from the owner content in the frame loader. */ void LoadFrame(bool aOriginalSrc); /** * Loads the specified URI in this frame. Behaves identically to loadFrame, * except that this method allows specifying the URI to load. * * @param aURI The URI to load. * @param aTriggeringPrincipal The triggering principal for the load. May be * null, in which case the node principal of the owner content will be * used. * @param aCsp The CSP to be used for the load. That is not the CSP to be * applied to subresources within the frame, but to the iframe load * itself. E.g. if the CSP holds upgrade-insecure-requests the the * frame load is upgraded from http to https. */ nsresult LoadURI(nsIURI* aURI, nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp, bool aOriginalSrc); /** * Resume a redirected load within this frame. * * @param aPendingSwitchID ID of a process-switching load to be reusmed * within this frame. */ void ResumeLoad(uint64_t aPendingSwitchID); /** * Destroy the frame loader and everything inside it. This will * clear the weak owner content reference. */ void Destroy(); void ActivateRemoteFrame(mozilla::ErrorResult& aRv); void DeactivateRemoteFrame(mozilla::ErrorResult& aRv); void SendCrossProcessMouseEvent(const nsAString& aType, float aX, float aY, int32_t aButton, int32_t aClickCount, int32_t aModifiers, bool aIgnoreRootScrollFrame, mozilla::ErrorResult& aRv); void ActivateFrameEvent(const nsAString& aType, bool aCapture, mozilla::ErrorResult& aRv); void RequestNotifyAfterRemotePaint(); void RequestUpdatePosition(mozilla::ErrorResult& aRv); bool RequestTabStateFlush(uint32_t aFlushId, bool aIsFinal = false); void Print(uint64_t aOuterWindowID, nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aProgressListener, mozilla::ErrorResult& aRv); already_AddRefed DrawSnapshot( double aX, double aY, double aW, double aH, double aScale, const nsAString& aBackgroundColor, mozilla::ErrorResult& aRv); void StartPersistence(uint64_t aOuterWindowID, nsIWebBrowserPersistDocumentReceiver* aRecv, mozilla::ErrorResult& aRv); // WebIDL getters already_AddRefed GetMessageManager(); already_AddRefed GetOwnerElement(); uint32_t LazyWidth() const; uint32_t LazyHeight() const; uint64_t ChildID() const { return mChildID; } bool DepthTooGreat() const { return mDepthTooGreat; } bool IsDead() const { return mDestroyCalled; } /** * Is this a frame loader for a bona fide