michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: "use strict"; michael@0: michael@0: module.metadata = { michael@0: "stability": "stable" michael@0: }; michael@0: michael@0: const { CC } = require('chrome'); michael@0: const { id, name, prefixURI, rootURI, metadata, michael@0: version, loadReason, preferencesBranch } = require('@loader/options'); michael@0: michael@0: const { readURISync } = require('./net/url'); michael@0: michael@0: const addonDataURI = prefixURI + name + '/data/'; michael@0: michael@0: const uri = (path="") => michael@0: path.contains(":") ? path : addonDataURI + path; michael@0: michael@0: michael@0: // Some XPCOM APIs require valid URIs as an argument for certain operations michael@0: // (see `nsILoginManager` for example). This property represents add-on michael@0: // associated unique URI string that can be used for that. michael@0: exports.uri = 'addon:' + id; michael@0: exports.id = id; michael@0: exports.preferencesBranch = preferencesBranch || id; michael@0: exports.name = name; michael@0: exports.loadReason = loadReason; michael@0: exports.version = version; michael@0: // If `rootURI` is jar:file://...!/ than add-on is packed. michael@0: exports.packed = (rootURI || '').indexOf('jar:') === 0; michael@0: exports.data = Object.freeze({ michael@0: url: uri, michael@0: load: function read(path) { michael@0: return readURISync(uri(path)); michael@0: } michael@0: }); michael@0: exports.isPrivateBrowsingSupported = ((metadata || {}).permissions || {})['private-browsing'] === true;