1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/lib/sdk/self.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +"use strict"; 1.8 + 1.9 +module.metadata = { 1.10 + "stability": "stable" 1.11 +}; 1.12 + 1.13 +const { CC } = require('chrome'); 1.14 +const { id, name, prefixURI, rootURI, metadata, 1.15 + version, loadReason, preferencesBranch } = require('@loader/options'); 1.16 + 1.17 +const { readURISync } = require('./net/url'); 1.18 + 1.19 +const addonDataURI = prefixURI + name + '/data/'; 1.20 + 1.21 +const uri = (path="") => 1.22 + path.contains(":") ? path : addonDataURI + path; 1.23 + 1.24 + 1.25 +// Some XPCOM APIs require valid URIs as an argument for certain operations 1.26 +// (see `nsILoginManager` for example). This property represents add-on 1.27 +// associated unique URI string that can be used for that. 1.28 +exports.uri = 'addon:' + id; 1.29 +exports.id = id; 1.30 +exports.preferencesBranch = preferencesBranch || id; 1.31 +exports.name = name; 1.32 +exports.loadReason = loadReason; 1.33 +exports.version = version; 1.34 +// If `rootURI` is jar:file://...!/ than add-on is packed. 1.35 +exports.packed = (rootURI || '').indexOf('jar:') === 0; 1.36 +exports.data = Object.freeze({ 1.37 + url: uri, 1.38 + load: function read(path) { 1.39 + return readURISync(uri(path)); 1.40 + } 1.41 +}); 1.42 +exports.isPrivateBrowsingSupported = ((metadata || {}).permissions || {})['private-browsing'] === true;