toolkit/modules/LoadContextInfo.jsm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial