toolkit/modules/LoadContextInfo.jsm

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:bfffbc6e4909
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
5 this.EXPORTED_SYMBOLS = ["LoadContextInfo"];
6
7 const Ci = Components.interfaces;
8 const Cc = Components.classes;
9 const Cr = Components.results;
10
11 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
12
13 this.LoadContextInfo = {};
14
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 }
22
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 }
29
30 // LoadContextInfo.default
31
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 });
36
37 // LoadContextInfo.private
38
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 });
43
44 // LoadContextInfo.anonymous
45
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 });
50
51 // Fully customizable
52 LoadContextInfo.custom = function(_private, _anonymous, _appId, _inBrowser) {
53 return new _LoadContextInfo(_private, _anonymous, _appId, _inBrowser);
54 }
55
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