content/base/src/nsCrossSiteListenerProxy.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/base/src/nsCrossSiteListenerProxy.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsCORSListenerProxy_h__
    1.10 +#define nsCORSListenerProxy_h__
    1.11 +
    1.12 +#include "nsIStreamListener.h"
    1.13 +#include "nsIInterfaceRequestor.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +#include "nsString.h"
    1.16 +#include "nsIURI.h"
    1.17 +#include "nsTArray.h"
    1.18 +#include "nsIInterfaceRequestor.h"
    1.19 +#include "nsIChannelEventSink.h"
    1.20 +#include "nsIAsyncVerifyRedirectCallback.h"
    1.21 +#include "mozilla/Attributes.h"
    1.22 +
    1.23 +class nsIURI;
    1.24 +class nsIParser;
    1.25 +class nsIPrincipal;
    1.26 +
    1.27 +extern bool
    1.28 +IsValidHTTPToken(const nsCSubstring& aToken);
    1.29 +
    1.30 +nsresult
    1.31 +NS_StartCORSPreflight(nsIChannel* aRequestChannel,
    1.32 +                      nsIStreamListener* aListener,
    1.33 +                      nsIPrincipal* aPrincipal,
    1.34 +                      bool aWithCredentials,
    1.35 +                      nsTArray<nsCString>& aACUnsafeHeaders,
    1.36 +                      nsIChannel** aPreflightChannel);
    1.37 +
    1.38 +class nsCORSListenerProxy MOZ_FINAL : public nsIStreamListener,
    1.39 +                                      public nsIInterfaceRequestor,
    1.40 +                                      public nsIChannelEventSink,
    1.41 +                                      public nsIAsyncVerifyRedirectCallback
    1.42 +{
    1.43 +public:
    1.44 +  nsCORSListenerProxy(nsIStreamListener* aOuter,
    1.45 +                      nsIPrincipal* aRequestingPrincipal,
    1.46 +                      bool aWithCredentials);
    1.47 +  nsCORSListenerProxy(nsIStreamListener* aOuter,
    1.48 +                      nsIPrincipal* aRequestingPrincipal,
    1.49 +                      bool aWithCredentials,
    1.50 +                      const nsCString& aPreflightMethod,
    1.51 +                      const nsTArray<nsCString>& aPreflightHeaders);
    1.52 +
    1.53 +  NS_DECL_ISUPPORTS
    1.54 +  NS_DECL_NSIREQUESTOBSERVER
    1.55 +  NS_DECL_NSISTREAMLISTENER
    1.56 +  NS_DECL_NSIINTERFACEREQUESTOR
    1.57 +  NS_DECL_NSICHANNELEVENTSINK
    1.58 +  NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
    1.59 +
    1.60 +  // Must be called at startup.
    1.61 +  static void Startup();
    1.62 +
    1.63 +  static void Shutdown();
    1.64 +
    1.65 +  nsresult Init(nsIChannel* aChannel, bool aAllowDataURI = false);
    1.66 +
    1.67 +private:
    1.68 +  nsresult UpdateChannel(nsIChannel* aChannel, bool aAllowDataURI = false);
    1.69 +  nsresult CheckRequestApproved(nsIRequest* aRequest);
    1.70 +
    1.71 +  nsCOMPtr<nsIStreamListener> mOuterListener;
    1.72 +  // The principal that originally kicked off the request
    1.73 +  nsCOMPtr<nsIPrincipal> mRequestingPrincipal;
    1.74 +  // The principal to use for our Origin header ("source origin" in spec terms).
    1.75 +  // This can get changed during redirects, unlike mRequestingPrincipal.
    1.76 +  nsCOMPtr<nsIPrincipal> mOriginHeaderPrincipal;
    1.77 +  nsCOMPtr<nsIInterfaceRequestor> mOuterNotificationCallbacks;
    1.78 +  bool mWithCredentials;
    1.79 +  bool mRequestApproved;
    1.80 +  bool mHasBeenCrossSite;
    1.81 +  bool mIsPreflight;
    1.82 +  nsCString mPreflightMethod;
    1.83 +  nsTArray<nsCString> mPreflightHeaders;
    1.84 +  nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
    1.85 +  nsCOMPtr<nsIChannel> mOldRedirectChannel;
    1.86 +  nsCOMPtr<nsIChannel> mNewRedirectChannel;
    1.87 +};
    1.88 +
    1.89 +#endif

mercurial