Bug 375596: Didn't update extension over installed disabled previous version. r=robstrong

This commit is contained in:
dtownsend@oxymoronical.com 2007-08-25 16:36:25 -07:00
Родитель 37e6007080
Коммит 23e11027b4
9 изменённых файлов: 180 добавлений и 44 удалений

Просмотреть файл

@ -67,12 +67,22 @@
<!ENTITY cmd.cancelUninstall.label "Cancel Uninstall">
<!ENTITY cmd.cancelUninstall.accesskey "C">
<!ENTITY cmd.cancelUninstall.tooltip "Cancel the uninstall of this Add-on">
<!ENTITY cmd.cancelInstall.label "Cancel Install">
<!ENTITY cmd.cancelInstall.accesskey "C">
<!ENTITY cmd.cancelInstall.tooltip "Cancel the install of this Add-on">
<!ENTITY cmd.cancelUpgrade.label "Cancel Upgrade">
<!ENTITY cmd.cancelUpgrade.accesskey "C">
<!ENTITY cmd.cancelUpgrade.tooltip "Cancel the upgrade of this Add-on">
<!ENTITY cmd.installUpdate.label "Install Update">
<!ENTITY cmd.installUpdate.accesskey "I">
<!ENTITY cmd.installUpdate.tooltip "Install an update for this Add-on">
<!-- The selected add-on's cancel action button label -->
<!ENTITY cancel.label "Cancel">
<!ENTITY cancel.accesskey "C">
<!ENTITY cancelInstall.label "Cancel">
<!ENTITY cancelInstall.accesskey "C">
<!ENTITY cancelUpgrade.label "Cancel">
<!ENTITY cancelUpgrade.accesskey "C">
<!-- Only displayed in the selected Add-on's context menu -->
<!ENTITY cmd.homepage.label "Visit Home Page">

Просмотреть файл

@ -27,6 +27,14 @@ moreInfoText=More information
uninstallTitle=Uninstall %S
uninstallWarnDependMsg=%S is required by one or more add-ons. If you continue, the following items will be disabled:
uninstallQueryMessage=Do you want to uninstall %S?
cancelInstallTitle=Cancel Install of %S
cancelInstallQueryMessage=Are you sure you want to cancel the install of %S?
cancelInstallButton=Yes
cancelCancelInstallButton=No
cancelUpgradeTitle=Cancel Upgrade of %S
cancelUpgradeQueryMessage=Are you sure you want to cancel the upgrade of %S?
cancelUpgradeButton=Yes
cancelCancelUpgradeButton=No
disableTitle=Disable %S
disableWarningDependMessage=If you disable %S, the following items that require this extension will also be disabled:
disableQueryMessage=Do you want to disable %S?

Просмотреть файл

@ -1130,7 +1130,8 @@ function onAddonSelect(aEvent)
// View Context Menus
var gAddonContextMenus = ["menuitem_useTheme", "menuitem_options", "menuitem_homepage",
"menuitem_about", "menuseparator_1", "menuitem_uninstall",
"menuitem_cancelUninstall", "menuitem_checkUpdate",
"menuitem_cancelUninstall", "menuitem_cancelInstall",
"menuitem_cancelUpgrade", "menuitem_checkUpdate",
"menuitem_enable", "menuitem_disable"];
var gUpdateContextMenus = ["menuitem_homepage", "menuitem_about", "menuseparator_1",
"menuitem_installUpdate", "menuitem_includeUpdate"];
@ -1174,11 +1175,17 @@ function buildContextMenu(aEvent)
var name = selectedItem ? selectedItem.getAttribute("name") : "";
menuitem_about.setAttribute("label", getExtensionString("aboutAddon", [name]));
// When performing update or install tasks we don't support uninstall
/* When an update or install is pending allow canceling the update or install
and don't allow uninstall. When an uninstall is pending allow canceling the
uninstall.*/
if (gView != "updates" && gView != "installs") {
var canEnable = gExtensionsViewController.isCommandEnabled("cmd_cancelUninstall");
document.getElementById("menuitem_cancelUninstall_clone").hidden = !canEnable;
document.getElementById("menuitem_uninstall_clone").hidden = canEnable;
var canCancelInstall = gExtensionsViewController.isCommandEnabled("cmd_cancelInstall");
document.getElementById("menuitem_cancelInstall_clone").hidden = !canCancelInstall;
var canCancelUpgrade = gExtensionsViewController.isCommandEnabled("cmd_cancelUpgrade");
document.getElementById("menuitem_cancelUpgrade_clone").hidden = !canCancelUpgrade;
document.getElementById("menuitem_uninstall_clone").hidden = canEnable || canCancelInstall || canCancelUpgrade;
}
switch (gView) {
@ -1200,16 +1207,16 @@ function buildContextMenu(aEvent)
document.getElementById("menuitem_options_clone").hidden = true;
document.getElementById("menuitem_disable_clone").hidden = true;
break;
case "locales":
case "plugins":
document.getElementById("menuitem_about_clone").hidden = true;
document.getElementById("menuitem_uninstall_clone").hidden = true;
document.getElementById("menuitem_checkUpdate_clone").hidden = true;
case "locales":
canEnable = gExtensionsViewController.isCommandEnabled("cmd_reallyEnable");
document.getElementById("menuitem_enable_clone").hidden = !canEnable;
document.getElementById("menuitem_disable_clone").hidden = canEnable;
document.getElementById("menuitem_useTheme_clone").hidden = true;
document.getElementById("menuitem_options_clone").hidden = true;
document.getElementById("menuitem_about_clone").hidden = true;
document.getElementById("menuitem_uninstall_clone").hidden = true;
document.getElementById("menuitem_checkUpdate_clone").hidden = true;
break;
case "updates":
var includeUpdate = document.getAnonymousElementByAttribute(selectedItem, "anonid", "includeUpdate");
@ -1597,6 +1604,27 @@ function closeEM() {
closeWindow(true);
}
function confirmOperation(aName, aTitle, aQueryMsg, aAcceptBtn, aCancelBtn,
aWarnMsg, aDependantItems) {
var params = {
message2: getExtensionString(aQueryMsg, [aName]),
title: getExtensionString(aTitle, [aName]),
buttons: {
accept: { label: getExtensionString(aAcceptBtn) },
cancel: { label: getExtensionString(aCancelBtn), focused: true }
}
}
if (aDependantItems.length > 0)
params.message1 = getExtensionString(aWarnMsg, [aName]);
var names = [];
for (var i = 0; i < aDependantItems.length; ++i)
names.push(aDependantItems[i].name + " " + aDependantItems[i].version);
window.openDialog("chrome://mozapps/content/extensions/list.xul", "",
"titlebar,modal,centerscreen", names, params);
return params.result == "accept";
}
var gExtensionsViewController = {
supportsCommand: function (aCommand)
{
@ -1643,6 +1671,10 @@ var gExtensionsViewController = {
!gExtensionsView.hasAttribute("update-operation");
case "cmd_cancelUninstall":
return selectedItem.opType == OP_NEEDS_UNINSTALL;
case "cmd_cancelInstall":
return selectedItem.opType == OP_NEEDS_INSTALL;
case "cmd_cancelUpgrade":
return selectedItem.opType == OP_NEEDS_UPGRADE;
case "cmd_checkUpdate":
return selectedItem.getAttribute("updateable") != "false" &&
!gExtensionsView.hasAttribute("update-operation");
@ -1829,24 +1861,10 @@ var gExtensionsViewController = {
var name = aSelectedItem.getAttribute("name");
var id = getIDFromResourceURI(aSelectedItem.id);
var dependentItems = gExtensionManager.getDependentItemListForID(id, true, { });
var params = {
message2: getExtensionString("uninstallQueryMessage", [name]),
title: getExtensionString("uninstallTitle", [name]),
buttons: {
accept: { label: getExtensionString("uninstallButton"),
focused: true },
cancel: { label: getExtensionString("cancelButton") }
}
}
if (dependentItems.length > 0)
params.message1 = getExtensionString("uninstallWarnDependMsg", [name]);
var names = [];
for (var i = 0; i < dependentItems.length; ++i)
names.push(dependentItems[i].name + " " + dependentItems[i].version);
window.openDialog("chrome://mozapps/content/extensions/list.xul", "",
"titlebar,modal,centerscreen", names, params);
if (params.result != "accept")
var result = confirmOperation(name, "uninstallTitle", "uninstallQueryMessage",
"uninstallButton", "cancelButton",
"uninstallWarnDependMsg", dependentItems);
if (!result)
return;
if (aSelectedItem.type == nsIUpdateItem.TYPE_THEME) {
@ -1876,6 +1894,39 @@ var gExtensionsViewController = {
updateOptionalViews();
},
cmd_cancelInstall: function (aSelectedItem)
{
var name = aSelectedItem.getAttribute("name");
var result = false;
// Confirm cancelling the operation
switch (aSelectedItem.opType)
{
case OP_NEEDS_INSTALL:
result = confirmOperation(name, "cancelInstallTitle", "cancelInstallQueryMessage",
"cancelInstallButton", "cancelCancelInstallButton",
null, []);
break;
case OP_NEEDS_UPGRADE:
result = confirmOperation(name, "cancelUpgradeTitle", "cancelUpgradeQueryMessage",
"cancelUpgradeButton", "cancelCancelUpgradeButton",
null, []);
break;
}
if (!result)
return;
gExtensionManager.cancelInstallItem(getIDFromResourceURI(aSelectedItem.id));
gExtensionsViewController.onCommandUpdate();
updateGlobalCommands();
gExtensionsView.selectedItem.focus();
updateOptionalViews();
},
cmd_cancelUpgrade: function (aSelectedItem)
{
this.cmd_cancelInstall(aSelectedItem);
},
cmd_disable: function (aSelectedItem)
{
if (aSelectedItem.getAttribute("plugin") == "true") {
@ -1888,24 +1939,10 @@ var gExtensionsViewController = {
if (dependentItems.length > 0) {
var name = aSelectedItem.getAttribute("name");
var message = getExtensionString("disableWarningDependMessage", [name]);
var params = {
message1: message,
message2: getExtensionString("disableQueryMessage", [name]),
title: getExtensionString("disableTitle", [name]),
buttons: {
accept: { label: getExtensionString("disableButton"),
focused: true },
cancel: { label: getExtensionString("cancelButton") }
}
}
var names = [];
for (var i = 0; i < dependentItems.length; ++i)
names.push(dependentItems[i].name + " " + dependentItems[i].version);
window.openDialog("chrome://mozapps/content/extensions/list.xul", "",
"titlebar,modal,centerscreen", names, params);
if (params.result != "accept")
var result = confirmOperation(name, "disableTitle", "disableQueryMessage",
"disableButton", "cancelButton",
"disableWarningDependMessage", dependentItems);
if (!result)
return;
}
gExtensionManager.disableItem(id);

Просмотреть файл

@ -274,6 +274,12 @@
<xul:button class="uninstallShow cancelUninstallButton" label="&cancel.label;"
accesskey="&cancel.accesskey;" tooltiptext="&cmd.cancelUninstall.tooltip;"
command="cmd_cancelUninstall"/>
<xul:button class="installShow cancelInstallButton" label="&cancelInstall.label;"
accesskey="&cancelInstall.accesskey;" tooltiptext="&cmd.cancelInstall.tooltip;"
command="cmd_cancelInstall"/>
<xul:button class="upgradeShow cancelUpgradeButton" label="&cancelUpgrade.label;"
accesskey="&cancelUpgrade.accesskey;" tooltiptext="&cmd.cancelUpgrade.tooltip;"
command="cmd_cancelUpgrade"/>
</xul:hbox>
</xul:vbox>
</xul:hbox>

Просмотреть файл

@ -93,6 +93,8 @@
<command id="cmd_homepage"/>
<command id="cmd_uninstall"/>
<command id="cmd_cancelUninstall"/>
<command id="cmd_cancelInstall"/>
<command id="cmd_cancelUpgrade"/>
<command id="cmd_checkUpdate"/>
<command id="cmd_includeUpdate"/>
<command id="cmd_installUpdate"/>
@ -128,6 +130,10 @@
label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;"/>
<menuitem id="menuitem_cancelUninstall" command="cmd_cancelUninstall"
label="&cmd.cancelUninstall.label;" accesskey="&cmd.cancelUninstall.accesskey;"/>
<menuitem id="menuitem_cancelInstall" command="cmd_cancelInstall"
label="&cmd.cancelInstall.label;" accesskey="&cmd.cancelInstall.accesskey;"/>
<menuitem id="menuitem_cancelUpgrade" command="cmd_cancelUpgrade"
label="&cmd.cancelUpgrade.label;" accesskey="&cmd.cancelUpgrade.accesskey;"/>
<menuitem id="menuitem_checkUpdate" command="cmd_checkUpdate"
label="&cmd.checkUpdate.label;" accesskey="&cmd.checkUpdate.accesskey;"/>
<menuitem id="menuitem_enable" command="cmd_enable"

Просмотреть файл

@ -197,7 +197,7 @@ interface nsIInstallLocation : nsISupports
* XXXben - Some of this stuff should go into a management-ey interface,
* some into an app-startup-ey interface.
*/
[scriptable, uuid(c2aef3c3-8ce1-4470-94e4-1167e5ca8928)]
[scriptable, uuid(f5c34a77-3487-4b70-a65a-6727fa066324)]
interface nsIExtensionManager : nsISupports
{
/**
@ -406,6 +406,14 @@ interface nsIExtensionManager : nsISupports
*/
void moveToIndexOf(in AString movingID, in AString destinationID);
/**
* Cancels a pending install or upgrade of an item. If the item does
* not have a pending install or upgrade then this will do nothing.
* @param id
* The ID of the item.
*/
void cancelInstallItem(in AString id);
/**
* Cancels a pending uninstall of an item
* @param id

Просмотреть файл

@ -4663,6 +4663,8 @@ ExtensionManager.prototype = {
this._updateManifests(false);
}
else {
if (opType == OP_NEEDS_UPGRADE)
ds.setItemProperty(id, "newVersion", null);
this._setOp(id, OP_NEEDS_UNINSTALL);
var type = ds.getItemProperty(id, "type");
var restartRequired = this.installRequiresRestart(id, type);
@ -4681,6 +4683,53 @@ ExtensionManager.prototype = {
this._notifyAction(id, EM_ITEM_UNINSTALLED);
},
/* See nsIExtensionManager.idl */
cancelInstallItem: function(id) {
var ds = this.datasource;
var opType = ds.getItemProperty(id, "opType");
if (opType != OP_NEEDS_UPGRADE && opType != OP_NEEDS_INSTALL)
return;
ds.updateDownloadState(PREFIX_ITEM_URI + id, null);
var installLocation = this.getInstallLocation(id);
// Removes any staged xpis for this item.
var stageFile = installLocation.getStageFile(id);
if (stageFile)
installLocation.removeFile(stageFile);
// Addons with an opType of OP_NEEDS_INSTALL only have a staged xpi file
// and just need to be removed completely from the ds.
if (opType == OP_NEEDS_INSTALL) {
ds.removeItemMetadata(id);
ds.removeItemFromContainer(id);
ds.updateVisibleList(id, null, true);
StartupCache.clearEntry(installLocation, id);
this._updateManifests(false);
this._notifyAction(id, EM_ITEM_CANCEL);
}
else {
// Clear upgrade information and reset any request to enable/disable.
ds.setItemProperty(id, EM_R("newVersion"), null);
var appDisabled = ds.getItemProperty(id, "appDisabled");
var userDisabled = ds.getItemProperty(id, "userDisabled");
if (appDisabled == "true" || appDisabled == OP_NONE && userDisabled == OP_NONE) {
this._setOp(id, OP_NONE);
this._notifyAction(id, EM_ITEM_CANCEL);
}
else if (appDisabled == OP_NEEDS_DISABLE || userDisabled == OP_NEEDS_DISABLE) {
this._setOp(id, OP_NEEDS_DISABLE);
this._notifyAction(id, EM_ITEM_DISABLED);
}
else if (appDisabled == OP_NEEDS_ENABLE || userDisabled == OP_NEEDS_ENABLE) {
this._setOp(id, OP_NEEDS_ENABLE);
this._notifyAction(id, EM_ITEM_ENABLED);
}
else {
this._setOp(id, OP_NONE);
this._notifyAction(id, EM_ITEM_CANCEL);
}
}
},
/**
* Cancels a pending uninstall of an item
* @param id

Просмотреть файл

@ -168,11 +168,15 @@ richlistitem[satisfiesDependencies="false"] .notifyBadge {
.enableHide,
.uninstallShow,
.installShow,
.upgradeShow,
richlistitem[isDisabled="true"] .disableHide {
display: none;
}
richlistitem[opType="needs-uninstall"] .uninstallShow,
richlistitem[opType="needs-install"] .installShow,
richlistitem[opType="needs-upgrade"] .upgradeShow,
richlistitem[opType="needs-enable"] .enableShow,
richlistitem[opType="needs-disable"] .disableShow,
richlistitem[isDisabled="true"] .disableShow {
@ -180,6 +184,8 @@ richlistitem[isDisabled="true"] .disableShow {
}
richlistitem[opType="needs-uninstall"] .uninstallHide,
richlistitem[opType="needs-install"] .uninstallHide,
richlistitem[opType="needs-upgrade"] .uninstallHide,
richlistitem[opType="needs-enable"] .enableHide,
richlistitem[opType="needs-disable"] .disableHide {
display: none;

Просмотреть файл

@ -237,11 +237,15 @@ richlistitem[satisfiesDependencies="false"] .notifyBadge {
.enableHide,
.uninstallShow,
.installShow,
.upgradeShow,
richlistitem[isDisabled="true"] .disableHide {
display: none;
}
richlistitem[opType="needs-uninstall"] .uninstallShow,
richlistitem[opType="needs-install"] .installShow,
richlistitem[opType="needs-upgrade"] .upgradeShow,
richlistitem[opType="needs-enable"] .enableShow,
richlistitem[opType="needs-disable"] .disableShow,
richlistitem[isDisabled="true"] .disableShow {
@ -249,6 +253,8 @@ richlistitem[isDisabled="true"] .disableShow {
}
richlistitem[opType="needs-uninstall"] .uninstallHide,
richlistitem[opType="needs-install"] .uninstallHide,
richlistitem[opType="needs-upgrade"] .uninstallHide,
richlistitem[opType="needs-enable"] .enableHide,
richlistitem[opType="needs-disable"] .disableHide {
display: none;