Line data Source code
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
30 : : public PNeckoParent
31 : {
32 : public:
33 : NeckoParent();
34 : virtual ~NeckoParent();
35 :
36 : MOZ_MUST_USE
37 : static const char *
38 : GetValidatedOriginAttributes(const SerializedLoadContext& aSerialized,
39 : PContentParent* aBrowser,
40 : nsIPrincipal* aRequestingPrincipal,
41 : mozilla::OriginAttributes& aAttrs);
42 :
43 : /*
44 : * Creates LoadContext for parent-side of an e10s channel.
45 : *
46 : * PContentParent corresponds to the process that is requesting the load.
47 : *
48 : * Returns null if successful, or an error string if failed.
49 : */
50 : MOZ_MUST_USE
51 : static const char*
52 : CreateChannelLoadContext(const PBrowserOrId& aBrowser,
53 : PContentParent* aContent,
54 : const SerializedLoadContext& aSerialized,
55 : nsIPrincipal* aRequestingPrincipal,
56 : nsCOMPtr<nsILoadContext> &aResult);
57 :
58 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
59 : virtual PCookieServiceParent* AllocPCookieServiceParent() override;
60 : virtual mozilla::ipc::IPCResult
61 0 : RecvPCookieServiceConstructor(PCookieServiceParent* aActor) override
62 : {
63 0 : return PNeckoParent::RecvPCookieServiceConstructor(aActor);
64 : }
65 :
66 : /*
67 : * This implementation of nsIAuthPrompt2 is used for nested remote iframes that
68 : * want an auth prompt. This class lives in the parent process and informs the
69 : * NeckoChild that we want an auth prompt, which forwards the request to the
70 : * TabParent in the remote iframe that contains the nested iframe
71 : */
72 : class NestedFrameAuthPrompt final : public nsIAuthPrompt2
73 : {
74 0 : ~NestedFrameAuthPrompt() {}
75 :
76 : public:
77 : NS_DECL_ISUPPORTS
78 :
79 : NestedFrameAuthPrompt(PNeckoParent* aParent, TabId aNestedFrameId);
80 :
81 0 : NS_IMETHOD PromptAuth(nsIChannel*, uint32_t, nsIAuthInformation*, bool*) override
82 : {
83 0 : return NS_ERROR_NOT_IMPLEMENTED;
84 : }
85 :
86 : NS_IMETHOD AsyncPromptAuth(nsIChannel* aChannel, nsIAuthPromptCallback* callback,
87 : nsISupports*, uint32_t,
88 : nsIAuthInformation* aInfo, nsICancelable**) override;
89 :
90 : protected:
91 : PNeckoParent* mNeckoParent;
92 : TabId mNestedFrameId;
93 : };
94 :
95 : protected:
96 : virtual PHttpChannelParent*
97 : AllocPHttpChannelParent(const PBrowserOrId&, const SerializedLoadContext&,
98 : const HttpChannelCreationArgs& aOpenArgs) override;
99 : virtual mozilla::ipc::IPCResult
100 : RecvPHttpChannelConstructor(
101 : PHttpChannelParent* aActor,
102 : const PBrowserOrId& aBrowser,
103 : const SerializedLoadContext& aSerialized,
104 : const HttpChannelCreationArgs& aOpenArgs) override;
105 : virtual bool DeallocPHttpChannelParent(PHttpChannelParent*) override;
106 :
107 : virtual PStunAddrsRequestParent* AllocPStunAddrsRequestParent() override;
108 : virtual bool
109 : DeallocPStunAddrsRequestParent(PStunAddrsRequestParent* aActor) override;
110 :
111 : virtual PAltDataOutputStreamParent* AllocPAltDataOutputStreamParent(
112 : const nsCString& type, PHttpChannelParent* channel) override;
113 : virtual bool DeallocPAltDataOutputStreamParent(
114 : PAltDataOutputStreamParent* aActor) override;
115 :
116 : virtual bool DeallocPCookieServiceParent(PCookieServiceParent*) override;
117 : virtual PWyciwygChannelParent* AllocPWyciwygChannelParent() override;
118 : virtual bool DeallocPWyciwygChannelParent(PWyciwygChannelParent*) override;
119 : virtual PFTPChannelParent*
120 : AllocPFTPChannelParent(const PBrowserOrId& aBrowser,
121 : const SerializedLoadContext& aSerialized,
122 : const FTPChannelCreationArgs& aOpenArgs) override;
123 : virtual mozilla::ipc::IPCResult
124 : RecvPFTPChannelConstructor(
125 : PFTPChannelParent* aActor,
126 : const PBrowserOrId& aBrowser,
127 : const SerializedLoadContext& aSerialized,
128 : const FTPChannelCreationArgs& aOpenArgs) override;
129 : virtual bool DeallocPFTPChannelParent(PFTPChannelParent*) override;
130 : virtual PWebSocketParent*
131 : AllocPWebSocketParent(const PBrowserOrId& browser,
132 : const SerializedLoadContext& aSerialized,
133 : const uint32_t& aSerial) override;
134 : virtual bool DeallocPWebSocketParent(PWebSocketParent*) override;
135 : virtual PTCPSocketParent* AllocPTCPSocketParent(const nsString& host,
136 : const uint16_t& port) override;
137 :
138 : virtual bool DeallocPTCPSocketParent(PTCPSocketParent*) override;
139 : virtual PTCPServerSocketParent*
140 : AllocPTCPServerSocketParent(const uint16_t& aLocalPort,
141 : const uint16_t& aBacklog,
142 : const bool& aUseArrayBuffers) override;
143 : virtual mozilla::ipc::IPCResult RecvPTCPServerSocketConstructor(PTCPServerSocketParent*,
144 : const uint16_t& aLocalPort,
145 : const uint16_t& aBacklog,
146 : const bool& aUseArrayBuffers) override;
147 : virtual bool DeallocPTCPServerSocketParent(PTCPServerSocketParent*) override;
148 : virtual PUDPSocketParent* AllocPUDPSocketParent(const Principal& aPrincipal,
149 : const nsCString& aFilter) override;
150 : virtual mozilla::ipc::IPCResult RecvPUDPSocketConstructor(PUDPSocketParent*,
151 : const Principal& aPrincipal,
152 : const nsCString& aFilter) override;
153 : virtual bool DeallocPUDPSocketParent(PUDPSocketParent*) override;
154 : virtual PDNSRequestParent* AllocPDNSRequestParent(const nsCString& aHost,
155 : const OriginAttributes& aOriginAttributes,
156 : const uint32_t& aFlags,
157 : const nsCString& aNetworkInterface) override;
158 : virtual mozilla::ipc::IPCResult RecvPDNSRequestConstructor(PDNSRequestParent* actor,
159 : const nsCString& hostName,
160 : const OriginAttributes& aOriginAttributes,
161 : const uint32_t& flags,
162 : const nsCString& aNetworkInterface) override;
163 : virtual bool DeallocPDNSRequestParent(PDNSRequestParent*) override;
164 : virtual mozilla::ipc::IPCResult RecvSpeculativeConnect(const URIParams& aURI,
165 : const Principal& aPrincipal,
166 : const bool& aAnonymous) override;
167 : virtual mozilla::ipc::IPCResult RecvHTMLDNSPrefetch(const nsString& hostname,
168 : const OriginAttributes& aOriginAttributes,
169 : const uint16_t& flags) override;
170 : virtual mozilla::ipc::IPCResult RecvCancelHTMLDNSPrefetch(const nsString& hostname,
171 : const OriginAttributes& aOriginAttributes,
172 : const uint16_t& flags,
173 : const nsresult& reason) override;
174 : virtual PWebSocketEventListenerParent*
175 : AllocPWebSocketEventListenerParent(const uint64_t& aInnerWindowID) override;
176 : virtual bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent*) override;
177 :
178 : virtual PDataChannelParent*
179 : AllocPDataChannelParent(const uint32_t& channelId) override;
180 : virtual bool DeallocPDataChannelParent(PDataChannelParent* parent) override;
181 :
182 : virtual mozilla::ipc::IPCResult RecvPDataChannelConstructor(PDataChannelParent* aActor,
183 : const uint32_t& channelId) override;
184 :
185 : virtual PFileChannelParent*
186 : AllocPFileChannelParent(const uint32_t& channelId) override;
187 : virtual bool DeallocPFileChannelParent(PFileChannelParent* parent) override;
188 :
189 : virtual mozilla::ipc::IPCResult RecvPFileChannelConstructor(PFileChannelParent* aActor,
190 : const uint32_t& channelId) override;
191 :
192 : virtual PRtspControllerParent* AllocPRtspControllerParent() override;
193 : virtual bool DeallocPRtspControllerParent(PRtspControllerParent*) override;
194 :
195 : virtual PRtspChannelParent*
196 : AllocPRtspChannelParent(const RtspChannelConnectArgs& aArgs)
197 : override;
198 : virtual mozilla::ipc::IPCResult
199 : RecvPRtspChannelConstructor(PRtspChannelParent* aActor,
200 : const RtspChannelConnectArgs& aArgs)
201 : override;
202 : virtual bool DeallocPRtspChannelParent(PRtspChannelParent*) override;
203 :
204 : virtual PChannelDiverterParent*
205 : AllocPChannelDiverterParent(const ChannelDiverterArgs& channel) override;
206 : virtual mozilla::ipc::IPCResult
207 : RecvPChannelDiverterConstructor(PChannelDiverterParent* actor,
208 : const ChannelDiverterArgs& channel) override;
209 : virtual bool DeallocPChannelDiverterParent(PChannelDiverterParent* actor)
210 : override;
211 : virtual PTransportProviderParent*
212 : AllocPTransportProviderParent() override;
213 : virtual bool
214 : DeallocPTransportProviderParent(PTransportProviderParent* aActor) override;
215 :
216 : virtual mozilla::ipc::IPCResult RecvOnAuthAvailable(const uint64_t& aCallbackId,
217 : const nsString& aUser,
218 : const nsString& aPassword,
219 : const nsString& aDomain) override;
220 : virtual mozilla::ipc::IPCResult RecvOnAuthCancelled(const uint64_t& aCallbackId,
221 : const bool& aUserCancel) override;
222 :
223 : /* Predictor Messages */
224 : virtual mozilla::ipc::IPCResult RecvPredPredict(const ipc::OptionalURIParams& aTargetURI,
225 : const ipc::OptionalURIParams& aSourceURI,
226 : const PredictorPredictReason& aReason,
227 : const OriginAttributes& aOriginAttributes,
228 : const bool& hasVerifier) override;
229 :
230 : virtual mozilla::ipc::IPCResult RecvPredLearn(const ipc::URIParams& aTargetURI,
231 : const ipc::OptionalURIParams& aSourceURI,
232 : const PredictorPredictReason& aReason,
233 : const OriginAttributes& aOriginAttributes) override;
234 : virtual mozilla::ipc::IPCResult RecvPredReset() override;
235 :
236 : virtual mozilla::ipc::IPCResult RecvRemoveRequestContext(const uint64_t& rcid) override;
237 :
238 : virtual mozilla::ipc::IPCResult RecvNotifyCurrentTopLevelOuterContentWindowId(const uint64_t& aWindowId) override;
239 :
240 : /* WebExtensions */
241 : virtual mozilla::ipc::IPCResult
242 : RecvGetExtensionStream(const URIParams& aURI,
243 : const LoadInfoArgs& aLoadInfo,
244 : GetExtensionStreamResolver&& aResolve) override;
245 :
246 : virtual mozilla::ipc::IPCResult
247 : RecvGetExtensionFD(const URIParams& aURI,
248 : const OptionalLoadInfoArgs& aLoadInfo,
249 : GetExtensionFDResolver&& aResolve) override;
250 : };
251 :
252 : } // namespace net
253 : } // namespace mozilla
254 :
255 : #endif // mozilla_net_NeckoParent_h
|