content/base/src/nsCrossSiteListenerProxy.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:5b5bdbed0bc2
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/. */
5
6 #ifndef nsCORSListenerProxy_h__
7 #define nsCORSListenerProxy_h__
8
9 #include "nsIStreamListener.h"
10 #include "nsIInterfaceRequestor.h"
11 #include "nsCOMPtr.h"
12 #include "nsString.h"
13 #include "nsIURI.h"
14 #include "nsTArray.h"
15 #include "nsIInterfaceRequestor.h"
16 #include "nsIChannelEventSink.h"
17 #include "nsIAsyncVerifyRedirectCallback.h"
18 #include "mozilla/Attributes.h"
19
20 class nsIURI;
21 class nsIParser;
22 class nsIPrincipal;
23
24 extern bool
25 IsValidHTTPToken(const nsCSubstring& aToken);
26
27 nsresult
28 NS_StartCORSPreflight(nsIChannel* aRequestChannel,
29 nsIStreamListener* aListener,
30 nsIPrincipal* aPrincipal,
31 bool aWithCredentials,
32 nsTArray<nsCString>& aACUnsafeHeaders,
33 nsIChannel** aPreflightChannel);
34
35 class nsCORSListenerProxy MOZ_FINAL : public nsIStreamListener,
36 public nsIInterfaceRequestor,
37 public nsIChannelEventSink,
38 public nsIAsyncVerifyRedirectCallback
39 {
40 public:
41 nsCORSListenerProxy(nsIStreamListener* aOuter,
42 nsIPrincipal* aRequestingPrincipal,
43 bool aWithCredentials);
44 nsCORSListenerProxy(nsIStreamListener* aOuter,
45 nsIPrincipal* aRequestingPrincipal,
46 bool aWithCredentials,
47 const nsCString& aPreflightMethod,
48 const nsTArray<nsCString>& aPreflightHeaders);
49
50 NS_DECL_ISUPPORTS
51 NS_DECL_NSIREQUESTOBSERVER
52 NS_DECL_NSISTREAMLISTENER
53 NS_DECL_NSIINTERFACEREQUESTOR
54 NS_DECL_NSICHANNELEVENTSINK
55 NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
56
57 // Must be called at startup.
58 static void Startup();
59
60 static void Shutdown();
61
62 nsresult Init(nsIChannel* aChannel, bool aAllowDataURI = false);
63
64 private:
65 nsresult UpdateChannel(nsIChannel* aChannel, bool aAllowDataURI = false);
66 nsresult CheckRequestApproved(nsIRequest* aRequest);
67
68 nsCOMPtr<nsIStreamListener> mOuterListener;
69 // The principal that originally kicked off the request
70 nsCOMPtr<nsIPrincipal> mRequestingPrincipal;
71 // The principal to use for our Origin header ("source origin" in spec terms).
72 // This can get changed during redirects, unlike mRequestingPrincipal.
73 nsCOMPtr<nsIPrincipal> mOriginHeaderPrincipal;
74 nsCOMPtr<nsIInterfaceRequestor> mOuterNotificationCallbacks;
75 bool mWithCredentials;
76 bool mRequestApproved;
77 bool mHasBeenCrossSite;
78 bool mIsPreflight;
79 nsCString mPreflightMethod;
80 nsTArray<nsCString> mPreflightHeaders;
81 nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
82 nsCOMPtr<nsIChannel> mOldRedirectChannel;
83 nsCOMPtr<nsIChannel> mNewRedirectChannel;
84 };
85
86 #endif

mercurial