/src/mozilla-central/uriloader/exthandler/ExternalHelperAppParent.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include "mozilla/dom/PExternalHelperAppParent.h" |
8 | | #include "nsIChannel.h" |
9 | | #include "nsIMultiPartChannel.h" |
10 | | #include "nsIResumableChannel.h" |
11 | | #include "nsIStreamListener.h" |
12 | | #include "nsHashPropertyBag.h" |
13 | | #include "PrivateBrowsingChannel.h" |
14 | | |
15 | | namespace IPC { |
16 | | class URI; |
17 | | } // namespace IPC |
18 | | |
19 | | namespace mozilla { |
20 | | |
21 | | namespace ipc { |
22 | | class OptionalURIParams; |
23 | | } // namespace ipc |
24 | | |
25 | | namespace net { |
26 | | class PChannelDiverterParent; |
27 | | } // namespace net |
28 | | |
29 | | namespace dom { |
30 | | |
31 | | #define NS_IEXTERNALHELPERAPPPARENT_IID \ |
32 | | { 0x127a01bc, 0x2a49, 0x46a8, \ |
33 | | { 0x8c, 0x63, 0x4b, 0x5d, 0x3c, 0xa4, 0x07, 0x9c } } |
34 | | |
35 | | class nsIExternalHelperAppParent : public nsISupports |
36 | | { |
37 | | public: |
38 | | NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEXTERNALHELPERAPPPARENT_IID) |
39 | | |
40 | | /** |
41 | | * Returns true if this fake channel represented a file channel in the child. |
42 | | */ |
43 | | virtual bool WasFileChannel() = 0; |
44 | | }; |
45 | | |
46 | | NS_DEFINE_STATIC_IID_ACCESSOR(nsIExternalHelperAppParent, NS_IEXTERNALHELPERAPPPARENT_IID) |
47 | | |
48 | | class ContentParent; |
49 | | class PBrowserParent; |
50 | | |
51 | | class ExternalHelperAppParent : public PExternalHelperAppParent |
52 | | , public nsHashPropertyBag |
53 | | , public nsIChannel |
54 | | , public nsIMultiPartChannel |
55 | | , public nsIResumableChannel |
56 | | , public nsIStreamListener |
57 | | , public net::PrivateBrowsingChannel<ExternalHelperAppParent> |
58 | | , public nsIExternalHelperAppParent |
59 | | { |
60 | | typedef mozilla::ipc::OptionalURIParams OptionalURIParams; |
61 | | |
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 |
70 | | |
71 | | mozilla::ipc::IPCResult RecvOnStartRequest(const nsCString& entityID, |
72 | | PBrowserParent* aBrowser) 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; |
77 | | |
78 | | mozilla::ipc::IPCResult RecvDivertToParentUsing(PChannelDiverterParent* diverter, |
79 | | PBrowserParent* aBrowser) override; |
80 | | |
81 | 0 | bool WasFileChannel() override { |
82 | 0 | return mWasFileChannel; |
83 | 0 | } |
84 | | |
85 | | ExternalHelperAppParent(const OptionalURIParams& uri, const int64_t& contentLength, |
86 | | const bool& wasFileChannel, |
87 | | const nsCString& aContentDispositionHeader, |
88 | | const uint32_t& aContentDispositionHint, |
89 | | const nsString& aContentDispositionFilename); |
90 | | void Init(ContentParent *parent, |
91 | | const nsCString& aMimeContentType, |
92 | | const bool& aForceSave, |
93 | | const OptionalURIParams& aReferrer, |
94 | | PBrowserParent* aBrowser); |
95 | | |
96 | | protected: |
97 | | virtual ~ExternalHelperAppParent(); |
98 | | |
99 | | virtual void ActorDestroy(ActorDestroyReason why) override; |
100 | | void Delete(); |
101 | | |
102 | | private: |
103 | | nsCOMPtr<nsIStreamListener> mListener; |
104 | | nsCOMPtr<nsIURI> mURI; |
105 | | bool mPending; |
106 | | #ifdef DEBUG |
107 | | bool mDiverted; |
108 | | #endif |
109 | | bool mIPCClosed; |
110 | | nsLoadFlags mLoadFlags; |
111 | | nsresult mStatus; |
112 | | int64_t mContentLength; |
113 | | bool mWasFileChannel; |
114 | | uint32_t mContentDisposition; |
115 | | nsString mContentDispositionFilename; |
116 | | nsCString mContentDispositionHeader; |
117 | | nsCString mEntityID; |
118 | | }; |
119 | | |
120 | | } // namespace dom |
121 | | } // namespace mozilla |