LoadContext.h (1969B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef LoadContext_h 8 #define LoadContext_h 9 10 #include "SerializedLoadContext.h" 11 #include "mozilla/BasePrincipal.h" 12 #include "nsIWeakReferenceUtils.h" 13 #include "nsIInterfaceRequestor.h" 14 #include "nsILoadContext.h" 15 16 namespace mozilla::dom { 17 class Element; 18 } 19 20 namespace mozilla { 21 22 /** 23 * Class that provides nsILoadContext info in Parent process. Typically copied 24 * from Child via SerializedLoadContext. 25 * 26 * Note: this is not the "normal" or "original" nsILoadContext. That is 27 * typically provided by BrowsingContext. This is only used when the original 28 * docshell is in a different process and we need to copy certain values from 29 * it. 30 */ 31 32 class LoadContext final : public nsILoadContext, public nsIInterfaceRequestor { 33 public: 34 NS_DECL_ISUPPORTS 35 NS_DECL_NSILOADCONTEXT 36 NS_DECL_NSIINTERFACEREQUESTOR 37 38 LoadContext(const IPC::SerializedLoadContext& aToCopy, 39 dom::Element* aTopFrameElement, OriginAttributes& aAttrs); 40 41 // Constructor taking reserved origin attributes. 42 explicit LoadContext(OriginAttributes& aAttrs); 43 44 // Constructor for creating a LoadContext with a given browser flag. 45 explicit LoadContext(nsIPrincipal* aPrincipal, 46 nsILoadContext* aOptionalBase = nullptr); 47 48 private: 49 ~LoadContext(); 50 51 nsWeakPtr mTopFrameElement; 52 bool mIsContent; 53 bool mUseRemoteTabs; 54 bool mUseRemoteSubframes; 55 bool mUseTrackingProtection; 56 #ifdef DEBUG 57 bool mIsNotNull; 58 #endif 59 OriginAttributes mOriginAttributes; 60 }; 61 62 already_AddRefed<nsILoadContext> CreateLoadContext(); 63 already_AddRefed<nsILoadContext> CreatePrivateLoadContext(); 64 65 } // namespace mozilla 66 67 #endif // LoadContext_h