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/. */
5 /* eslint-env mozilla/remote-page */
9 /* JavaScript to enumerate and display all installed plug-ins
11 * First, refresh plugins in case anything has been changed recently in
12 * prefs: (The "false" argument tells refresh not to reload or activate
13 * any plug-ins that would be active otherwise. In contrast, one would
14 * use "true" in the case of ASD instead of restarting)
16 navigator.plugins.refresh(false);
18 RPMSendQuery("RequestPlugins", {}).then(aPlugins => {
19 var fragment = document.createDocumentFragment();
21 window.ensureCustomElements("moz-message-bar");
23 // "Installed plugins"
25 if (aPlugins.length) {
27 label = "installed-plugins-label";
30 label = "no-plugins-are-installed-label";
32 var enabledplugins = document.createElement("h1");
33 enabledplugins.setAttribute("id", id);
34 document.l10n.setAttributes(enabledplugins, label);
35 fragment.appendChild(enabledplugins);
37 let deprecation = document.createElement("moz-message-bar");
38 let deprecationLink = document.createElement("a", { is: "moz-support-link" });
39 deprecationLink.setAttribute("support-page", "npapi");
40 deprecationLink.setAttribute("slot", "support-link");
41 deprecation.appendChild(deprecationLink);
42 deprecation.setAttribute("data-l10n-attrs", "message");
43 document.l10n.setAttributes(deprecation, "deprecation-description2");
44 fragment.appendChild(deprecation);
47 ["STATE_SOFTBLOCKED", "STATE_BLOCKED"].forEach(function (label) {
48 stateNames[Ci.nsIBlocklistService[label]] = label;
51 for (var i = 0; i < aPlugins.length; i++) {
52 var plugin = aPlugins[i];
55 var plugname = document.createElement("h2");
56 plugname.setAttribute("class", "plugname");
57 plugname.appendChild(document.createTextNode(plugin.name));
58 fragment.appendChild(plugname);
60 var dl = document.createElement("dl");
61 fragment.appendChild(dl);
63 // "File: Flash Player.plugin"
64 var fileDd = document.createElement("dd");
65 var file = document.createElement("span");
66 file.setAttribute("data-l10n-name", "file");
67 file.setAttribute("class", "label");
68 fileDd.appendChild(file);
69 document.l10n.setAttributes(fileDd, "file-dd", {
70 pluginLibraries: plugin.pluginLibraries[0] ?? "",
72 dl.appendChild(fileDd);
74 // "Path: /usr/lib/mozilla/plugins/libtotem-cone-plugin.so"
75 var pathDd = document.createElement("dd");
76 var path = document.createElement("span");
77 path.setAttribute("data-l10n-name", "path");
78 path.setAttribute("class", "label");
79 pathDd.appendChild(path);
80 document.l10n.setAttributes(pathDd, "path-dd", {
81 pluginFullPath: plugin.pluginFullpath[0] ?? "",
83 dl.appendChild(pathDd);
86 var versionDd = document.createElement("dd");
87 var version = document.createElement("span");
88 version.setAttribute("data-l10n-name", "version");
89 version.setAttribute("class", "label");
90 versionDd.appendChild(version);
91 document.l10n.setAttributes(versionDd, "version-dd", {
92 version: plugin.version ?? "",
94 dl.appendChild(versionDd);
97 var stateDd = document.createElement("dd");
98 var state = document.createElement("span");
99 state.setAttribute("data-l10n-name", "state");
100 state.setAttribute("label", "state");
101 stateDd.appendChild(state);
102 if (plugin.isActive) {
103 if (plugin.blocklistState in stateNames) {
104 document.l10n.setAttributes(
106 "state-dd-enabled-block-list-state",
107 { blockListState: stateNames[plugin.blocklistState] }
110 document.l10n.setAttributes(stateDd, "state-dd-enabled");
112 } else if (plugin.blocklistState in stateNames) {
113 document.l10n.setAttributes(
115 "state-dd-disabled-block-list-state",
116 { blockListState: stateNames[plugin.blocklistState] }
119 document.l10n.setAttributes(stateDd, "state-dd-disabled");
121 dl.appendChild(stateDd);
123 // Plugin Description
124 var descDd = document.createElement("dd");
125 descDd.appendChild(document.createTextNode(plugin.description));
126 dl.appendChild(descDd);
130 document.getElementById("outside").appendChild(fragment);