Bug 1494615 - Accept source parameter in adb-addon install();r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Thu, 04 Oct 2018 18:43:29 +0000
changeset 488034 aeb01a4cf6685b89f45c3c938a89dfd6190c9436
parent 488033 0869291895c4d5810aefdfd94ca75091ca6127de
child 488035 dfab2478409617ddb8cbd923228809aba1de3b09
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersladybenko
bugs1494615
milestone64.0a1
Bug 1494615 - Accept source parameter in adb-addon install();r=ladybenko Depends on D7404. The install method should not hardcode "webide" for the addon manager telemetry info Differential Revision: https://phabricator.services.mozilla.com/D7405
devtools/client/webide/content/addons.js
devtools/client/webide/content/webide.js
devtools/shared/adb/adb-addon.js
--- a/devtools/client/webide/content/addons.js
+++ b/devtools/client/webide/content/addons.js
@@ -75,17 +75,17 @@ function BuildUI() {
 
   const status = document.createElement("span");
   status.className = "status";
   status.textContent = Strings.GetStringFromName("addons_status_" + adbAddon.status);
   li.appendChild(status);
 
   const installButton = document.createElement("button");
   installButton.className = "install-button";
-  installButton.onclick = () => adbAddon.install();
+  installButton.onclick = () => adbAddon.install("webide");
   installButton.textContent = Strings.GetStringFromName("addons_install_button");
   li.appendChild(installButton);
 
   const uninstallButton = document.createElement("button");
   uninstallButton.className = "uninstall-button";
   uninstallButton.onclick = () => adbAddon.uninstall();
   uninstallButton.textContent = Strings.GetStringFromName("addons_uninstall_button");
   li.appendChild(uninstallButton);
--- a/devtools/client/webide/content/webide.js
+++ b/devtools/client/webide/content/webide.js
@@ -82,17 +82,17 @@ var UI = {
       console.error(e);
       this.reportError("error_appProjectsLoadFailed");
     });
 
     // Auto install the ADB Addon Helper. Only once.
     // If the user decides to uninstall any of this addon, we won't install it again.
     const autoinstallADBExtension = Services.prefs.getBoolPref("devtools.webide.autoinstallADBExtension");
     if (autoinstallADBExtension) {
-      adbAddon.install();
+      adbAddon.install("webide");
     }
 
     Services.prefs.setBoolPref("devtools.webide.autoinstallADBExtension", false);
 
     this.setupDeck();
 
     this.contentViewer = window.docShell.contentViewer;
     this.contentViewer.fullZoom = Services.prefs.getCharPref("devtools.webide.zoom");
--- a/devtools/shared/adb/adb-addon.js
+++ b/devtools/shared/adb/adb-addon.js
@@ -67,31 +67,38 @@ ADBAddon.prototype = {
     const addon = await AddonManager.getAddonByID(ADB_ADDON_ID);
     if (addon && !addon.userDisabled) {
       this.status = "installed";
     } else {
       this.status = "uninstalled";
     }
   },
 
-  install: async function() {
+  /**
+   * Install and enable the adb extension. Returns a promise that resolves when ADB is
+   * enabled.
+   *
+   * @param {String} source
+   *        String passed to the AddonManager for telemetry.
+   */
+  install: async function(source) {
     const addon = await AddonManager.getAddonByID(ADB_ADDON_ID);
     if (addon && !addon.userDisabled) {
       this.status = "installed";
       return;
     }
     this.status = "preparing";
     if (addon && addon.userDisabled) {
       await addon.enable();
     } else {
       const install = await AddonManager.getInstallForURL(
         this.xpiLink,
         "application/x-xpinstall",
         null, null, null, null, null,
-        { source: "webide" }
+        { source }
       );
       install.addListener(this);
       install.install();
     }
   },
 
   uninstall: async function() {
     const addon = await AddonManager.getAddonByID(ADB_ADDON_ID);