diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-13 19:11:37 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-02-13 19:11:37 +0100 |
commit | 43d44975b1f49df640916cca5f6a0b138696da3c (patch) | |
tree | 98b95bb1043fc6a599e3c02fbb9b1ee7a363bf89 /toolkit/components/webextensions/ext-management.js | |
parent | 6bb02d95f70000b150569089987701c8244d7d5d (diff) | |
download | UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.gz UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.lz UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.xz UXP-43d44975b1f49df640916cca5f6a0b138696da3c.zip |
Remove WebExtension support from the platform.
- Conditional code
- WE APIs
- WE toolkit theming
Diffstat (limited to 'toolkit/components/webextensions/ext-management.js')
-rw-r--r-- | toolkit/components/webextensions/ext-management.js | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/toolkit/components/webextensions/ext-management.js b/toolkit/components/webextensions/ext-management.js deleted file mode 100644 index 59a7959d7..000000000 --- a/toolkit/components/webextensions/ext-management.js +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set sts=2 sw=2 et tw=80: */ -"use strict"; - -const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; - -XPCOMUtils.defineLazyGetter(this, "strBundle", function() { - const stringSvc = Cc["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService); - return stringSvc.createBundle("chrome://global/locale/extensions.properties"); -}); -XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", - "resource://gre/modules/AddonManager.jsm"); -XPCOMUtils.defineLazyServiceGetter(this, "promptService", - "@mozilla.org/embedcomp/prompt-service;1", - "nsIPromptService"); - -function _(key, ...args) { - if (args.length) { - return strBundle.formatStringFromName(key, args, args.length); - } - return strBundle.GetStringFromName(key); -} - -function installType(addon) { - if (addon.temporarilyInstalled) { - return "development"; - } else if (addon.foreignInstall) { - return "sideload"; - } else if (addon.isSystem) { - return "other"; - } - return "normal"; -} - -extensions.registerSchemaAPI("management", "addon_parent", context => { - let {extension} = context; - return { - management: { - getSelf: function() { - return new Promise((resolve, reject) => AddonManager.getAddonByID(extension.id, addon => { - try { - let m = extension.manifest; - let extInfo = { - id: extension.id, - name: addon.name, - shortName: m.short_name || "", - description: addon.description || "", - version: addon.version, - mayDisable: !!(addon.permissions & AddonManager.PERM_CAN_DISABLE), - enabled: addon.isActive, - optionsUrl: addon.optionsURL || "", - permissions: Array.from(extension.permissions).filter(perm => { - return !extension.whiteListedHosts.pat.includes(perm); - }), - hostPermissions: extension.whiteListedHosts.pat, - installType: installType(addon), - }; - if (addon.homepageURL) { - extInfo.homepageUrl = addon.homepageURL; - } - if (addon.updateURL) { - extInfo.updateUrl = addon.updateURL; - } - if (m.icons) { - extInfo.icons = Object.keys(m.icons).map(key => { - return {size: Number(key), url: m.icons[key]}; - }); - } - - resolve(extInfo); - } catch (err) { - reject(err); - } - })); - }, - - uninstallSelf: function(options) { - return new Promise((resolve, reject) => { - if (options && options.showConfirmDialog) { - let message = _("uninstall.confirmation.message", extension.name); - if (options.dialogMessage) { - message = `${options.dialogMessage}\n${message}`; - } - let title = _("uninstall.confirmation.title", extension.name); - let buttonFlags = promptService.BUTTON_POS_0 * promptService.BUTTON_TITLE_IS_STRING + - promptService.BUTTON_POS_1 * promptService.BUTTON_TITLE_IS_STRING; - let button0Title = _("uninstall.confirmation.button-0.label"); - let button1Title = _("uninstall.confirmation.button-1.label"); - let response = promptService.confirmEx(null, title, message, buttonFlags, button0Title, button1Title, null, null, {value: 0}); - if (response == 1) { - return reject({message: "User cancelled uninstall of extension"}); - } - } - AddonManager.getAddonByID(extension.id, addon => { - let canUninstall = Boolean(addon.permissions & AddonManager.PERM_CAN_UNINSTALL); - if (!canUninstall) { - return reject({message: "The add-on cannot be uninstalled"}); - } - try { - addon.uninstall(); - } catch (err) { - return reject(err); - } - }); - }); - }, - }, - }; -}); |