Bug 1477598 - Part 1: Implement a mechanism to dispatch extensions. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 10 Aug 2018 15:56:05 +0900
changeset 486280 a6ccfdee5d73e4acb85fdbfee7d78007ef659b82
parent 486279 13ec6b447cc53a5acec6063a892e824cb3d7c7b8
child 486281 72e1e5b24aaa8de32c254d19b68b70412414819d
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1477598
milestone63.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 1477598 - Part 1: Implement a mechanism to dispatch extensions. r=jdescottes Differential Revision: https://phabricator.services.mozilla.com/D3083
devtools/client/aboutdebugging-new/src/actions/runtime.js
devtools/client/aboutdebugging-new/src/components/RuntimePage.js
devtools/client/aboutdebugging-new/src/constants.js
devtools/client/aboutdebugging-new/src/reducers/runtime-state.js
--- a/devtools/client/aboutdebugging-new/src/actions/runtime.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtime.js
@@ -10,16 +10,19 @@ const { DebuggerServer } = require("devt
 const {
   CONNECT_RUNTIME_FAILURE,
   CONNECT_RUNTIME_START,
   CONNECT_RUNTIME_SUCCESS,
   DEBUG_TARGETS,
   DISCONNECT_RUNTIME_FAILURE,
   DISCONNECT_RUNTIME_START,
   DISCONNECT_RUNTIME_SUCCESS,
+  REQUEST_EXTENSIONS_FAILURE,
+  REQUEST_EXTENSIONS_START,
+  REQUEST_EXTENSIONS_SUCCESS,
   REQUEST_TABS_FAILURE,
   REQUEST_TABS_START,
   REQUEST_TABS_SUCCESS,
 } = require("../constants");
 
 function connectRuntime() {
   return async (dispatch, getState) => {
     dispatch({ type: CONNECT_RUNTIME_START });
@@ -27,16 +30,17 @@ function connectRuntime() {
     DebuggerServer.init();
     DebuggerServer.registerAllActors();
     const client = new DebuggerClient(DebuggerServer.connectPipe());
 
     try {
       await client.connect();
 
       dispatch({ type: CONNECT_RUNTIME_SUCCESS, client });
+      dispatch(requestExtensions());
       dispatch(requestTabs());
     } catch (e) {
       dispatch({ type: CONNECT_RUNTIME_FAILURE, error: e.message });
     }
   };
 }
 
 function disconnectRuntime() {
@@ -78,14 +82,37 @@ function requestTabs() {
 
       dispatch({ type: REQUEST_TABS_SUCCESS, tabs });
     } catch (e) {
       dispatch({ type: REQUEST_TABS_FAILURE, error: e.message });
     }
   };
 }
 
+function requestExtensions() {
+  return async (dispatch, getState) => {
+    dispatch({ type: REQUEST_EXTENSIONS_START });
+
+    const client = getState().runtime.client;
+
+    try {
+      const { addons } = await client.listAddons();
+      const extensions = addons.filter(a => a.debuggable);
+      const installedExtensions = extensions.filter(e => !e.temporarilyInstalled);
+      const temporaryExtensions = extensions.filter(e => e.temporarilyInstalled);
+
+      dispatch({
+        type: REQUEST_EXTENSIONS_SUCCESS,
+        installedExtensions,
+        temporaryExtensions,
+      });
+    } catch (e) {
+      dispatch({ type: REQUEST_EXTENSIONS_FAILURE, error: e.message });
+    }
+  };
+}
+
 module.exports = {
   connectRuntime,
   disconnectRuntime,
   inspectDebugTarget,
   requestTabs,
 };
--- a/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
+++ b/devtools/client/aboutdebugging-new/src/components/RuntimePage.js
@@ -13,40 +13,53 @@ const DebugTargetPane = createFactory(re
 const RuntimeInfo = createFactory(require("./RuntimeInfo"));
 
 const Services = require("Services");
 
 class RuntimePage extends PureComponent {
   static get propTypes() {
     return {
       dispatch: PropTypes.func.isRequired,
+      installedExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
       tabs: PropTypes.arrayOf(PropTypes.object).isRequired,
+      temporaryExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
     };
   }
 
   render() {
-    const { dispatch, tabs } = this.props;
+    const { dispatch, installedExtensions, tabs, temporaryExtensions } = this.props;
 
     return dom.article(
       {
         className: "page",
       },
       RuntimeInfo({
         icon: "chrome://branding/content/icon64.png",
         name: Services.appinfo.name,
         version: Services.appinfo.version,
       }),
       DebugTargetPane({
         dispatch,
         name: "Tabs",
         targets: tabs
       }),
+      // Temporary implementation
+      dom.ul(
+        {},
+        temporaryExtensions.map(e => dom.li({}, e.name))
+      ),
+      dom.ul(
+        {},
+        installedExtensions.map(e => dom.li({}, e.name))
+      ),
     );
   }
 }
 
 const mapStateToProps = state => {
   return {
+    installedExtensions: state.runtime.installedExtensions,
     tabs: state.runtime.tabs,
+    temporaryExtensions: state.runtime.temporaryExtensions,
   };
 };
 
 module.exports = connect(mapStateToProps)(RuntimePage);
--- a/devtools/client/aboutdebugging-new/src/constants.js
+++ b/devtools/client/aboutdebugging-new/src/constants.js
@@ -6,16 +6,19 @@
 
 const actionTypes = {
   CONNECT_RUNTIME_FAILURE: "CONNECT_RUNTIME_FAILURE",
   CONNECT_RUNTIME_START: "CONNECT_RUNTIME_START",
   CONNECT_RUNTIME_SUCCESS: "CONNECT_RUNTIME_SUCCESS",
   DISCONNECT_RUNTIME_FAILURE: "DISCONNECT_RUNTIME_FAILURE",
   DISCONNECT_RUNTIME_START: "DISCONNECT_RUNTIME_START",
   DISCONNECT_RUNTIME_SUCCESS: "DISCONNECT_RUNTIME_SUCCESS",
+  REQUEST_EXTENSIONS_FAILURE: "REQUEST_EXTENSIONS_FAILURE",
+  REQUEST_EXTENSIONS_START: "REQUEST_EXTENSIONS_START",
+  REQUEST_EXTENSIONS_SUCCESS: "REQUEST_EXTENSIONS_SUCCESS",
   REQUEST_TABS_FAILURE: "REQUEST_TABS_FAILURE",
   REQUEST_TABS_START: "REQUEST_TABS_START",
   REQUEST_TABS_SUCCESS: "REQUEST_TABS_SUCCESS",
   PAGE_SELECTED: "PAGE_SELECTED",
 };
 
 const DEBUG_TARGETS = {
   TAB: "TAB",
--- a/devtools/client/aboutdebugging-new/src/reducers/runtime-state.js
+++ b/devtools/client/aboutdebugging-new/src/reducers/runtime-state.js
@@ -3,35 +3,42 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const {
   CONNECT_RUNTIME_SUCCESS,
   DEBUG_TARGETS,
   DISCONNECT_RUNTIME_SUCCESS,
+  REQUEST_EXTENSIONS_SUCCESS,
   REQUEST_TABS_SUCCESS,
 } = require("../constants");
 
 function RuntimeState() {
   return {
     client: null,
+    installedExtensions: [],
     tabs: [],
+    temporaryExtensions: [],
   };
 }
 
 function runtimeReducer(state = RuntimeState(), action) {
   switch (action.type) {
     case CONNECT_RUNTIME_SUCCESS: {
       const { client } = action;
       return Object.assign({}, state, { client });
     }
     case DISCONNECT_RUNTIME_SUCCESS: {
       return RuntimeState();
     }
+    case REQUEST_EXTENSIONS_SUCCESS: {
+      const { installedExtensions, temporaryExtensions } = action;
+      return Object.assign({}, state, { installedExtensions, temporaryExtensions });
+    }
     case REQUEST_TABS_SUCCESS: {
       const { tabs } = action;
       return Object.assign({}, state, { tabs: toTabComponentData(tabs) });
     }
 
     default:
       return state;
   }