toolkit/devtools/DevToolsExtensions.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/. */
     4 "use strict";
     6 this.EXPORTED_SYMBOLS = ["gDevToolsExtensions"];
     8 Components.utils.import("resource://gre/modules/Services.jsm");
    10 let globalsCache = {};
    12 this.gDevToolsExtensions = {
    13   addContentGlobal: function(options) {
    14     if (!options || !options.global || !options['inner-window-id']) {
    15       throw Error('Invalid arguments');
    16     }
    17     let cache = getGlobalCache(options['inner-window-id']);
    18     cache.push(options.global);
    19     return undefined;
    20   },
    21   getContentGlobals: function(options) {
    22     if (!options || !options['inner-window-id']) {
    23       throw Error('Invalid arguments');
    24     }
    25     return Array.slice(globalsCache[options['inner-window-id']] || []);
    26   },
    27   removeContentGlobal: function(options) {
    28     if (!options || !options.global || !options['inner-window-id']) {
    29       throw Error('Invalid arguments');
    30     }
    31     let cache = getGlobalCache(options['inner-window-id']);
    32     let index = cache.indexOf(options.global);
    33     cache.splice(index, 1);
    34     return undefined;
    35   }
    36 };
    38 function getGlobalCache(aInnerWindowID) {
    39   return globalsCache[aInnerWindowID] = globalsCache[aInnerWindowID] || [];
    40 }
    42 // when the window is destroyed, eliminate the associated globals cache
    43 Services.obs.addObserver(function observer(subject, topic, data) {
    44   let id = subject.QueryInterface(Components.interfaces.nsISupportsPRUint64).data;
    45   delete globalsCache[id];
    46 }, 'inner-window-destroyed', false);

mercurial