michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set sw=2 ts=8 et tw=80 : */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef LoadContext_h michael@0: #define LoadContext_h michael@0: michael@0: #include "SerializedLoadContext.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIWeakReferenceUtils.h" michael@0: #include "mozilla/dom/Element.h" michael@0: #include "nsIInterfaceRequestor.h" michael@0: #include "nsILoadContext.h" michael@0: michael@0: class mozIApplication; michael@0: michael@0: namespace mozilla { michael@0: michael@0: /** michael@0: * Class that provides nsILoadContext info in Parent process. Typically copied michael@0: * from Child via SerializedLoadContext. michael@0: * michael@0: * Note: this is not the "normal" or "original" nsILoadContext. That is michael@0: * typically provided by nsDocShell. This is only used when the original michael@0: * docshell is in a different process and we need to copy certain values from michael@0: * it. michael@0: * michael@0: * Note: we also generate a new nsILoadContext using LoadContext(uint32_t aAppId) michael@0: * to separate the safebrowsing cookie. michael@0: */ michael@0: michael@0: class LoadContext MOZ_FINAL : public nsILoadContext, michael@0: public nsIInterfaceRequestor michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSILOADCONTEXT michael@0: NS_DECL_NSIINTERFACEREQUESTOR michael@0: michael@0: // AppId/inBrowser arguments override those in SerializedLoadContext provided michael@0: // by child process. michael@0: LoadContext(const IPC::SerializedLoadContext& aToCopy, michael@0: dom::Element* aTopFrameElement, michael@0: uint32_t aAppId, bool aInBrowser) michael@0: : mTopFrameElement(do_GetWeakReference(aTopFrameElement)) michael@0: , mAppId(aAppId) michael@0: , mIsContent(aToCopy.mIsContent) michael@0: , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing) michael@0: , mUseRemoteTabs(aToCopy.mUseRemoteTabs) michael@0: , mIsInBrowserElement(aInBrowser) michael@0: #ifdef DEBUG michael@0: , mIsNotNull(aToCopy.mIsNotNull) michael@0: #endif michael@0: {} michael@0: michael@0: LoadContext(dom::Element* aTopFrameElement, michael@0: uint32_t aAppId, michael@0: bool aIsContent, michael@0: bool aUsePrivateBrowsing, michael@0: bool aUseRemoteTabs, michael@0: bool aIsInBrowserElement) michael@0: : mTopFrameElement(do_GetWeakReference(aTopFrameElement)) michael@0: , mAppId(aAppId) michael@0: , mIsContent(aIsContent) michael@0: , mUsePrivateBrowsing(aUsePrivateBrowsing) michael@0: , mUseRemoteTabs(aUseRemoteTabs) michael@0: , mIsInBrowserElement(aIsInBrowserElement) michael@0: #ifdef DEBUG michael@0: , mIsNotNull(true) michael@0: #endif michael@0: {} michael@0: michael@0: // Constructor taking reserved appId for the safebrowsing cookie. michael@0: LoadContext(uint32_t aAppId) michael@0: : mTopFrameElement(nullptr) michael@0: , mAppId(aAppId) michael@0: , mIsContent(false) michael@0: , mUsePrivateBrowsing(false) michael@0: , mUseRemoteTabs(false) michael@0: , mIsInBrowserElement(false) michael@0: #ifdef DEBUG michael@0: , mIsNotNull(true) michael@0: #endif michael@0: {} michael@0: michael@0: private: michael@0: nsWeakPtr mTopFrameElement; michael@0: uint32_t mAppId; michael@0: bool mIsContent; michael@0: bool mUsePrivateBrowsing; michael@0: bool mUseRemoteTabs; michael@0: bool mIsInBrowserElement; michael@0: #ifdef DEBUG michael@0: bool mIsNotNull; michael@0: #endif michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif // LoadContext_h michael@0: