Bug 1522820 - Disable browser action's "Remove Extension" if the addon can't be uninstalled. r=Felipe

Differential Revision: https://phabricator.services.mozilla.com/D18493

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Oriol Brufau 2019-02-06 17:18:32 +00:00
parent e8a4c6f7a9
commit 9a121796e0

View File

@ -6339,18 +6339,29 @@ var ToolbarContextMenu = {
return triggerNode;
},
updateExtension(popup) {
_getExtensionId(popup) {
let node = this._getUnwrappedTriggerNode(popup);
return node && node.getAttribute("data-extensionid");
},
async updateExtension(popup) {
let removeExtension = popup.querySelector(".customize-context-removeExtension");
let manageExtension = popup.querySelector(".customize-context-manageExtension");
let separator = removeExtension.nextElementSibling;
let node = this._getUnwrappedTriggerNode(popup);
let isWebExt = node && node.hasAttribute("data-extensionid");
removeExtension.hidden = manageExtension.hidden = separator.hidden = !isWebExt;
let id = this._getExtensionId(popup);
let addon = id && await AddonManager.getAddonByID(id);
removeExtension.hidden = manageExtension.hidden = separator.hidden = !addon;
if (addon) {
removeExtension.disabled = !(addon.permissions & AddonManager.PERM_CAN_UNINSTALL);
}
},
async removeExtensionForContextAction(popup) {
let id = this._getUnwrappedTriggerNode(popup).getAttribute("data-extensionid");
let addon = await AddonManager.getAddonByID(id);
let id = this._getExtensionId(popup);
let addon = id && await AddonManager.getAddonByID(id);
if (!addon || !(addon.permissions & AddonManager.PERM_CAN_UNINSTALL)) {
return;
}
let {name} = addon;
let brand = document.getElementById("bundle_brand").getString("brandShorterName");
let {getFormattedString, getString} = gNavigatorBundle;
@ -6368,9 +6379,11 @@ var ToolbarContextMenu = {
},
openAboutAddonsForContextAction(popup) {
let id = this._getUnwrappedTriggerNode(popup).getAttribute("data-extensionid");
let viewID = "addons://detail/" + encodeURIComponent(id);
BrowserOpenAddonsMgr(viewID);
let id = this._getExtensionId(popup);
if (id) {
let viewID = "addons://detail/" + encodeURIComponent(id);
BrowserOpenAddonsMgr(viewID);
}
},
};