Bug 1502437 - Hide system add-ons in about:performance when browser internals are hidden, r=felipe.

This commit is contained in:
Florian Quèze 2018-10-31 19:10:51 +01:00
Родитель 97a292d889
Коммит 86f3147cb8
1 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -9,6 +9,7 @@
const { PerformanceStats } = ChromeUtils.import("resource://gre/modules/PerformanceStats.jsm", {});
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
const { ObjectUtils } = ChromeUtils.import("resource://gre/modules/ObjectUtils.jsm", {});
const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm", {});
const { ExtensionParent } = ChromeUtils.import("resource://gre/modules/ExtensionParent.jsm", {});
const {WebExtensionPolicy} = Cu.getGlobalForObject(Services);
@ -77,6 +78,13 @@ function extensionCountersEnabled() {
return Services.prefs.getBoolPref("extensions.webextensions.enablePerformanceCounters", false);
}
// The ids of system add-ons, so that we can hide them when the
// toolkit.aboutPerformance.showInternals pref is false.
// The API to access addons is async, so we cache the list during init.
// The list is unlikely to change while the about:performance
// tab is open, so not updating seems fine.
var gSystemAddonIds = new Set();
let tabFinder = {
update() {
this._map = new Map();
@ -636,7 +644,7 @@ var State = {
let addon = WebExtensionPolicy.getByHostname(host);
name = `${addon.name} (${addon.id})`;
image = "chrome://mozapps/skin/extensions/extensionGeneric-16.svg";
type = "addon";
type = gSystemAddonIds.has(addon.id) ? "system-addon" : "addon";
} else if (id == 0 && !tab.isWorker) {
name = {id: "ghost-windows"};
}
@ -1035,6 +1043,8 @@ var View = {
row.appendChild(elt);
elt = document.createElement("td");
if (type == "system-addon")
type = "addon";
document.l10n.setAttributes(elt, "type-" + type);
row.appendChild(elt);
@ -1358,6 +1368,13 @@ var go = async function() {
let opt = document.querySelector(".options");
opt.style.display = "none";
opt.nextElementSibling.style.display = "none";
let addons = await AddonManager.getAddonsByTypes(["extension"]);
for (let addon of addons) {
if (addon.isSystem) {
gSystemAddonIds.add(addon.id);
}
}
} else {
document.getElementById("dispatch-table").parentNode.style.display = "none";
}