Bug 1494615 - Move ADBAddon module to devtools/shared/adb;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 03 Oct 2018 13:34:40 +0000
changeset 495386 3d5b641b9783187b6dba552bb246ec6d28d0dbbd
parent 495385 274c5774f6fb762d3124b11dd21824edf2d1301a
child 495387 0869291895c4d5810aefdfd94ca75091ca6127de
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko
bugs1494615
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1494615 - Move ADBAddon module to devtools/shared/adb;r=ladybenko Depends on D7402. Moving the module to a shared older. Following patches will cleanup the implementation to remove WebIDE couplings. Differential Revision: https://phabricator.services.mozilla.com/D7403
devtools/client/aboutdebugging-new/src/modules/usb-runtimes.js
devtools/client/webide/content/addons.js
devtools/client/webide/content/webide.js
devtools/client/webide/modules/addons.js
devtools/client/webide/modules/moz.build
devtools/shared/adb/adb-addon.js
devtools/shared/adb/moz.build
--- a/devtools/client/aboutdebugging-new/src/modules/usb-runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/modules/usb-runtimes.js
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const { ADBScanner } = require("devtools/shared/adb/adb-scanner");
-const { getADBAddon } = require("devtools/client/webide/modules/addons");
+const { getADBAddon } = require("devtools/shared/adb/adb-addon");
 
 /**
  * This module provides a collection of helper methods to detect USB runtimes whom Firefox
  * is running on.
  */
 function addUSBRuntimesObserver(listener) {
   ADBScanner.on("runtime-list-updated", listener);
 }
--- a/devtools/client/webide/content/addons.js
+++ b/devtools/client/webide/content/addons.js
@@ -1,17 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
+
 const Services = require("Services");
+const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties");
+
 const {gDevTools} = require("devtools/client/framework/devtools");
-const {getADBAddon, forgetADBAddon} = require("devtools/client/webide/modules/addons");
-const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties");
+const {getADBAddon, forgetADBAddon} = require("devtools/shared/adb/adb-addon");
 const {ADBScanner} = require("devtools/shared/adb/adb-scanner");
 const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes");
 
 window.addEventListener("load", function() {
   document.querySelector("#aboutaddons").onclick = function() {
     const browserWin = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
     if (browserWin && browserWin.BrowserOpenAddonsMgr) {
       browserWin.BrowserOpenAddonsMgr("addons://list/extension");
--- a/devtools/client/webide/content/webide.js
+++ b/devtools/client/webide/content/webide.js
@@ -11,17 +11,17 @@ const {gDevTools} = require("devtools/cl
 const {gDevToolsBrowser} = require("devtools/client/framework/devtools-browser");
 const {Toolbox} = require("devtools/client/framework/toolbox");
 const Services = require("Services");
 const {AppProjects} = require("devtools/client/webide/modules/app-projects");
 const {Connection} = require("devtools/shared/client/connection-manager");
 const {AppManager} = require("devtools/client/webide/modules/app-manager");
 const EventEmitter = require("devtools/shared/event-emitter");
 const promise = require("promise");
-const {getADBAddon} = require("devtools/client/webide/modules/addons");
+const {getADBAddon} = require("devtools/shared/adb/adb-addon");
 const {getJSON} = require("devtools/client/shared/getjson");
 const Telemetry = require("devtools/client/shared/telemetry");
 const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes");
 const {openContentLink} = require("devtools/client/shared/link");
 
 const Strings =
   Services.strings.createBundle("chrome://devtools/locale/webide.properties");
 
--- a/devtools/client/webide/modules/moz.build
+++ b/devtools/client/webide/modules/moz.build
@@ -1,16 +1,15 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DevToolsModules(
-    'addons.js',
     'app-manager.js',
     'app-projects.js',
     'app-validator.js',
     'config-view.js',
     'project-list.js',
     'runtime-list.js',
     'runtime-types.js',
     'runtimes.js',
rename from devtools/client/webide/modules/addons.js
rename to devtools/shared/adb/adb-addon.js
--- a/devtools/client/webide/modules/addons.js
+++ b/devtools/shared/adb/adb-addon.js
@@ -4,52 +4,54 @@
 
 "use strict";
 
 const {AddonManager} = require("resource://gre/modules/AddonManager.jsm");
 const {Devices} = require("resource://devtools/shared/apps/Devices.jsm");
 const Services = require("Services");
 const EventEmitter = require("devtools/shared/event-emitter");
 
-var ADB_LINK = Services.prefs.getCharPref("devtools.remote.adb.extensionURL");
-var ADB_ADDON_ID = Services.prefs.getCharPref("devtools.remote.adb.extensionID");
+const ADB_LINK = Services.prefs.getCharPref("devtools.remote.adb.extensionURL");
+const ADB_ADDON_ID = Services.prefs.getCharPref("devtools.remote.adb.extensionID");
 
 // Extension ID for adb helper extension that might be installed on Firefox 63 or older.
 const OLD_ADB_ADDON_ID = "adbhelper@mozilla.org";
 
-var platform = Services.appShell.hiddenDOMWindow.navigator.platform;
-var OS = "";
+const platform = Services.appShell.hiddenDOMWindow.navigator.platform;
+let OS = "";
 if (platform.includes("Win")) {
   OS = "win32";
 } else if (platform.includes("Mac")) {
   OS = "mac64";
 } else if (platform.includes("Linux")) {
   if (platform.includes("x86_64")) {
     OS = "linux64";
   } else {
     OS = "linux32";
   }
 }
 
-var addonsListener = {};
+const addonsListener = {};
 addonsListener.onEnabled =
 addonsListener.onDisabled =
 addonsListener.onInstalled =
 addonsListener.onUninstalled = (updatedAddon) => {
   getADBAddon().updateInstallStatus();
 };
 AddonManager.addAddonListener(addonsListener);
 
-var adbAddon = null;
-var getADBAddon = exports.getADBAddon = function() {
+// adbAddon is the exposed singleton for ADBAddon.
+let adbAddon = null;
+function getADBAddon() {
   if (!adbAddon) {
     adbAddon = new ADBAddon();
   }
   return adbAddon;
-};
+}
+exports.getADBAddon = getADBAddon;
 
 exports.forgetADBAddon = function() {
   adbAddon = null;
 };
 
 function ADBAddon() {
   EventEmitter.decorate(this);
 
@@ -90,18 +92,22 @@ ADBAddon.prototype = {
     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"});
+      const install = await AddonManager.getInstallForURL(
+        this.xpiLink,
+        "application/x-xpinstall",
+        null, null, null, null, null,
+        { source: "webide" }
+      );
       install.addListener(this);
       install.install();
     }
   },
 
   uninstall: async function() {
     const addon = await AddonManager.getAddonByID(ADB_ADDON_ID);
     addon.uninstall();
--- a/devtools/shared/adb/moz.build
+++ b/devtools/shared/adb/moz.build
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DevToolsModules(
+    'adb-addon.js',
     'adb-binary.js',
     'adb-client.js',
     'adb-device.js',
     'adb-running-checker.js',
     'adb-scanner.js',
     'adb-socket.js',
     'adb.js',
 )