  }
  }

  return next(action);
};

function getFilePath(extension) {
  // Only show file system paths, and only for temporarily installed add-ons.
  if (
    !extension.temporarilyInstalled ||
    !extension.url ||
    !extension.url.startsWith("file://")
  ) {
    return null;
  }

  return parseFileUri(extension.url);
}

function toComponentData(extensions) {
  return extensions.map(extension => {
    const type = DEBUG_TARGETS.EXTENSION;
    const {
      actor,
      iconDataURL,
      iconURL,
      id,
      manifestURL,
      name,
      warnings,
    } = extension;
    const icon =
      iconDataURL ||
      iconURL ||
      "chrome://mozapps/skin/extensions/extensionGeneric.svg";
    const location = getFilePath(extension);
    const uuid = getExtensionUuid(extension);
    return {
      name,
      icon,
      id,
      type,
      details: {
        actor,
        location,
        manifestURL,
        uuid,
        warnings: warnings || [],
      },
    };
  });
}

module.exports = extensionComponentDataMiddleware;
PK