toolkit/modules/LoadContextInfo.jsm

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 this.EXPORTED_SYMBOLS = ["LoadContextInfo"];
     7 const Ci = Components.interfaces;
     8 const Cc = Components.classes;
     9 const Cr = Components.results;
    11 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    13 this.LoadContextInfo = {};
    15 _LoadContextInfo.prototype = {
    16   QueryInterface: XPCOMUtils.generateQI([Ci.nsILoadContextInfo, Ci.nsISupports]),
    17   get isPrivate() { return this._isPrivate },
    18   get isAnonymous() { return this._isAnonymous },
    19   get isInBrowserElement() { return this._isInBrowserElement },
    20   get appId() { return this._appId }
    21 }
    23 function _LoadContextInfo(_private, _anonymous, _appId, _inBrowser) {
    24   this._isPrivate = _private || false;
    25   this._isAnonymous = _anonymous || false;
    26   this._appId = _appId || 0;
    27   this._isInBrowserElement = _inBrowser || false;
    28 }
    30 // LoadContextInfo.default
    32 // Non-private, non-anonymous, no app ID, not in browser
    33 XPCOMUtils.defineLazyGetter(LoadContextInfo, "default", function () {
    34   return new _LoadContextInfo(false, false, 0, false);
    35 });
    37 // LoadContextInfo.private
    39 // Private, non-anonymous, no app ID, not in browser
    40 XPCOMUtils.defineLazyGetter(LoadContextInfo, "private", function () {
    41   return new _LoadContextInfo(true, false, 0, false);
    42 });
    44 // LoadContextInfo.anonymous
    46 // Non-private, anonymous, no app ID, not in browser
    47 XPCOMUtils.defineLazyGetter(LoadContextInfo, "anonymous", function () {
    48   return new _LoadContextInfo(false, true, 0, false);
    49 });
    51 // Fully customizable
    52 LoadContextInfo.custom = function(_private, _anonymous, _appId, _inBrowser) {
    53   return new _LoadContextInfo(_private, _anonymous, _appId, _inBrowser);
    54 }
    56 // Copies info from provided nsILoadContext
    57 LoadContextInfo.fromLoadContext = function(_loadContext, _anonymous) {
    58   return new _LoadContextInfo(_loadContext.isPrivate,
    59                               _anonymous,
    60                               _loadContext.appId,
    61                               _loadContext.isInBrowserElement);
    62 }

mercurial