Compare commits

...
@@ -16,34 +16,25 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Preferences.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonRepository",
"resource://gre/modules/addons/AddonRepository.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ChromeManifestParser",
"resource://gre/modules/ChromeManifestParser.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeManager",
"resource://gre/modules/LightweightThemeManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ZipUtils",
"resource://gre/modules/ZipUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PermissionsUtils",
"resource://gre/modules/PermissionsUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm");
[
["AddonRepository", "resource://gre/modules/addons/AddonRepository.jsm"],
["ChromeManifestParser", "resource://gre/modules/ChromeManifestParser.jsm"],
["LightweightThemeManager", "resource://gre/modules/LightweightThemeManager.jsm"],
["FileUtils", "resource://gre/modules/FileUtils.jsm"],
["ZipUtils", "resource://gre/modules/ZipUtils.jsm"],
["NetUtil", "resource://gre/modules/NetUtil.jsm"],
["PermissionsUtils", "resource://gre/modules/PermissionsUtils.jsm"],
["Promise", "resource://gre/modules/Promise.jsm"],
["Task", "resource://gre/modules/Task.jsm"],
["OS", "resource://gre/modules/osfile.jsm"],
#ifdef MOZ_DEVTOOLS
XPCOMUtils.defineLazyModuleGetter(this, "BrowserToolboxProcess",
"resource://devtools/client/framework/ToolboxProcess.jsm");
["BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm"],
#endif
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPI",
"resource://gre/modules/Console.jsm");
["ConsoleAPI", "resource://gre/modules/Console.jsm"]
].forEach(([name, resource]) => XPCOMUtils.defineLazyModuleGetter(this, name, resource));
XPCOMUtils.defineLazyServiceGetter(this, "Blocklist",
XPCOMUtils.defineLazyServiceGetter(this,
"Blocklist",
"@mozilla.org/extensions/blocklist;1",
Ci.nsIBlocklistService);
XPCOMUtils.defineLazyServiceGetter(this,
@@ -59,169 +50,163 @@ XPCOMUtils.defineLazyServiceGetter(this,
"@mozilla.org/addon-path-service;1",
"amIAddonPathService");
const nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
const nsIFile = Components.Constructor("@mozilla.org/file/local;1",
"nsIFile",
"initWithPath");
const PREF_DB_SCHEMA = "extensions.databaseSchema";
const PREF_INSTALL_CACHE = "extensions.installCache";
const PREF_XPI_STATE = "extensions.xpiState";
const PREF_BOOTSTRAP_ADDONS = "extensions.bootstrappedAddons";
const PREF_PENDING_OPERATIONS = "extensions.pendingOperations";
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
const PREF_EM_DSS_ENABLED = "extensions.dss.enabled";
const PREF_DSS_SWITCHPENDING = "extensions.dss.switchPending";
const PREF_DSS_SKIN_TO_SELECT = "extensions.lastSelectedSkin";
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
const PREF_EM_UPDATE_URL = "extensions.update.url";
const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons";
const PREF_EM_EXTENSION_FORMAT = "extensions.";
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
const PREF_EM_AUTO_DISABLED_SCOPES = "extensions.autoDisableScopes";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_XPI_WHITELIST_REQUIRED = "xpinstall.whitelist.required";
const PREF_XPI_DIRECT_WHITELISTED = "xpinstall.whitelist.directRequest";
const PREF_XPI_FILE_WHITELISTED = "xpinstall.whitelist.fileRequest";
const PREF_XPI_PERMISSIONS_BRANCH = "xpinstall.";
const PREF_XPI_UNPACK = "extensions.alwaysUnpack";
const PREF_INSTALL_REQUIREBUILTINCERTS = "extensions.install.requireBuiltInCerts";
const PREF_INSTALL_REQUIRESECUREORIGIN = "extensions.install.requireSecureOrigin";
const PREF_INSTALL_DISTRO_ADDONS = "extensions.installDistroAddons";
const PREF_BRANCH_INSTALLED_ADDON = "extensions.installedDistroAddon.";
const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI";
const PREF_INTERPOSITION_ENABLED = "extensions.interposition.enabled";
const PREF_DB_SCHEMA = "extensions.databaseSchema";
const PREF_INSTALL_CACHE = "extensions.installCache";
const PREF_XPI_STATE = "extensions.xpiState";
const PREF_BOOTSTRAP_ADDONS = "extensions.bootstrappedAddons";
const PREF_PENDING_OPERATIONS = "extensions.pendingOperations";
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
const PREF_EM_DSS_ENABLED = "extensions.dss.enabled";
const PREF_DSS_SWITCHPENDING = "extensions.dss.switchPending";
const PREF_DSS_SKIN_TO_SELECT = "extensions.lastSelectedSkin";
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
const PREF_EM_UPDATE_URL = "extensions.update.url";
const PREF_EM_ENABLED_ADDONS = "extensions.enabledAddons";
const PREF_EM_EXTENSION_FORMAT = "extensions.";
const PREF_EM_ENABLED_SCOPES = "extensions.enabledScopes";
const PREF_EM_AUTO_DISABLED_SCOPES = "extensions.autoDisableScopes";
const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
const PREF_XPI_ENABLED = "xpinstall.enabled";
const PREF_XPI_WHITELIST_REQUIRED = "xpinstall.whitelist.required";
const PREF_XPI_DIRECT_WHITELISTED = "xpinstall.whitelist.directRequest";
const PREF_XPI_FILE_WHITELISTED = "xpinstall.whitelist.fileRequest";
const PREF_XPI_PERMISSIONS_BRANCH = "xpinstall.";
const PREF_XPI_UNPACK = "extensions.alwaysUnpack";
const PREF_INSTALL_REQUIREBUILTINCERTS = "extensions.install.requireBuiltInCerts";
const PREF_INSTALL_REQUIRESECUREORIGIN = "extensions.install.requireSecureOrigin";
const PREF_INSTALL_DISTRO_ADDONS = "extensions.installDistroAddons";
const PREF_BRANCH_INSTALLED_ADDON = "extensions.installedDistroAddon.";
const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI";
const PREF_INTERPOSITION_ENABLED = "extensions.interposition.enabled";
const PREF_EM_MIN_COMPAT_APP_VERSION = "extensions.minCompatibleAppVersion";
const PREF_EM_MIN_COMPAT_PLATFORM_VERSION = "extensions.minCompatiblePlatformVersion";
const URI_EXTENSION_SELECT_DIALOG = "chrome://mozapps/content/extensions/selectAddons.xul";
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
const URI_EXTENSION_SELECT_DIALOG = "chrome://mozapps/content/extensions/selectAddons.xul";
const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
const URI_EXTENSION_STRINGS = "chrome://mozapps/locale/extensions/extensions.properties";
const STRING_TYPE_NAME = "type.%ID%.name";
const STRING_TYPE_NAME = "type.%ID%.name";
const DIR_EXTENSIONS = "extensions";
const DIR_STAGE = "staged";
const DIR_XPI_STAGE = "staged-xpis";
const DIR_TRASH = "trash";
const DIR_EXTENSIONS = "extensions";
const DIR_STAGE = "staged";
const DIR_XPI_STAGE = "staged-xpis";
const DIR_TRASH = "trash";
const FILE_DATABASE = "extensions.json";
const FILE_OLD_CACHE = "extensions.cache";
const FILE_INSTALL_MANIFEST = "install.rdf";
const FILE_DATABASE = "extensions.json";
const FILE_OLD_CACHE = "extensions.cache";
const FILE_XPI_ADDONS_LIST = "extensions.ini";
const FILE_RDF_INSTALL_MANIFEST = "install.rdf";
#ifndef MOZ_JETPACK
const FILE_JETPACK_MANIFEST_1 = "harness-options.json";
const FILE_JETPACK_MANIFEST_2 = "package.json";
const FILE_CFX_JETPACK_MANIFEST = "harness-options.json";
const FILE_NPM_JETPACK_MANIFEST = "package.json";
#endif
const FILE_WEBEXT_MANIFEST = "manifest.json";
const FILE_XPI_ADDONS_LIST = "extensions.ini";
const FILE_WEBEXTENSION_MANIFEST = "manifest.json";
const KEY_PROFILEDIR = "ProfD";
const KEY_APPDIR = "XCurProcD";
const KEY_TEMPDIR = "TmpD";
const KEY_APP_DISTRIBUTION = "XREAppDist";
const KEY_PROFILEDIR = "ProfD";
const KEY_APPDIR = "XCurProcD";
const KEY_TEMPDIR = "TmpD";
const KEY_APP_DISTRIBUTION = "XREAppDist";
const KEY_APP_PROFILE = "app-profile";
const KEY_APP_GLOBAL = "app-global";
const KEY_APP_SYSTEM_LOCAL = "app-system-local";
const KEY_APP_SYSTEM_SHARE = "app-system-share";
const KEY_APP_SYSTEM_USER = "app-system-user";
const KEY_APP_PROFILE = "app-profile";
const KEY_APP_GLOBAL = "app-global";
const KEY_APP_SYSTEM_LOCAL = "app-system-local";
const KEY_APP_SYSTEM_SHARE = "app-system-share";
const KEY_APP_SYSTEM_USER = "app-system-user";
const NOTIFICATION_FLUSH_PERMISSIONS = "flush-pending-permissions";
const XPI_PERMISSION = "install";
const NOTIFICATION_FLUSH_PERMISSIONS = "flush-pending-permissions";
const XPI_PERMISSION = "install";
const RDFURI_INSTALL_MANIFEST_ROOT = "urn:mozilla:install-manifest";
const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
const RDFURI_INSTALL_MANIFEST_ROOT = "urn:mozilla:install-manifest";
const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
const TOOLKIT_ID = "toolkit@mozilla.org";
const TOOLKIT_ID = "toolkit@mozilla.org";
#ifdef MOZ_PHOENIX_EXTENSIONS
const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
const FIREFOX_APPCOMPATVERSION = "56.9"
const FIREFOX_ID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
const FIREFOX_APPCOMPATVERSION = "56.9"
#endif
// The value for this is in Makefile.in
#expand const DB_SCHEMA = __MOZ_EXTENSIONS_DB_SCHEMA__;
XPCOMUtils.defineConstant(this, "DB_SCHEMA", DB_SCHEMA);
#ifdef MOZ_DEVTOOLS
const NOTIFICATION_TOOLBOXPROCESS_LOADED = "ToolboxProcessLoaded";
const NOTIFICATION_TOOLBOXPROCESS_LOADED = "ToolboxProcessLoaded";
#endif
// Properties that exist in the install manifest
const PROP_METADATA = ["id", "version", "type", "internalName", "updateURL",
"updateKey", "optionsURL", "optionsType", "aboutURL",
"iconURL", "icon64URL"];
const PROP_LOCALE_SINGLE = ["name", "description", "creator", "homepageURL"];
const PROP_LOCALE_MULTI = ["developers", "translators", "contributors"];
const PROP_TARGETAPP = ["id", "minVersion", "maxVersion"];
const PROP_METADATA = ["id", "version", "type", "internalName", "updateURL",
"updateKey", "optionsURL", "optionsType", "aboutURL",
"iconURL", "icon64URL"];
const PROP_LOCALE_SINGLE = ["name", "description", "creator", "homepageURL"];
const PROP_LOCALE_MULTI = ["developers", "translators", "contributors"];
const PROP_TARGETAPP = ["id", "minVersion", "maxVersion"];
// Properties that should be migrated where possible from an old database. These
// shouldn't include properties that can be read directly from install.rdf files
// or calculated
const DB_MIGRATE_METADATA= ["installDate", "userDisabled", "softDisabled",
"sourceURI", "applyBackgroundUpdates",
"releaseNotesURI", "foreignInstall", "syncGUID"];
const DB_MIGRATE_METADATA = ["installDate", "userDisabled", "softDisabled",
"sourceURI", "applyBackgroundUpdates",
"releaseNotesURI", "foreignInstall", "syncGUID"];
// Properties to cache and reload when an addon installation is pending
const PENDING_INSTALL_METADATA =
["syncGUID", "targetApplications", "userDisabled", "softDisabled",
"existingAddonID", "sourceURI", "releaseNotesURI", "installDate",
"updateDate", "applyBackgroundUpdates", "compatibilityOverrides"];
const PENDING_INSTALL_METADATA = ["syncGUID", "targetApplications", "userDisabled", "softDisabled",
"existingAddonID", "sourceURI", "releaseNotesURI", "installDate",
"updateDate", "applyBackgroundUpdates", "compatibilityOverrides"];
// Note: When adding/changing/removing items here, remember to change the
// DB schema version to ensure changes are picked up ASAP.
const STATIC_BLOCKLIST_PATTERNS = [
{ creator: "Mozilla Corp.",
level: Blocklist.STATE_BLOCKED,
blockID: "i162" },
{ creator: "Mozilla.org",
level: Blocklist.STATE_BLOCKED,
blockID: "i162" }
];
const STATIC_BLOCKLIST_PATTERNS = [
{ creator: "Mozilla Corp.",
level: Blocklist.STATE_BLOCKED,
blockID: "i162" },
{ creator: "Mozilla.org",
level: Blocklist.STATE_BLOCKED,
blockID: "i162" }
];
const BOOTSTRAP_REASONS = {
APP_STARTUP : 1,
APP_SHUTDOWN : 2,
ADDON_ENABLE : 3,
ADDON_DISABLE : 4,
ADDON_INSTALL : 5,
ADDON_UNINSTALL : 6,
ADDON_UPGRADE : 7,
ADDON_DOWNGRADE : 8
};
const BOOTSTRAP_REASONS = { APP_STARTUP: 1,
APP_SHUTDOWN: 2,
ADDON_ENABLE: 3,
ADDON_DISABLE: 4,
ADDON_INSTALL: 5,
ADDON_UNINSTALL: 6,
ADDON_UPGRADE: 7,
ADDON_DOWNGRADE: 8 };
// Map new string type identifiers to old style nsIUpdateItem types
const TYPES = {
extension: 2,
theme: 4,
locale: 8,
multipackage: 32,
dictionary: 64,
experiment: 128,
};
const TYPES = { extension: 2,
theme: 4,
locale: 8,
multipackage: 32,
dictionary: 64,
experiment: 128 };
const RESTARTLESS_TYPES = new Set([
"dictionary",
"experiment",
"locale",
]);
const RESTARTLESS_TYPES = new Set([
"dictionary",
"experiment",
"locale",
]);
// Keep track of where we are in startup for telemetry
// event happened during XPIDatabase.startup()
const XPI_STARTING = "XPIStarting";
const XPI_STARTING = "XPIStarting";
// event happened after startup() but before the final-ui-startup event
const XPI_BEFORE_UI_STARTUP = "BeforeFinalUIStartup";
const XPI_BEFORE_UI_STARTUP = "BeforeFinalUIStartup";
// event happened after final-ui-startup
const XPI_AFTER_UI_STARTUP = "AfterFinalUIStartup";
const XPI_AFTER_UI_STARTUP = "AfterFinalUIStartup";
const COMPATIBLE_BY_DEFAULT_TYPES = {
extension: true,
dictionary: true
};
const COMPATIBLE_BY_DEFAULT_TYPES = { extension: true,
dictionary: true };
const MSG_JAR_FLUSH = "AddonJarFlush";
const MSG_MESSAGE_MANAGER_CACHES_FLUSH = "AddonMessageManagerCachesFlush";
const MSG_JAR_FLUSH = "AddonJarFlush";
const MSG_MM_CACHES_FLUSH = "AddonMessageManagerCachesFlush";
var gGlobalScope = this;
var gGlobalScope = this;
/**
* Valid IDs fit this pattern.
@@ -1015,7 +1000,7 @@ function loadManifestFromDir(aDir) {
}
let file = aDir.clone();
file.append(FILE_INSTALL_MANIFEST);
file.append(FILE_RDF_INSTALL_MANIFEST);
if (!file.exists() || !file.isFile())
throw new Error("Directory " + aDir.path + " does not contain a valid " +
"install manifest");
@@ -1061,8 +1046,8 @@ function loadManifestFromDir(aDir) {
*/
function loadManifestFromZipReader(aZipReader) {
// If WebExtension but not install.rdf throw an error
if (aZipReader.hasEntry(FILE_WEBEXT_MANIFEST)) {
if (!aZipReader.hasEntry(FILE_INSTALL_MANIFEST)) {
if (aZipReader.hasEntry(FILE_WEBEXTENSION_MANIFEST)) {
if (!aZipReader.hasEntry(FILE_RDF_INSTALL_MANIFEST)) {
throw {
name: "UnsupportedExtension",
message: Services.appinfo.name + " does not support WebExtensions",
@@ -1073,8 +1058,8 @@ function loadManifestFromZipReader(aZipReader) {
#ifndef MOZ_JETPACK
// If Jetpack is not built throw an error
if (aZipReader.hasEntry(FILE_JETPACK_MANIFEST_1) ||
aZipReader.hasEntry(FILE_JETPACK_MANIFEST_2)) {
if (aZipReader.hasEntry(FILE_CFX_JETPACK_MANIFEST) ||
aZipReader.hasEntry(FILE_NPM_JETPACK_MANIFEST)) {
throw {
name: "UnsupportedExtension",
message: Services.appinfo.name + " does not support Jetpack Extensions",
@@ -1084,14 +1069,14 @@ function loadManifestFromZipReader(aZipReader) {
#endif
// Attempt to open install.rdf else throw normally
let zis = aZipReader.getInputStream(FILE_INSTALL_MANIFEST);
let zis = aZipReader.getInputStream(FILE_RDF_INSTALL_MANIFEST);
// Create a buffered input stream for install.rdf
let bis = Cc["@mozilla.org/network/buffered-input-stream;1"].
createInstance(Ci.nsIBufferedInputStream);
bis.init(zis, 4096);
try {
let uri = buildJarURI(aZipReader.file, FILE_INSTALL_MANIFEST);
let uri = buildJarURI(aZipReader.file, FILE_RDF_INSTALL_MANIFEST);
let addon = loadManifestFromRDF(uri, bis);
addon._sourceBundle = aZipReader.file;
@@ -1208,7 +1193,7 @@ function flushChromeCaches() {
// Flush message manager cached scripts
Services.obs.notifyObservers(null, "message-manager-flush-caches", null);
// Also dispatch this event to child processes
Services.mm.broadcastAsyncMessage(MSG_MESSAGE_MANAGER_CACHES_FLUSH, null);
Services.mm.broadcastAsyncMessage(MSG_MM_CACHES_FLUSH, null);
}
/**
@@ -1533,7 +1518,7 @@ XPIState.prototype = {
// XXX This will eventually also need to check for package.json or whatever
// the new manifest is named.
let maniFile = aFile.clone();
maniFile.append(FILE_INSTALL_MANIFEST);
maniFile.append(FILE_RDF_INSTALL_MANIFEST);
if (!(aId in XPIProvider._mostRecentlyModifiedFile)) {
XPIProvider._mostRecentlyModifiedFile[aId] = maniFile.leafName;
}
@@ -2571,7 +2556,7 @@ this.XPIProvider = {
if (isDir) {
// Check if the directory contains an install manifest.
let manifest = stageDirEntry.clone();
manifest.append(FILE_INSTALL_MANIFEST);
manifest.append(FILE_RDF_INSTALL_MANIFEST);
// If the install manifest doesn't exist uninstall this add-on in this
// install location.