|
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"; |
|
5 |
|
6 module.metadata = { |
|
7 "stability": "stable" |
|
8 }; |
|
9 |
|
10 const { CC } = require('chrome'); |
|
11 const { id, name, prefixURI, rootURI, metadata, |
|
12 version, loadReason, preferencesBranch } = require('@loader/options'); |
|
13 |
|
14 const { readURISync } = require('./net/url'); |
|
15 |
|
16 const addonDataURI = prefixURI + name + '/data/'; |
|
17 |
|
18 const uri = (path="") => |
|
19 path.contains(":") ? path : addonDataURI + path; |
|
20 |
|
21 |
|
22 // Some XPCOM APIs require valid URIs as an argument for certain operations |
|
23 // (see `nsILoginManager` for example). This property represents add-on |
|
24 // associated unique URI string that can be used for that. |
|
25 exports.uri = 'addon:' + id; |
|
26 exports.id = id; |
|
27 exports.preferencesBranch = preferencesBranch || id; |
|
28 exports.name = name; |
|
29 exports.loadReason = loadReason; |
|
30 exports.version = version; |
|
31 // If `rootURI` is jar:file://...!/ than add-on is packed. |
|
32 exports.packed = (rootURI || '').indexOf('jar:') === 0; |
|
33 exports.data = Object.freeze({ |
|
34 url: uri, |
|
35 load: function read(path) { |
|
36 return readURISync(uri(path)); |
|
37 } |
|
38 }); |
|
39 exports.isPrivateBrowsingSupported = ((metadata || {}).permissions || {})['private-browsing'] === true; |