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.)

     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 nsCORSListenerProxy_h__
     7 #define nsCORSListenerProxy_h__
     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"
    20 class nsIURI;
    21 class nsIParser;
    22 class nsIPrincipal;
    24 extern bool
    25 IsValidHTTPToken(const nsCSubstring& aToken);
    27 nsresult
    28 NS_StartCORSPreflight(nsIChannel* aRequestChannel,
    29                       nsIStreamListener* aListener,
    30                       nsIPrincipal* aPrincipal,
    31                       bool aWithCredentials,
    32                       nsTArray<nsCString>& aACUnsafeHeaders,
    33                       nsIChannel** aPreflightChannel);
    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);
    50   NS_DECL_ISUPPORTS
    51   NS_DECL_NSIREQUESTOBSERVER
    52   NS_DECL_NSISTREAMLISTENER
    53   NS_DECL_NSIINTERFACEREQUESTOR
    54   NS_DECL_NSICHANNELEVENTSINK
    55   NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
    57   // Must be called at startup.
    58   static void Startup();
    60   static void Shutdown();
    62   nsresult Init(nsIChannel* aChannel, bool aAllowDataURI = false);
    64 private:
    65   nsresult UpdateChannel(nsIChannel* aChannel, bool aAllowDataURI = false);
    66   nsresult CheckRequestApproved(nsIRequest* aRequest);
    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 };
    86 #endif

mercurial