process-component-data.js (1547B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 l10n, 9 } = require("resource://devtools/client/aboutdebugging/src/modules/l10n.js"); 10 11 const { 12 DEBUG_TARGETS, 13 REQUEST_PROCESSES_SUCCESS, 14 } = require("resource://devtools/client/aboutdebugging/src/constants.js"); 15 16 /** 17 * This middleware converts tabs object that get from DevToolsClient.listProcesses() to 18 * data which is used in DebugTargetItem. 19 */ 20 const processComponentDataMiddleware = () => next => action => { 21 switch (action.type) { 22 case REQUEST_PROCESSES_SUCCESS: { 23 const mainProcessComponentData = toMainProcessComponentData( 24 action.mainProcess 25 ); 26 action.processes = [mainProcessComponentData]; 27 break; 28 } 29 } 30 31 return next(action); 32 }; 33 34 function toMainProcessComponentData() { 35 const type = DEBUG_TARGETS.PROCESS; 36 const icon = "chrome://devtools/skin/images/aboutdebugging-process-icon.svg"; 37 38 // For now, we assume there is only one process and this is the main process 39 // So the name and title are for a remote (multiprocess) browser toolbox. 40 const name = l10n.getString("about-debugging-multiprocess-toolbox-name"); 41 const description = l10n.getString( 42 "about-debugging-multiprocess-toolbox-description" 43 ); 44 45 return { 46 name, 47 icon, 48 type, 49 details: { 50 description, 51 }, 52 }; 53 } 54 55 module.exports = processComponentDataMiddleware;