Bug 1728955: part 8) Refactor `DisplayErrCode` in Windows' `nsClipboard`. r=masayuki
[gecko.git] / uriloader / exthandler / ExternalHelperAppParent.h
blob71ac04cee8fde86b2279a40be073c92cee695e0e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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/. */
7 #include "mozilla/dom/PExternalHelperAppParent.h"
8 #include "mozilla/ipc/BackgroundUtils.h"
9 #include "nsIChannel.h"
10 #include "nsIMultiPartChannel.h"
11 #include "nsIResumableChannel.h"
12 #include "nsIStreamListener.h"
13 #include "nsHashPropertyBag.h"
14 #include "mozilla/net/PrivateBrowsingChannel.h"
16 namespace IPC {
17 class URI;
18 } // namespace IPC
20 class nsExternalAppHandler;
22 namespace mozilla {
24 namespace net {
25 class PChannelDiverterParent;
26 } // namespace net
28 namespace dom {
30 #define NS_IEXTERNALHELPERAPPPARENT_IID \
31 { \
32 0x127a01bc, 0x2a49, 0x46a8, { \
33 0x8c, 0x63, 0x4b, 0x5d, 0x3c, 0xa4, 0x07, 0x9c \
34 } \
37 class nsIExternalHelperAppParent : public nsISupports {
38 public:
39 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEXTERNALHELPERAPPPARENT_IID)
41 /**
42 * Returns true if this fake channel represented a file channel in the child.
44 virtual bool WasFileChannel() = 0;
47 NS_DEFINE_STATIC_IID_ACCESSOR(nsIExternalHelperAppParent,
48 NS_IEXTERNALHELPERAPPPARENT_IID)
50 class ContentParent;
51 class PBrowserParent;
53 class ExternalHelperAppParent
54 : public PExternalHelperAppParent,
55 public nsHashPropertyBag,
56 public nsIChannel,
57 public nsIMultiPartChannel,
58 public nsIResumableChannel,
59 public nsIStreamListener,
60 public net::PrivateBrowsingChannel<ExternalHelperAppParent>,
61 public nsIExternalHelperAppParent {
62 public:
63 NS_DECL_ISUPPORTS_INHERITED
64 NS_DECL_NSIREQUEST
65 NS_DECL_NSICHANNEL
66 NS_DECL_NSIMULTIPARTCHANNEL
67 NS_DECL_NSIRESUMABLECHANNEL
68 NS_DECL_NSISTREAMLISTENER
69 NS_DECL_NSIREQUESTOBSERVER
71 mozilla::ipc::IPCResult RecvOnStartRequest(
72 const nsCString& entityID) override;
73 mozilla::ipc::IPCResult RecvOnDataAvailable(const nsCString& data,
74 const uint64_t& offset,
75 const uint32_t& count) override;
76 mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& code) override;
78 bool WasFileChannel() override { return mWasFileChannel; }
80 ExternalHelperAppParent(nsIURI* uri, const int64_t& contentLength,
81 const bool& wasFileChannel,
82 const nsCString& aContentDispositionHeader,
83 const uint32_t& aContentDispositionHint,
84 const nsString& aContentDispositionFilename);
85 void Init(const Maybe<mozilla::net::LoadInfoArgs>& aLoadInfoArgs,
86 const nsCString& aMimeContentType, const bool& aForceSave,
87 nsIURI* aReferrer, BrowsingContext* aContext,
88 const bool& aShouldCloseWindow);
90 protected:
91 virtual ~ExternalHelperAppParent();
93 virtual void ActorDestroy(ActorDestroyReason why) override;
94 void Delete();
96 private:
97 RefPtr<nsIStreamListener> mListener;
98 nsCOMPtr<nsIURI> mURI;
99 nsCOMPtr<nsILoadInfo> mLoadInfo;
100 bool mPending;
101 bool mIPCClosed;
102 nsLoadFlags mLoadFlags;
103 nsresult mStatus;
104 bool mCanceled;
105 int64_t mContentLength;
106 bool mWasFileChannel;
107 uint32_t mContentDisposition;
108 nsString mContentDispositionFilename;
109 nsCString mContentDispositionHeader;
110 nsCString mEntityID;
113 } // namespace dom
114 } // namespace mozilla