зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1409245 Part 2 Implement bootstrap update() method r=kmag
When we are updating versions of an extension, instead of calling uninstall() on the old version followed by calling install() on the new version, we now call update() once with details about the old and new versions. This logic is only applied for webextensions, any other bootstrapped extensions retain the old behavior. MozReview-Commit-ID: EwdvGATG0rK --HG-- extra : rebase_source : 60ead06460340874c86c109bcaa4b61be1717dd1
This commit is contained in:
Родитель
f6221fbeff
Коммит
30a1f56c87
|
@ -1799,12 +1799,15 @@ class AddonInstall {
|
|||
|
||||
// Deactivate and remove the old add-on as necessary
|
||||
let reason = BOOTSTRAP_REASONS.ADDON_INSTALL;
|
||||
let callUpdate = false;
|
||||
if (this.existingAddon) {
|
||||
if (Services.vc.compare(this.existingAddon.version, this.addon.version) < 0)
|
||||
reason = BOOTSTRAP_REASONS.ADDON_UPGRADE;
|
||||
else
|
||||
reason = BOOTSTRAP_REASONS.ADDON_DOWNGRADE;
|
||||
|
||||
callUpdate = isWebExtension(this.addon.type) && isWebExtension(this.existingAddon.type);
|
||||
|
||||
if (this.existingAddon.bootstrap) {
|
||||
let file = this.existingAddon._sourceBundle;
|
||||
if (this.existingAddon.active) {
|
||||
|
@ -1813,9 +1816,11 @@ class AddonInstall {
|
|||
{ newVersion: this.addon.version });
|
||||
}
|
||||
|
||||
XPIProvider.callBootstrapMethod(this.existingAddon, file,
|
||||
"uninstall", reason,
|
||||
{ newVersion: this.addon.version });
|
||||
if (!callUpdate) {
|
||||
XPIProvider.callBootstrapMethod(this.existingAddon, file,
|
||||
"uninstall", reason,
|
||||
{ newVersion: this.addon.version });
|
||||
}
|
||||
XPIProvider.unloadBootstrapScope(this.existingAddon.id);
|
||||
flushChromeCaches();
|
||||
}
|
||||
|
@ -1861,7 +1866,8 @@ class AddonInstall {
|
|||
}
|
||||
|
||||
if (this.addon.bootstrap) {
|
||||
XPIProvider.callBootstrapMethod(this.addon, file, "install",
|
||||
let method = callUpdate ? "update" : "install";
|
||||
XPIProvider.callBootstrapMethod(this.addon, file, method,
|
||||
reason, extraParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -2392,12 +2392,16 @@ this.XPIProvider = {
|
|||
let reason = BOOTSTRAP_REASONS.ADDON_UNINSTALL;
|
||||
|
||||
let existing = XPIStates.findAddon(id, loc => loc != tempLocation);
|
||||
let callUpdate = false;
|
||||
if (existing) {
|
||||
reason = newVersionReason(addon.version, existing.version);
|
||||
callUpdate = (isWebExtension(addon.type) && isWebExtension(existing.type));
|
||||
}
|
||||
|
||||
this.callBootstrapMethod(addon, addon.file, "shutdown", reason);
|
||||
this.callBootstrapMethod(addon, addon.file, "uninstall", reason);
|
||||
if (!callUpdate) {
|
||||
this.callBootstrapMethod(addon, addon.file, "uninstall", reason);
|
||||
}
|
||||
this.unloadBootstrapScope(id);
|
||||
TemporaryInstallLocation.uninstallAddon(id);
|
||||
XPIStates.removeAddon(TemporaryInstallLocation.name, id);
|
||||
|
@ -2408,7 +2412,8 @@ this.XPIProvider = {
|
|||
let file = new nsIFile(newAddon.path);
|
||||
|
||||
let data = {oldVersion: addon.version};
|
||||
this.callBootstrapMethod(newAddon, file, "install", reason, data);
|
||||
let method = callUpdate ? "update" : "install";
|
||||
this.callBootstrapMethod(newAddon, file, method, reason, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3553,6 +3558,7 @@ this.XPIProvider = {
|
|||
let installReason = BOOTSTRAP_REASONS.ADDON_INSTALL;
|
||||
let oldAddon = await new Promise(
|
||||
resolve => XPIDatabase.getVisibleAddonForID(addon.id, resolve));
|
||||
let callUpdate = false;
|
||||
|
||||
let extraParams = {};
|
||||
extraParams.temporarilyInstalled = aInstallLocation === TemporaryInstallLocation;
|
||||
|
@ -3581,13 +3587,18 @@ this.XPIProvider = {
|
|||
extraParams.newVersion = newVersion;
|
||||
extraParams.oldVersion = oldVersion;
|
||||
|
||||
callUpdate = isWebExtension(oldAddon.type) && isWebExtension(addon.type);
|
||||
|
||||
if (oldAddon.active) {
|
||||
XPIProvider.callBootstrapMethod(oldAddon, existingAddon,
|
||||
"shutdown", uninstallReason,
|
||||
extraParams);
|
||||
}
|
||||
this.callBootstrapMethod(oldAddon, existingAddon,
|
||||
"uninstall", uninstallReason, extraParams);
|
||||
|
||||
if (!callUpdate) {
|
||||
this.callBootstrapMethod(oldAddon, existingAddon,
|
||||
"uninstall", uninstallReason, extraParams);
|
||||
}
|
||||
this.unloadBootstrapScope(existingAddonID);
|
||||
flushChromeCaches();
|
||||
}
|
||||
|
@ -3598,7 +3609,8 @@ this.XPIProvider = {
|
|||
let file = addon._sourceBundle;
|
||||
|
||||
XPIProvider._addURIMapping(addon.id, file);
|
||||
XPIProvider.callBootstrapMethod(addon, file, "install", installReason, extraParams);
|
||||
let method = callUpdate ? "update" : "install";
|
||||
XPIProvider.callBootstrapMethod(addon, file, method, installReason, extraParams);
|
||||
addon.state = AddonManager.STATE_INSTALLED;
|
||||
logger.debug("Install of temporary addon in " + aFile.path + " completed.");
|
||||
addon.visible = true;
|
||||
|
@ -4653,10 +4665,12 @@ this.XPIProvider = {
|
|||
}
|
||||
|
||||
let reason = BOOTSTRAP_REASONS.ADDON_UNINSTALL;
|
||||
let callUpdate = false;
|
||||
let existingAddon = XPIStates.findAddon(aAddon.id, loc =>
|
||||
loc.name != aAddon._installLocation.name);
|
||||
if (existingAddon) {
|
||||
reason = newVersionReason(aAddon.version, existingAddon.version);
|
||||
callUpdate = isWebExtension(aAddon.type) && isWebExtension(existingAddon.type);
|
||||
}
|
||||
|
||||
if (!makePending) {
|
||||
|
@ -4666,8 +4680,10 @@ this.XPIProvider = {
|
|||
reason);
|
||||
}
|
||||
|
||||
this.callBootstrapMethod(aAddon, aAddon._sourceBundle, "uninstall",
|
||||
reason);
|
||||
if (!callUpdate) {
|
||||
this.callBootstrapMethod(aAddon, aAddon._sourceBundle, "uninstall",
|
||||
reason);
|
||||
}
|
||||
XPIStates.disableAddon(aAddon.id);
|
||||
this.unloadBootstrapScope(aAddon.id);
|
||||
flushChromeCaches();
|
||||
|
@ -4689,8 +4705,9 @@ this.XPIProvider = {
|
|||
}
|
||||
|
||||
if (aAddon.bootstrap) {
|
||||
let method = callUpdate ? "update" : "install";
|
||||
XPIProvider.callBootstrapMethod(existing, existing._sourceBundle,
|
||||
"install", reason);
|
||||
method, reason);
|
||||
|
||||
if (existing.active) {
|
||||
XPIProvider.callBootstrapMethod(existing, existing._sourceBundle,
|
||||
|
|
Загрузка…
Ссылка в новой задаче