NeckoParent.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/BasePrincipal.h"
  6. #include "mozilla/net/PNeckoParent.h"
  7. #include "mozilla/net/NeckoCommon.h"
  8. #include "nsIAuthPrompt2.h"
  9. #include "nsINetworkPredictor.h"
  10. #include "nsNetUtil.h"
  11. #ifndef mozilla_net_NeckoParent_h
  12. #define mozilla_net_NeckoParent_h
  13. namespace mozilla {
  14. namespace net {
  15. // Used to override channel Private Browsing status if needed.
  16. enum PBOverrideStatus {
  17. kPBOverride_Unset = 0,
  18. kPBOverride_Private,
  19. kPBOverride_NotPrivate
  20. };
  21. // Header file contents
  22. class NeckoParent
  23. : public PNeckoParent
  24. {
  25. public:
  26. NeckoParent();
  27. virtual ~NeckoParent();
  28. MOZ_MUST_USE
  29. static const char *
  30. GetValidatedOriginAttributes(const SerializedLoadContext& aSerialized,
  31. PContentParent* aBrowser,
  32. nsIPrincipal* aRequestingPrincipal,
  33. mozilla::DocShellOriginAttributes& aAttrs);
  34. /*
  35. * Creates LoadContext for parent-side of an e10s channel.
  36. *
  37. * PContentParent corresponds to the process that is requesting the load.
  38. *
  39. * Returns null if successful, or an error string if failed.
  40. */
  41. MOZ_MUST_USE
  42. static const char*
  43. CreateChannelLoadContext(const PBrowserOrId& aBrowser,
  44. PContentParent* aContent,
  45. const SerializedLoadContext& aSerialized,
  46. nsIPrincipal* aRequestingPrincipal,
  47. nsCOMPtr<nsILoadContext> &aResult);
  48. virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  49. virtual PCookieServiceParent* AllocPCookieServiceParent() override;
  50. virtual bool
  51. RecvPCookieServiceConstructor(PCookieServiceParent* aActor) override
  52. {
  53. return PNeckoParent::RecvPCookieServiceConstructor(aActor);
  54. }
  55. /*
  56. * This implementation of nsIAuthPrompt2 is used for nested remote iframes that
  57. * want an auth prompt. This class lives in the parent process and informs the
  58. * NeckoChild that we want an auth prompt, which forwards the request to the
  59. * TabParent in the remote iframe that contains the nested iframe
  60. */
  61. class NestedFrameAuthPrompt final : public nsIAuthPrompt2
  62. {
  63. ~NestedFrameAuthPrompt() {}
  64. public:
  65. NS_DECL_ISUPPORTS
  66. NestedFrameAuthPrompt(PNeckoParent* aParent, TabId aNestedFrameId);
  67. NS_IMETHOD PromptAuth(nsIChannel*, uint32_t, nsIAuthInformation*, bool*) override
  68. {
  69. return NS_ERROR_NOT_IMPLEMENTED;
  70. }
  71. NS_IMETHOD AsyncPromptAuth(nsIChannel* aChannel, nsIAuthPromptCallback* callback,
  72. nsISupports*, uint32_t,
  73. nsIAuthInformation* aInfo, nsICancelable**) override;
  74. protected:
  75. PNeckoParent* mNeckoParent;
  76. TabId mNestedFrameId;
  77. };
  78. protected:
  79. virtual PHttpChannelParent*
  80. AllocPHttpChannelParent(const PBrowserOrId&, const SerializedLoadContext&,
  81. const HttpChannelCreationArgs& aOpenArgs) override;
  82. virtual bool
  83. RecvPHttpChannelConstructor(
  84. PHttpChannelParent* aActor,
  85. const PBrowserOrId& aBrowser,
  86. const SerializedLoadContext& aSerialized,
  87. const HttpChannelCreationArgs& aOpenArgs) override;
  88. virtual bool DeallocPHttpChannelParent(PHttpChannelParent*) override;
  89. virtual PAltDataOutputStreamParent* AllocPAltDataOutputStreamParent(
  90. const nsCString& type, PHttpChannelParent* channel) override;
  91. virtual bool DeallocPAltDataOutputStreamParent(
  92. PAltDataOutputStreamParent* aActor) override;
  93. virtual bool DeallocPCookieServiceParent(PCookieServiceParent*) override;
  94. virtual PWyciwygChannelParent* AllocPWyciwygChannelParent() override;
  95. virtual bool DeallocPWyciwygChannelParent(PWyciwygChannelParent*) override;
  96. virtual PFTPChannelParent*
  97. AllocPFTPChannelParent(const PBrowserOrId& aBrowser,
  98. const SerializedLoadContext& aSerialized,
  99. const FTPChannelCreationArgs& aOpenArgs) override;
  100. virtual bool
  101. RecvPFTPChannelConstructor(
  102. PFTPChannelParent* aActor,
  103. const PBrowserOrId& aBrowser,
  104. const SerializedLoadContext& aSerialized,
  105. const FTPChannelCreationArgs& aOpenArgs) override;
  106. virtual bool DeallocPFTPChannelParent(PFTPChannelParent*) override;
  107. virtual PWebSocketParent*
  108. AllocPWebSocketParent(const PBrowserOrId& browser,
  109. const SerializedLoadContext& aSerialized,
  110. const uint32_t& aSerial) override;
  111. virtual bool DeallocPWebSocketParent(PWebSocketParent*) override;
  112. virtual PTCPSocketParent* AllocPTCPSocketParent(const nsString& host,
  113. const uint16_t& port) override;
  114. virtual bool DeallocPTCPSocketParent(PTCPSocketParent*) override;
  115. virtual PTCPServerSocketParent*
  116. AllocPTCPServerSocketParent(const uint16_t& aLocalPort,
  117. const uint16_t& aBacklog,
  118. const bool& aUseArrayBuffers) override;
  119. virtual bool RecvPTCPServerSocketConstructor(PTCPServerSocketParent*,
  120. const uint16_t& aLocalPort,
  121. const uint16_t& aBacklog,
  122. const bool& aUseArrayBuffers) override;
  123. virtual bool DeallocPTCPServerSocketParent(PTCPServerSocketParent*) override;
  124. virtual PUDPSocketParent* AllocPUDPSocketParent(const Principal& aPrincipal,
  125. const nsCString& aFilter) override;
  126. virtual bool RecvPUDPSocketConstructor(PUDPSocketParent*,
  127. const Principal& aPrincipal,
  128. const nsCString& aFilter) override;
  129. virtual bool DeallocPUDPSocketParent(PUDPSocketParent*) override;
  130. virtual PDNSRequestParent* AllocPDNSRequestParent(const nsCString& aHost,
  131. const uint32_t& aFlags,
  132. const nsCString& aNetworkInterface) override;
  133. virtual bool RecvPDNSRequestConstructor(PDNSRequestParent* actor,
  134. const nsCString& hostName,
  135. const uint32_t& flags,
  136. const nsCString& aNetworkInterface) override;
  137. virtual bool DeallocPDNSRequestParent(PDNSRequestParent*) override;
  138. virtual bool RecvSpeculativeConnect(const URIParams& aURI,
  139. const Principal& aPrincipal,
  140. const bool& aAnonymous) override;
  141. virtual bool RecvHTMLDNSPrefetch(const nsString& hostname,
  142. const uint16_t& flags) override;
  143. virtual bool RecvCancelHTMLDNSPrefetch(const nsString& hostname,
  144. const uint16_t& flags,
  145. const nsresult& reason) override;
  146. virtual PWebSocketEventListenerParent*
  147. AllocPWebSocketEventListenerParent(const uint64_t& aInnerWindowID) override;
  148. virtual bool DeallocPWebSocketEventListenerParent(PWebSocketEventListenerParent*) override;
  149. virtual PDataChannelParent*
  150. AllocPDataChannelParent(const uint32_t& channelId) override;
  151. virtual bool DeallocPDataChannelParent(PDataChannelParent* parent) override;
  152. virtual bool RecvPDataChannelConstructor(PDataChannelParent* aActor,
  153. const uint32_t& channelId) override;
  154. virtual PRtspControllerParent* AllocPRtspControllerParent() override;
  155. virtual bool DeallocPRtspControllerParent(PRtspControllerParent*) override;
  156. virtual PRtspChannelParent*
  157. AllocPRtspChannelParent(const RtspChannelConnectArgs& aArgs)
  158. override;
  159. virtual bool
  160. RecvPRtspChannelConstructor(PRtspChannelParent* aActor,
  161. const RtspChannelConnectArgs& aArgs)
  162. override;
  163. virtual bool DeallocPRtspChannelParent(PRtspChannelParent*) override;
  164. virtual PChannelDiverterParent*
  165. AllocPChannelDiverterParent(const ChannelDiverterArgs& channel) override;
  166. virtual bool
  167. RecvPChannelDiverterConstructor(PChannelDiverterParent* actor,
  168. const ChannelDiverterArgs& channel) override;
  169. virtual bool DeallocPChannelDiverterParent(PChannelDiverterParent* actor)
  170. override;
  171. virtual PTransportProviderParent*
  172. AllocPTransportProviderParent() override;
  173. virtual bool
  174. DeallocPTransportProviderParent(PTransportProviderParent* aActor) override;
  175. virtual bool RecvOnAuthAvailable(const uint64_t& aCallbackId,
  176. const nsString& aUser,
  177. const nsString& aPassword,
  178. const nsString& aDomain) override;
  179. virtual bool RecvOnAuthCancelled(const uint64_t& aCallbackId,
  180. const bool& aUserCancel) override;
  181. /* Predictor Messages */
  182. virtual bool RecvPredPredict(const ipc::OptionalURIParams& aTargetURI,
  183. const ipc::OptionalURIParams& aSourceURI,
  184. const PredictorPredictReason& aReason,
  185. const IPC::SerializedLoadContext& aLoadContext,
  186. const bool& hasVerifier) override;
  187. virtual bool RecvPredLearn(const ipc::URIParams& aTargetURI,
  188. const ipc::OptionalURIParams& aSourceURI,
  189. const PredictorPredictReason& aReason,
  190. const IPC::SerializedLoadContext& aLoadContext) override;
  191. virtual bool RecvPredReset() override;
  192. virtual bool RecvRemoveRequestContext(const nsCString& rcid) override;
  193. };
  194. } // namespace net
  195. } // namespace mozilla
  196. #endif // mozilla_net_NeckoParent_h