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 }
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;
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);
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);
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);
52 LoadContextInfo.custom = function(_private, _anonymous, _appId, _inBrowser) {
53 return new _LoadContextInfo(_private, _anonymous, _appId, _inBrowser);
56 // Copies info from provided nsILoadContext
57 LoadContextInfo.fromLoadContext = function(_loadContext, _anonymous) {
58 return new _LoadContextInfo(_loadContext.isPrivate,
61 _loadContext.isInBrowserElement);