content/base/src/nsCrossSiteListenerProxy.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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