caps/include/nsJSPrincipals.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
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/. */
     5 /* describes principals by their orginating uris*/
     7 #ifndef nsJSPrincipals_h__
     8 #define nsJSPrincipals_h__
     9 #include "jsapi.h"
    10 #include "nsIPrincipal.h"
    12 class nsCString;
    14 struct nsJSPrincipals : nsIPrincipal, JSPrincipals
    15 {
    16   static bool Subsume(JSPrincipals *jsprin, JSPrincipals *other);
    17   static void Destroy(JSPrincipals *jsprin);
    19   /*
    20    * Get a weak reference to nsIPrincipal associated with the given JS
    21    * principal.
    22    */
    23   static nsJSPrincipals* get(JSPrincipals *principals) {
    24     nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principals);
    25     MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
    26     return self;
    27   }
    29   static nsJSPrincipals* get(nsIPrincipal *principal) {
    30     nsJSPrincipals *self = static_cast<nsJSPrincipals *>(principal);
    31     MOZ_ASSERT_IF(self, self->debugToken == DEBUG_TOKEN);
    32     return self;
    33   }
    35   nsJSPrincipals() {
    36     refcount = 0;
    37     setDebugToken(DEBUG_TOKEN);
    38   }
    40   virtual ~nsJSPrincipals() {
    41     setDebugToken(0);
    42   }
    44   /**
    45    * Return a string that can be used as JS script filename in error reports.
    46    */
    47   virtual void GetScriptLocation(nsACString &aStr) = 0;
    49 #ifdef DEBUG
    50   virtual void dumpImpl() = 0;
    51 #endif
    53   static const uint32_t DEBUG_TOKEN = 0x0bf41760;
    54 };
    56 #endif /* nsJSPrincipals_h__ */

mercurial