/* -*- 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/. */ #ifndef nsDocShell_h__ #define nsDocShell_h__ #include "mozilla/BasePrincipal.h" #include "mozilla/LinkedList.h" #include "mozilla/Maybe.h" #include "mozilla/Move.h" #include "mozilla/TimeStamp.h" #include "mozilla/UniquePtr.h" #include "mozilla/WeakPtr.h" #include "mozilla/dom/ProfileTimelineMarkerBinding.h" #include "mozilla/gfx/Matrix.h" #include "nsIAuthPromptProvider.h" #include "nsIBaseWindow.h" #include "nsIClipboardCommands.h" #include "nsIDeprecationWarner.h" #include "nsIDocShell.h" #include "nsIDocShellLoadInfo.h" #include "nsIDocShellTreeItem.h" #include "nsIDOMStorageManager.h" #include "nsIInterfaceRequestor.h" #include "nsILinkHandler.h" #include "nsILoadContext.h" #include "nsILoadURIDelegate.h" #include "nsINetworkInterceptController.h" #include "nsIRefreshURI.h" #include "nsIScrollable.h" #include "nsITabParent.h" #include "nsITextScroll.h" #include "nsIWebNavigation.h" #include "nsIWebPageDescriptor.h" #include "nsIWebProgressListener.h" #include "nsIWebShellServices.h" #include "nsAutoPtr.h" #include "nsCOMPtr.h" #include "nsContentPolicyUtils.h" #include "nsContentUtils.h" #include "nsCRT.h" #include "nsDocLoader.h" #include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences #include "nsRect.h" #include "nsString.h" #include "nsThreadUtils.h" #include "GeckoProfiler.h" #include "jsapi.h" #include "prtime.h" #include "Units.h" #include "timeline/ObservedDocShell.h" #include "timeline/TimelineConsumers.h" #include "timeline/TimelineMarker.h" // Interfaces Needed namespace mozilla { class Encoding; class HTMLEditor; enum class TaskCategory; namespace dom { class ClientInfo; class ClientSource; class EventTarget; typedef uint32_t ScreenOrientationInternal; } // namespace dom } // namespace mozilla class nsIClipboardDragDropHookList; class nsICommandManager; class nsIContentViewer; class nsIController; class nsIDocShellTreeOwner; class nsIDocument; class nsIDOMNode; class nsIGlobalHistory2; class nsIHttpChannel; class nsIMutableArray; class nsIPrompt; class nsIScrollableFrame; class nsISecureBrowserUI; class nsISHistory; class nsIStringBundle; class nsIURIFixup; class nsIURILoader; class nsIWebBrowserFind; class nsIWidget; class nsDocShell; class nsDocShellEditorData; class nsDOMNavigationTiming; class nsDSURIContentListener; class nsGlobalWindowInner; class nsGlobalWindowOuter; class FramingChecker; class OnLinkClickEvent; /* internally used ViewMode types */ enum ViewMode { viewNormal = 0x0, viewSource = 0x1 }; enum eCharsetReloadState { eCharsetReloadInit, eCharsetReloadRequested, eCharsetReloadStopOrigional }; class nsDocShell final : public nsDocLoader , public nsIDocShell , public nsIWebNavigation , public nsIBaseWindow , public nsIScrollable , public nsITextScroll , public nsIRefreshURI , public nsIWebProgressListener , public nsIWebPageDescriptor , public nsIAuthPromptProvider , public nsILoadContext , public nsIWebShellServices , public nsILinkHandler , public nsIClipboardCommands , public nsIDOMStorageManager , public nsINetworkInterceptController , public nsIDeprecationWarner , public mozilla::SupportsWeakPtr { public: // Event type dispatched by RestorePresentation class RestorePresentationEvent : public mozilla::Runnable { public: NS_DECL_NSIRUNNABLE explicit RestorePresentationEvent(nsDocShell* aDs) : mozilla::Runnable("nsDocShell::RestorePresentationEvent") , mDocShell(aDs) { } void Revoke() { mDocShell = nullptr; } private: RefPtr mDocShell; }; class InterfaceRequestorProxy : public nsIInterfaceRequestor { public: explicit InterfaceRequestorProxy(nsIInterfaceRequestor* aRequestor); NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR private: virtual ~InterfaceRequestorProxy(); InterfaceRequestorProxy() {} nsWeakPtr mWeakPtr; }; MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell) NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDocShell, nsDocLoader) NS_DECL_NSIDOCSHELL NS_DECL_NSIDOCSHELLTREEITEM NS_DECL_NSIWEBNAVIGATION NS_DECL_NSIBASEWINDOW NS_DECL_NSISCROLLABLE NS_DECL_NSITEXTSCROLL NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIWEBPROGRESSLISTENER NS_DECL_NSIREFRESHURI NS_DECL_NSIWEBPAGEDESCRIPTOR NS_DECL_NSIAUTHPROMPTPROVIDER NS_DECL_NSICLIPBOARDCOMMANDS NS_DECL_NSIWEBSHELLSERVICES NS_DECL_NSINETWORKINTERCEPTCONTROLLER NS_DECL_NSIDEPRECATIONWARNER NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager()) // Need to implement (and forward) nsISecurityEventSink, because // nsIWebProgressListener has methods with identical names... NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::) nsDocShell(); virtual nsresult Init() override; NS_IMETHOD Stop() override { // Need this here because otherwise nsIWebNavigation::Stop // overrides the docloader's Stop() return nsDocLoader::Stop(); } // nsILinkHandler NS_IMETHOD OnLinkClick(nsIContent* aContent, nsIURI* aURI, const char16_t* aTargetSpec, const nsAString& aFileName, nsIInputStream* aPostDataStream, int64_t aPostDataStreamLength, nsIInputStream* aHeadersDataStream, bool aIsTrusted, nsIPrincipal* aTriggeringPrincipal) override; NS_IMETHOD OnLinkClickSync(nsIContent* aContent, nsIURI* aURI, const char16_t* aTargetSpec, const nsAString& aFileName, nsIInputStream* aPostDataStream = 0, int64_t aPostDataStreamLength = -1, nsIInputStream* aHeadersDataStream = 0, bool aNoOpenerImplied = false, nsIDocShell** aDocShell = 0, nsIRequest** aRequest = 0, nsIPrincipal* aTriggeringPrincipal = nullptr) override; NS_IMETHOD OnOverLink(nsIContent* aContent, nsIURI* aURI, const char16_t* aTargetSpec) override; NS_IMETHOD OnLeaveLink() override; // Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods // are shared with nsIDocShell (appID, etc.) and can't be declared twice. NS_IMETHOD GetAssociatedWindow(mozIDOMWindowProxy**) override; NS_IMETHOD GetTopWindow(mozIDOMWindowProxy**) override; NS_IMETHOD GetTopFrameElement(nsIDOMElement**) override; NS_IMETHOD GetNestedFrameId(uint64_t*) override; NS_IMETHOD GetIsContent(bool*) override; NS_IMETHOD GetUsePrivateBrowsing(bool*) override; NS_IMETHOD SetUsePrivateBrowsing(bool) override; NS_IMETHOD SetPrivateBrowsing(bool) override; NS_IMETHOD GetUseRemoteTabs(bool*) override; NS_IMETHOD SetRemoteTabs(bool) override; NS_IMETHOD GetScriptableOriginAttributes(JS::MutableHandle) override; NS_IMETHOD_(void) GetOriginAttributes(mozilla::OriginAttributes& aAttrs) override; // Restores a cached presentation from history (mLSHE). // This method swaps out the content viewer and simulates loads for // subframes. It then simulates the completion of the toplevel load. nsresult RestoreFromHistory(); // Perform a URI load from a refresh timer. This is just like the // ForceRefreshURI method on nsIRefreshURI, but makes sure to take // the timer involved out of mRefreshURIList if it's there. // aTimer must not be null. nsresult ForceRefreshURIFromTimer(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDelay, bool aMetaRefresh, nsITimer* aTimer); // We need dummy OnLocationChange in some cases to update the UI without // updating security info. void FireDummyOnLocationChange() { FireOnLocationChange(this, nullptr, mCurrentURI, LOCATION_CHANGE_SAME_DOCUMENT); } nsresult HistoryTransactionRemoved(int32_t aIndex); // Notify Scroll observers when an async panning/zooming transform // has started being applied void NotifyAsyncPanZoomStarted(); // Notify Scroll observers when an async panning/zooming transform // is no longer applied void NotifyAsyncPanZoomStopped(); void SetInFrameSwap(bool aInSwap) { mInFrameSwap = aInSwap; } bool InFrameSwap(); const mozilla::Encoding* GetForcedCharset() { return mForcedCharset; } mozilla::HTMLEditor* GetHTMLEditorInternal(); nsresult SetHTMLEditorInternal(mozilla::HTMLEditor* aHTMLEditor); nsDOMNavigationTiming* GetNavigationTiming() const; nsresult SetOriginAttributes(const mozilla::OriginAttributes& aAttrs); /** * Get the list of ancestor principals for this docshell. The list is meant * to be the list of principals of the documents this docshell is "nested * through" in the sense of * . * In practice, it is defined as follows: * * If this is an