Bug 1526591 - Remove devtools.inspector.shapesHighlighter.enabled pref. r=rcaliman
[gecko.git] / netwerk / base / nsSecCheckWrapChannel.h
blob17aecab938d250f22702258d500f1fe18aa7d5b8
1 /* -*- Mode: C++; tab-width: 2; 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/. */
6 #ifndef nsSecCheckWrapChannel_h__
7 #define nsSecCheckWrapChannel_h__
9 #include "nsIHttpChannel.h"
10 #include "nsIHttpChannelInternal.h"
11 #include "nsIUploadChannel.h"
12 #include "nsIUploadChannel2.h"
13 #include "nsISecCheckWrapChannel.h"
14 #include "nsIWyciwygChannel.h"
15 #include "mozilla/LoadInfo.h"
17 namespace mozilla {
18 namespace net {
21 * The nsSecCheckWrapChannelBase wraps channels that do *not*
22 * * provide a newChannel2() implementation
23 * * provide get/setLoadInfo functions
25 * In order to perform security checks for channels
26 * a) before opening the channel, and
27 * b) after redirects
28 * we are attaching a loadinfo object to every channel which
29 * provides information about the content-type of the channel,
30 * who initiated the load, etc.
32 * Addon created channels might *not* provide that loadInfo object for
33 * some transition time before we mark the NewChannel-API as deprecated.
34 * We do not want to break those addons hence we wrap such channels
35 * using the provided wrapper in this class.
37 * Please note that the wrapper only forwards calls for
38 * * nsIRequest
39 * * nsIChannel
40 * * nsIHttpChannel
41 * * nsIHttpChannelInternal
42 * * nsIUploadChannel
43 * * nsIUploadChannel2
45 * In case any addon needs to query the inner channel this class
46 * provides a readonly function to query the wrapped channel.
50 class nsSecCheckWrapChannelBase : public nsIHttpChannel,
51 public nsIHttpChannelInternal,
52 public nsISecCheckWrapChannel,
53 public nsIUploadChannel,
54 public nsIUploadChannel2 {
55 public:
56 NS_FORWARD_NSIHTTPCHANNEL(mHttpChannel->)
57 NS_FORWARD_NSIHTTPCHANNELINTERNAL(mHttpChannelInternal->)
58 NS_FORWARD_NSICHANNEL(mChannel->)
59 NS_FORWARD_NSIREQUEST(mRequest->)
60 NS_FORWARD_NSIUPLOADCHANNEL(mUploadChannel->)
61 NS_FORWARD_NSIUPLOADCHANNEL2(mUploadChannel2->)
62 NS_DECL_NSISECCHECKWRAPCHANNEL
63 NS_DECL_ISUPPORTS
65 explicit nsSecCheckWrapChannelBase(nsIChannel* aChannel);
67 protected:
68 virtual ~nsSecCheckWrapChannelBase() = default;
70 nsCOMPtr<nsIChannel> mChannel;
71 // We do a QI in the constructor to set the following pointers.
72 nsCOMPtr<nsIHttpChannel> mHttpChannel;
73 nsCOMPtr<nsIHttpChannelInternal> mHttpChannelInternal;
74 nsCOMPtr<nsIRequest> mRequest;
75 nsCOMPtr<nsIUploadChannel> mUploadChannel;
76 nsCOMPtr<nsIUploadChannel2> mUploadChannel2;
79 /* We define a separate class here to make it clear that we're overriding
80 * Get/SetLoadInfo as well as AsyncOpen2() and Open2(), rather that using
81 * the forwarded implementations provided by NS_FORWARD_NSICHANNEL"
83 class nsSecCheckWrapChannel : public nsSecCheckWrapChannelBase {
84 public:
85 NS_IMETHOD GetLoadInfo(nsILoadInfo** aLoadInfo) override;
86 NS_IMETHOD SetLoadInfo(nsILoadInfo* aLoadInfo) override;
88 NS_IMETHOD AsyncOpen2(nsIStreamListener* aListener) override;
89 NS_IMETHOD Open2(nsIInputStream** aStream) override;
91 nsSecCheckWrapChannel(nsIChannel* aChannel, nsILoadInfo* aLoadInfo);
92 static already_AddRefed<nsIChannel> MaybeWrap(nsIChannel* aChannel,
93 nsILoadInfo* aLoadInfo);
95 protected:
96 virtual ~nsSecCheckWrapChannel() = default;
98 nsCOMPtr<nsILoadInfo> mLoadInfo;
101 } // namespace net
102 } // namespace mozilla
104 #endif // nsSecCheckWrapChannel_h__