1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 ts=8 et tw=80 : */ 3 4 /* This Source Code Form is subject to the terms of the Mozilla Public 5 * License, v. 2.0. If a copy of the MPL was not distributed with this 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 8 #include "mozilla/BasePrincipal.h" 9 #include "mozilla/net/PNeckoParent.h" 10 #include "mozilla/net/NeckoCommon.h" 11 #include "nsIAuthPrompt2.h" 12 #include "nsINetworkPredictor.h" 13 #include "nsNetUtil.h" 14 15 #ifndef mozilla_net_NeckoParent_h 16 # define mozilla_net_NeckoParent_h 17 18 namespace mozilla { 19 namespace net { 20 21 // Used to override channel Private Browsing status if needed. 22 enum PBOverrideStatus { 23 kPBOverride_Unset = 0, 24 kPBOverride_Private, 25 kPBOverride_NotPrivate 26 }; 27 28 // Header file contents 29 class NeckoParent : public PNeckoParent { 30 friend class PNeckoParent; 31 32 public: 33 NeckoParent(); 34 virtual ~NeckoParent() = default; 35 36 [[nodiscard]] static const char* GetValidatedOriginAttributes( 37 const SerializedLoadContext& aSerialized, PContentParent* aBrowser, 38 nsIPrincipal* aRequestingPrincipal, mozilla::OriginAttributes& aAttrs); 39 40 /* 41 * Creates LoadContext for parent-side of an e10s channel. 42 * 43 * PContentParent corresponds to the process that is requesting the load. 44 * 45 * Returns null if successful, or an error string if failed. 46 */ 47 [[nodiscard]] static const char* CreateChannelLoadContext( 48 PBrowserParent* aBrowser, PContentParent* aContent, 49 const SerializedLoadContext& aSerialized, 50 nsIPrincipal* aRequestingPrincipal, nsCOMPtr<nsILoadContext>& aResult); 51 52 virtual void ActorDestroy(ActorDestroyReason aWhy) override; 53 PCookieServiceParent* AllocPCookieServiceParent(); RecvPCookieServiceConstructor(PCookieServiceParent * aActor)54 virtual mozilla::ipc::IPCResult RecvPCookieServiceConstructor( 55 PCookieServiceParent* aActor) override { 56 return PNeckoParent::RecvPCookieServiceConstructor(aActor); 57 } 58 59 protected: 60 bool mSocketProcessBridgeInited; 61 62 already_AddRefed<PHttpChannelParent> AllocPHttpChannelParent( 63 PBrowserParent*, const SerializedLoadContext&, 64 const HttpChannelCreationArgs& aOpenArgs); 65 virtual mozilla::ipc::IPCResult RecvPHttpChannelConstructor( 66 PHttpChannelParent* aActor, PBrowserParent* aBrowser, 67 const SerializedLoadContext& aSerialized, 68 const HttpChannelCreationArgs& aOpenArgs) override; 69 70 PStunAddrsRequestParent* AllocPStunAddrsRequestParent(); 71 bool DeallocPStunAddrsRequestParent(PStunAddrsRequestParent* aActor); 72 73 PWebrtcTCPSocketParent* AllocPWebrtcTCPSocketParent( 74 const Maybe<TabId>& aTabId); 75 bool DeallocPWebrtcTCPSocketParent(PWebrtcTCPSocketParent* aActor); 76 77 PAltDataOutputStreamParent* AllocPAltDataOutputStreamParent( 78 const nsCString& type, const int64_t& predictedSize, 79 PHttpChannelParent* channel); 80 bool DeallocPAltDataOutputStreamParent(PAltDataOutputStreamParent* aActor); 81 82 bool DeallocPCookieServiceParent(PCookieServiceParent*); 83 PWebSocketParent* AllocPWebSocketParent( 84 PBrowserParent* browser, const SerializedLoadContext& aSerialized, 85 const uint32_t& aSerial); 86 bool DeallocPWebSocketParent(PWebSocketParent*); 87 PTCPSocketParent* AllocPTCPSocketParent(const nsString& host, 88 const uint16_t& port); 89 90 already_AddRefed<PDocumentChannelParent> AllocPDocumentChannelParent( 91 const dom::MaybeDiscarded<dom::BrowsingContext>& aContext, 92 const DocumentChannelCreationArgs& args); 93 virtual mozilla::ipc::IPCResult RecvPDocumentChannelConstructor( 94 PDocumentChannelParent* aActor, 95 const dom::MaybeDiscarded<dom::BrowsingContext>& aContext, 96 const DocumentChannelCreationArgs& aArgs) override; 97 bool DeallocPDocumentChannelParent(PDocumentChannelParent* channel); 98 99 bool DeallocPTCPSocketParent(PTCPSocketParent*); 100 PTCPServerSocketParent* AllocPTCPServerSocketParent( 101 const uint16_t& aLocalPort, const uint16_t& aBacklog, 102 const bool& aUseArrayBuffers); 103 virtual mozilla::ipc::IPCResult RecvPTCPServerSocketConstructor( 104 PTCPServerSocketParent*, const uint16_t& aLocalPort, 105 const uint16_t& aBacklog, const bool& aUseArrayBuffers) override; 106 bool DeallocPTCPServerSocketParent(PTCPServerSocketParent*); 107 PUDPSocketParent* AllocPUDPSocketParent(nsIPrincipal* aPrincipal, 108 const nsCString& aFilter); 109 virtual mozilla::ipc::IPCResult RecvPUDPSocketConstructor( 110 PUDPSocketParent*, nsIPrincipal* aPrincipal, 111 const nsCString& aFilter) override; 112 bool DeallocPUDPSocketParent(PUDPSocketParent*); 113 already_AddRefed<PDNSRequestParent> AllocPDNSRequestParent( 114 const nsCString& aHost, const nsCString& aTrrServer, 115 const uint16_t& aType, const OriginAttributes& aOriginAttributes, 116 const uint32_t& aFlags); 117 virtual mozilla::ipc::IPCResult RecvPDNSRequestConstructor( 118 PDNSRequestParent* actor, const nsCString& aHost, 119 const nsCString& trrServer, const uint16_t& type, 120 const OriginAttributes& aOriginAttributes, 121 const uint32_t& flags) override; 122 mozilla::ipc::IPCResult RecvSpeculativeConnect(nsIURI* aURI, 123 nsIPrincipal* aPrincipal, 124 const bool& aAnonymous); 125 mozilla::ipc::IPCResult RecvHTMLDNSPrefetch( 126 const nsString& hostname, const bool& isHttps, 127 const OriginAttributes& aOriginAttributes, const uint32_t& flags); 128 mozilla::ipc::IPCResult RecvCancelHTMLDNSPrefetch( 129 const nsString& hostname, const bool& isHttps, 130 const OriginAttributes& aOriginAttributes, const uint32_t& flags, 131 const nsresult& reason); 132 PWebSocketEventListenerParent* AllocPWebSocketEventListenerParent( 133 const uint64_t& aInnerWindowID); 134 bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent*); 135 136 already_AddRefed<PDataChannelParent> AllocPDataChannelParent( 137 const uint32_t& channelId); 138 139 virtual mozilla::ipc::IPCResult RecvPDataChannelConstructor( 140 PDataChannelParent* aActor, const uint32_t& channelId) override; 141 # ifdef MOZ_WIDGET_GTK 142 PGIOChannelParent* AllocPGIOChannelParent( 143 PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, 144 const GIOChannelCreationArgs& aOpenArgs); 145 bool DeallocPGIOChannelParent(PGIOChannelParent* channel); 146 147 virtual mozilla::ipc::IPCResult RecvPGIOChannelConstructor( 148 PGIOChannelParent* aActor, PBrowserParent* aBrowser, 149 const SerializedLoadContext& aSerialized, 150 const GIOChannelCreationArgs& aOpenArgs) override; 151 # endif 152 PSimpleChannelParent* AllocPSimpleChannelParent(const uint32_t& channelId); 153 bool DeallocPSimpleChannelParent(PSimpleChannelParent* actor); 154 155 virtual mozilla::ipc::IPCResult RecvPSimpleChannelConstructor( 156 PSimpleChannelParent* aActor, const uint32_t& channelId) override; 157 158 already_AddRefed<PFileChannelParent> AllocPFileChannelParent( 159 const uint32_t& channelId); 160 161 virtual mozilla::ipc::IPCResult RecvPFileChannelConstructor( 162 PFileChannelParent* aActor, const uint32_t& channelId) override; 163 164 PTransportProviderParent* AllocPTransportProviderParent(); 165 bool DeallocPTransportProviderParent(PTransportProviderParent* aActor); 166 167 /* Predictor Messages */ 168 mozilla::ipc::IPCResult RecvPredPredict( 169 nsIURI* aTargetURI, nsIURI* aSourceURI, 170 const PredictorPredictReason& aReason, 171 const OriginAttributes& aOriginAttributes, const bool& hasVerifier); 172 173 mozilla::ipc::IPCResult RecvPredLearn( 174 nsIURI* aTargetURI, nsIURI* aSourceURI, 175 const PredictorPredictReason& aReason, 176 const OriginAttributes& aOriginAttributes); 177 mozilla::ipc::IPCResult RecvPredReset(); 178 179 mozilla::ipc::IPCResult RecvRequestContextLoadBegin(const uint64_t& rcid); 180 mozilla::ipc::IPCResult RecvRequestContextAfterDOMContentLoaded( 181 const uint64_t& rcid); 182 mozilla::ipc::IPCResult RecvRemoveRequestContext(const uint64_t& rcid); 183 184 /* WebExtensions */ 185 mozilla::ipc::IPCResult RecvGetExtensionStream( 186 nsIURI* aURI, GetExtensionStreamResolver&& aResolve); 187 188 mozilla::ipc::IPCResult RecvGetExtensionFD(nsIURI* aURI, 189 GetExtensionFDResolver&& aResolve); 190 191 /* Page thumbnails remote resource loading */ 192 mozilla::ipc::IPCResult RecvGetPageThumbStream( 193 nsIURI* aURI, GetPageThumbStreamResolver&& aResolve); 194 195 PClassifierDummyChannelParent* AllocPClassifierDummyChannelParent( 196 nsIURI* aURI, nsIURI* aTopWindowURI, const nsresult& aTopWindowURIResult, 197 const Maybe<LoadInfoArgs>& aLoadInfo); 198 199 bool DeallocPClassifierDummyChannelParent( 200 PClassifierDummyChannelParent* aActor); 201 202 virtual mozilla::ipc::IPCResult RecvPClassifierDummyChannelConstructor( 203 PClassifierDummyChannelParent* aActor, nsIURI* aURI, 204 nsIURI* aTopWindowURI, const nsresult& aTopWindowURIResult, 205 const Maybe<LoadInfoArgs>& aLoadInfo) override; 206 207 mozilla::ipc::IPCResult RecvInitSocketProcessBridge( 208 InitSocketProcessBridgeResolver&& aResolver); 209 mozilla::ipc::IPCResult RecvResetSocketProcessBridge(); 210 211 mozilla::ipc::IPCResult RecvEnsureHSTSData( 212 EnsureHSTSDataResolver&& aResolver); 213 }; 214 215 } // namespace net 216 } // namespace mozilla 217 218 #endif // mozilla_net_NeckoParent_h 219