зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1363925: Part 8a - Migrate XPIProviderUtils.js to XPIDatabase.jsm. r=aswan
MozReview-Commit-ID: CNfHgCYCkNd --HG-- rename : toolkit/mozapps/extensions/internal/XPIProviderUtils.js => toolkit/mozapps/extensions/internal/XPIDatabase.jsm extra : rebase_source : 968e0072b9dfaf7d9f3f9b2c551ae34582ff1934 extra : histedit_source : a5ad9c4e61f8a92f3830953d3db88213f12a5c8b
This commit is contained in:
Родитель
17554348ca
Коммит
a6683dff36
|
@ -371,7 +371,7 @@ var AddonRepository = {
|
|||
* disabled, null is passed to the specified callback.
|
||||
*
|
||||
* The callback variant exists only for existing code in XPIProvider.jsm
|
||||
* and XPIProviderUtils.jsm that requires a synchronous callback, yuck.
|
||||
* and XPIDatabase.jsm that requires a synchronous callback, yuck.
|
||||
*
|
||||
* @param aId
|
||||
* The id of the add-on to get
|
||||
|
|
|
@ -787,6 +787,7 @@ var AddonTestUtils = {
|
|||
|
||||
AddonManagerPrivate.unregisterProvider(XPIscope.XPIProvider);
|
||||
Cu.unload("resource://gre/modules/addons/XPIProvider.jsm");
|
||||
Cu.unload("resource://gre/modules/addons/XPIDatabase.jsm");
|
||||
Cu.unload("resource://gre/modules/addons/XPIInstall.jsm");
|
||||
|
||||
if (shutdownError)
|
||||
|
|
|
@ -6,11 +6,7 @@
|
|||
|
||||
/* eslint "valid-jsdoc": [2, {requireReturn: false, requireReturnDescription: false, prefer: {return: "returns"}}] */
|
||||
|
||||
// These are injected from XPIProvider.jsm
|
||||
/* globals ADDON_SIGNING, SIGNED_TYPES, BOOTSTRAP_REASONS, DB_SCHEMA,
|
||||
AddonInternal, XPIProvider, XPIStates,
|
||||
isUsableAddon, recordAddonTelemetry,
|
||||
descriptorToPath */
|
||||
var EXPORTED_SYMBOLS = ["XPIDatabase", "XPIDatabaseReconcile"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
@ -18,13 +14,35 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
AddonManager: "resource://gre/modules/AddonManager.jsm",
|
||||
AddonManagerPrivate: "resource://gre/modules/AddonManager.jsm",
|
||||
AddonRepository: "resource://gre/modules/addons/AddonRepository.jsm",
|
||||
AddonSettings: "resource://gre/modules/addons/AddonSettings.jsm",
|
||||
DeferredTask: "resource://gre/modules/DeferredTask.jsm",
|
||||
FileUtils: "resource://gre/modules/FileUtils.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
Services: "resource://gre/modules/Services.jsm",
|
||||
XPIInstall: "resource://gre/modules/addons/XPIInstall.jsm",
|
||||
XPIInternal: "resource://gre/modules/addons/XPIProvider.jsm",
|
||||
});
|
||||
|
||||
// These are injected from XPIProvider.jsm
|
||||
/* globals SIGNED_TYPES, BOOTSTRAP_REASONS, DB_SCHEMA,
|
||||
AddonInternal, XPIProvider, XPIStates,
|
||||
isUsableAddon, recordAddonTelemetry,
|
||||
descriptorToPath */
|
||||
|
||||
for (let sym of [
|
||||
"AddonInternal",
|
||||
"BOOTSTRAP_REASONS",
|
||||
"DB_SCHEMA",
|
||||
"SIGNED_TYPES",
|
||||
"XPIProvider",
|
||||
"XPIStates",
|
||||
"descriptorToPath",
|
||||
"isUsableAddon",
|
||||
"recordAddonTelemetry",
|
||||
]) {
|
||||
XPCOMUtils.defineLazyGetter(this, sym, () => XPIInternal[sym]);
|
||||
}
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Log.jsm");
|
||||
const LOGGER_ID = "addons.xpi-utils";
|
||||
|
||||
|
@ -1266,8 +1284,9 @@ this.XPIDatabaseReconcile = {
|
|||
updateCompatibility(aInstallLocation, aOldAddon, aAddonState, aReloadMetadata) {
|
||||
logger.debug("Updating compatibility for add-on " + aOldAddon.id + " in " + aInstallLocation.name);
|
||||
|
||||
let checkSigning = aOldAddon.signedState === undefined && ADDON_SIGNING &&
|
||||
SIGNED_TYPES.has(aOldAddon.type);
|
||||
let checkSigning = (aOldAddon.signedState === undefined &&
|
||||
AddonSettings.ADDON_SIGNING &&
|
||||
SIGNED_TYPES.has(aOldAddon.type));
|
||||
|
||||
let manifest = null;
|
||||
if (checkSigning || aReloadMetadata) {
|
||||
|
@ -1312,7 +1331,7 @@ this.XPIDatabaseReconcile = {
|
|||
* known to be installed when the application last ran and applies any
|
||||
* changes found to the database. Also sends "startupcache-invalidate" signal to
|
||||
* observerservice if it detects that data may have changed.
|
||||
* Always called after XPIProviderUtils.js and extensions.json have been loaded.
|
||||
* Always called after XPIDatabase.jsm and extensions.json have been loaded.
|
||||
*
|
||||
* @param {Object} aManifests
|
||||
* A dictionary of cached AddonInstalls for add-ons that have been
|
|
@ -43,6 +43,8 @@ ChromeUtils.defineModuleGetter(this, "ProductAddonChecker",
|
|||
"resource://gre/modules/addons/ProductAddonChecker.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "UpdateUtils",
|
||||
"resource://gre/modules/UpdateUtils.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "XPIDatabase",
|
||||
"resource://gre/modules/addons/XPIDatabase.jsm");
|
||||
ChromeUtils.defineModuleGetter(this, "ZipUtils",
|
||||
"resource://gre/modules/ZipUtils.jsm");
|
||||
|
||||
|
@ -85,7 +87,7 @@ const PREF_XPI_DIRECT_WHITELISTED = "xpinstall.whitelist.directRequest";
|
|||
const PREF_XPI_FILE_WHITELISTED = "xpinstall.whitelist.fileRequest";
|
||||
const PREF_XPI_WHITELIST_REQUIRED = "xpinstall.whitelist.required";
|
||||
|
||||
/* globals AddonInternal, BOOTSTRAP_REASONS, KEY_APP_SYSTEM_ADDONS, KEY_APP_SYSTEM_DEFAULTS, KEY_APP_TEMPORARY, PREF_BRANCH_INSTALLED_ADDON, PREF_SYSTEM_ADDON_SET, TEMPORARY_ADDON_SUFFIX, SIGNED_TYPES, TOOLKIT_ID, XPIDatabase, XPI_PERMISSION, XPIStates, getExternalType, isTheme, isUsableAddon, isWebExtension, mustSign, recordAddonTelemetry */
|
||||
/* globals AddonInternal, BOOTSTRAP_REASONS, KEY_APP_SYSTEM_ADDONS, KEY_APP_SYSTEM_DEFAULTS, KEY_APP_TEMPORARY, PREF_BRANCH_INSTALLED_ADDON, PREF_SYSTEM_ADDON_SET, TEMPORARY_ADDON_SUFFIX, SIGNED_TYPES, TOOLKIT_ID, XPI_PERMISSION, XPIStates, getExternalType, isTheme, isUsableAddon, isWebExtension, mustSign, recordAddonTelemetry */
|
||||
const XPI_INTERNAL_SYMBOLS = [
|
||||
"AddonInternal",
|
||||
"BOOTSTRAP_REASONS",
|
||||
|
@ -98,7 +100,6 @@ const XPI_INTERNAL_SYMBOLS = [
|
|||
"TEMPORARY_ADDON_SUFFIX",
|
||||
"TOOLKIT_ID",
|
||||
"XPI_PERMISSION",
|
||||
"XPIDatabase",
|
||||
"XPIStates",
|
||||
"getExternalType",
|
||||
"isTheme",
|
||||
|
|
|
@ -31,6 +31,8 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
clearTimeout: "resource://gre/modules/Timer.jsm",
|
||||
|
||||
UpdateChecker: "resource://gre/modules/addons/XPIInstall.jsm",
|
||||
XPIDatabase: "resource://gre/modules/addons/XPIDatabase.jsm",
|
||||
XPIDatabaseReconcile: "resource://gre/modules/addons/XPIDatabase.jsm",
|
||||
XPIInstall: "resource://gre/modules/addons/XPIInstall.jsm",
|
||||
verifyBundleSignedState: "resource://gre/modules/addons/XPIInstall.jsm",
|
||||
});
|
||||
|
@ -240,11 +242,6 @@ const LOGGER_ID = "addons.xpi";
|
|||
// (Requires AddonManager.jsm)
|
||||
var logger = Log.repository.getLogger(LOGGER_ID);
|
||||
|
||||
const LAZY_OBJECTS = ["XPIDatabase", "XPIDatabaseReconcile"];
|
||||
/* globals XPIDatabase, XPIDatabaseReconcile*/
|
||||
|
||||
var gLazyObjectsLoaded = false;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gStartupScanScopes", () => {
|
||||
let appBuildID = Services.appinfo.appBuildID;
|
||||
let oldAppBuildID = Services.prefs.getCharPref(PREF_EM_LAST_APP_BUILD_ID, "");
|
||||
|
@ -257,46 +254,6 @@ XPCOMUtils.defineLazyGetter(this, "gStartupScanScopes", () => {
|
|||
return Services.prefs.getIntPref(PREF_EM_STARTUP_SCAN_SCOPES, 0);
|
||||
});
|
||||
|
||||
function loadLazyObjects() {
|
||||
let uri = "resource://gre/modules/addons/XPIProviderUtils.js";
|
||||
let scope = Cu.Sandbox(Services.scriptSecurityManager.getSystemPrincipal(), {
|
||||
sandboxName: uri,
|
||||
wantGlobalProperties: ["ChromeUtils", "TextDecoder"],
|
||||
});
|
||||
|
||||
Object.assign(scope, {
|
||||
ADDON_SIGNING: AddonSettings.ADDON_SIGNING,
|
||||
SIGNED_TYPES,
|
||||
BOOTSTRAP_REASONS,
|
||||
DB_SCHEMA,
|
||||
AddonInternal,
|
||||
XPIProvider,
|
||||
XPIStates,
|
||||
isUsableAddon,
|
||||
recordAddonTelemetry,
|
||||
descriptorToPath,
|
||||
});
|
||||
|
||||
Services.scriptloader.loadSubScript(uri, scope);
|
||||
|
||||
for (let name of LAZY_OBJECTS) {
|
||||
delete gGlobalScope[name];
|
||||
gGlobalScope[name] = scope[name];
|
||||
}
|
||||
gLazyObjectsLoaded = true;
|
||||
return scope;
|
||||
}
|
||||
|
||||
LAZY_OBJECTS.forEach(name => {
|
||||
Object.defineProperty(gGlobalScope, name, {
|
||||
get() {
|
||||
let objs = loadLazyObjects();
|
||||
return objs[name];
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Spins the event loop until the given promise resolves, and then eiter returns
|
||||
* its success value or throws its rejection value.
|
||||
|
@ -809,7 +766,7 @@ class XPIState {
|
|||
return new XPIState(location, id, data);
|
||||
}
|
||||
|
||||
// Compatibility shim getters for legacy callers in XPIProviderUtils:
|
||||
// Compatibility shim getters for legacy callers in XPIDatabase.jsm.
|
||||
get mtime() {
|
||||
return this.lastModifiedTime;
|
||||
}
|
||||
|
@ -1501,7 +1458,10 @@ var XPIProvider = {
|
|||
// Check if the XPIDatabase has been loaded (without actually
|
||||
// triggering unwanted imports or I/O)
|
||||
get isDBLoaded() {
|
||||
return gLazyObjectsLoaded && XPIDatabase.initialized;
|
||||
// Make sure we don't touch the XPIDatabase getter before it's
|
||||
// actually loaded, and force an early load.
|
||||
return (Object.getOwnPropertyDescriptor(gGlobalScope, "XPIDatabase").value &&
|
||||
XPIDatabase.initialized);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -3263,7 +3223,7 @@ let addonFor = wrapper => wrapperMap.get(wrapper);
|
|||
|
||||
/**
|
||||
* The AddonInternal is an internal only representation of add-ons. It may
|
||||
* have come from the database (see DBAddonInternal in XPIProviderUtils.jsm)
|
||||
* have come from the database (see DBAddonInternal in XPIDatabase.jsm)
|
||||
* or an install manifest.
|
||||
*/
|
||||
function AddonInternal() {
|
||||
|
@ -4773,6 +4733,7 @@ class WinRegInstallLocation extends DirectoryInstallLocation {
|
|||
var XPIInternal = {
|
||||
AddonInternal,
|
||||
BOOTSTRAP_REASONS,
|
||||
DB_SCHEMA,
|
||||
KEY_APP_SYSTEM_ADDONS,
|
||||
KEY_APP_SYSTEM_DEFAULTS,
|
||||
KEY_APP_TEMPORARY,
|
||||
|
@ -4780,20 +4741,20 @@ var XPIInternal = {
|
|||
PREF_SYSTEM_ADDON_SET,
|
||||
SIGNED_TYPES,
|
||||
SystemAddonInstallLocation,
|
||||
TemporaryInstallLocation,
|
||||
TEMPORARY_ADDON_SUFFIX,
|
||||
TOOLKIT_ID,
|
||||
XPI_PERMISSION,
|
||||
TemporaryInstallLocation,
|
||||
XPIProvider,
|
||||
XPIStates,
|
||||
XPI_PERMISSION,
|
||||
awaitPromise,
|
||||
descriptorToPath,
|
||||
getExternalType,
|
||||
isTheme,
|
||||
isUsableAddon,
|
||||
isWebExtension,
|
||||
mustSign,
|
||||
recordAddonTelemetry,
|
||||
|
||||
get XPIDatabase() { return gGlobalScope.XPIDatabase; },
|
||||
};
|
||||
|
||||
var addonTypes = [
|
||||
|
|
|
@ -14,9 +14,9 @@ EXTRA_JS_MODULES.addons += [
|
|||
'ProductAddonChecker.jsm',
|
||||
'SpellCheckDictionaryBootstrap.js',
|
||||
'UpdateRDFConverter.jsm',
|
||||
'XPIDatabase.jsm',
|
||||
'XPIInstall.jsm',
|
||||
'XPIProvider.jsm',
|
||||
'XPIProviderUtils.js',
|
||||
]
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
|
|
Загрузка…
Ссылка в новой задаче