content/base/src/nsCrossSiteListenerProxy.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsCORSListenerProxy_h__
michael@0 7 #define nsCORSListenerProxy_h__
michael@0 8
michael@0 9 #include "nsIStreamListener.h"
michael@0 10 #include "nsIInterfaceRequestor.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsString.h"
michael@0 13 #include "nsIURI.h"
michael@0 14 #include "nsTArray.h"
michael@0 15 #include "nsIInterfaceRequestor.h"
michael@0 16 #include "nsIChannelEventSink.h"
michael@0 17 #include "nsIAsyncVerifyRedirectCallback.h"
michael@0 18 #include "mozilla/Attributes.h"
michael@0 19
michael@0 20 class nsIURI;
michael@0 21 class nsIParser;
michael@0 22 class nsIPrincipal;
michael@0 23
michael@0 24 extern bool
michael@0 25 IsValidHTTPToken(const nsCSubstring& aToken);
michael@0 26
michael@0 27 nsresult
michael@0 28 NS_StartCORSPreflight(nsIChannel* aRequestChannel,
michael@0 29 nsIStreamListener* aListener,
michael@0 30 nsIPrincipal* aPrincipal,
michael@0 31 bool aWithCredentials,
michael@0 32 nsTArray<nsCString>& aACUnsafeHeaders,
michael@0 33 nsIChannel** aPreflightChannel);
michael@0 34
michael@0 35 class nsCORSListenerProxy MOZ_FINAL : public nsIStreamListener,
michael@0 36 public nsIInterfaceRequestor,
michael@0 37 public nsIChannelEventSink,
michael@0 38 public nsIAsyncVerifyRedirectCallback
michael@0 39 {
michael@0 40 public:
michael@0 41 nsCORSListenerProxy(nsIStreamListener* aOuter,
michael@0 42 nsIPrincipal* aRequestingPrincipal,
michael@0 43 bool aWithCredentials);
michael@0 44 nsCORSListenerProxy(nsIStreamListener* aOuter,
michael@0 45 nsIPrincipal* aRequestingPrincipal,
michael@0 46 bool aWithCredentials,
michael@0 47 const nsCString& aPreflightMethod,
michael@0 48 const nsTArray<nsCString>& aPreflightHeaders);
michael@0 49
michael@0 50 NS_DECL_ISUPPORTS
michael@0 51 NS_DECL_NSIREQUESTOBSERVER
michael@0 52 NS_DECL_NSISTREAMLISTENER
michael@0 53 NS_DECL_NSIINTERFACEREQUESTOR
michael@0 54 NS_DECL_NSICHANNELEVENTSINK
michael@0 55 NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
michael@0 56
michael@0 57 // Must be called at startup.
michael@0 58 static void Startup();
michael@0 59
michael@0 60 static void Shutdown();
michael@0 61
michael@0 62 nsresult Init(nsIChannel* aChannel, bool aAllowDataURI = false);
michael@0 63
michael@0 64 private:
michael@0 65 nsresult UpdateChannel(nsIChannel* aChannel, bool aAllowDataURI = false);
michael@0 66 nsresult CheckRequestApproved(nsIRequest* aRequest);
michael@0 67
michael@0 68 nsCOMPtr<nsIStreamListener> mOuterListener;
michael@0 69 // The principal that originally kicked off the request
michael@0 70 nsCOMPtr<nsIPrincipal> mRequestingPrincipal;
michael@0 71 // The principal to use for our Origin header ("source origin" in spec terms).
michael@0 72 // This can get changed during redirects, unlike mRequestingPrincipal.
michael@0 73 nsCOMPtr<nsIPrincipal> mOriginHeaderPrincipal;
michael@0 74 nsCOMPtr<nsIInterfaceRequestor> mOuterNotificationCallbacks;
michael@0 75 bool mWithCredentials;
michael@0 76 bool mRequestApproved;
michael@0 77 bool mHasBeenCrossSite;
michael@0 78 bool mIsPreflight;
michael@0 79 nsCString mPreflightMethod;
michael@0 80 nsTArray<nsCString> mPreflightHeaders;
michael@0 81 nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
michael@0 82 nsCOMPtr<nsIChannel> mOldRedirectChannel;
michael@0 83 nsCOMPtr<nsIChannel> mNewRedirectChannel;
michael@0 84 };
michael@0 85
michael@0 86 #endif

mercurial