gecko-dev/toolkit/content/plugins.html

237 lines
9.5 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2012-05-21 11:12:37 +00:00
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<html>
<head>
<script type="application/javascript">
"use strict";
Components.utils.import("resource://gre/modules/AddonManager.jsm");
var Ci = Components.interfaces;
var strBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
var pluginsbundle = strBundleService.createBundle("chrome://global/locale/plugins.properties");
var regionbundle = strBundleService.createBundle("chrome://global-region/locale/region.properties");
document.writeln("<title>" + pluginsbundle.GetStringFromName("title_label") + "<\/title>");
</script>
<link rel="stylesheet" type="text/css" href="chrome://global/content/plugins.css">
<link rel="stylesheet" type="text/css" href="chrome://global/skin/plugins.css">
</head>
<body>
<div id="outside">
<script type="application/javascript">
"use strict";
function setDirection() {
var frame = document.getElementById("directionDetector");
var direction = frame.contentDocument
.defaultView
.window
.getComputedStyle(frame.contentDocument.getElementById("target"), "")
.getPropertyValue("direction");
document.body.removeChild(frame);
document.dir = direction;
}
function setupDirection() {
var frame = document.createElement("iframe");
frame.setAttribute("id", "directionDetector");
frame.setAttribute("src", "chrome://global/content/directionDetector.html");
frame.setAttribute("width", "0");
frame.setAttribute("height", "0");
frame.setAttribute("style", "visibility: hidden;");
frame.setAttribute("onload", "setDirection();");
document.body.appendChild(frame);
}
setupDirection();
/* JavaScript to enumerate and display all installed plug-ins
* First, refresh plugins in case anything has been changed recently in
* prefs: (The "false" argument tells refresh not to reload or activate
* any plug-ins that would be active otherwise. In contrast, one would
* use "true" in the case of ASD instead of restarting)
*/
navigator.plugins.refresh(false);
AddonManager.getAddonsByTypes(["plugin"], function (aPlugins) {
var fragment = document.createDocumentFragment();
// "Enabled plugins"
var id, label;
if (aPlugins.length > 0) {
id = "plugs";
label = "enabledplugins_label";
} else {
id = "noplugs";
label = "nopluginsareenabled_label";
}
var enabledplugins = document.createElement("h1");
enabledplugins.setAttribute("id", id);
enabledplugins.appendChild(document.createTextNode(pluginsbundle.GetStringFromName(label)));
fragment.appendChild(enabledplugins);
// "Find more information about browser plugins at " ...
var findmore = document.createElement("div");
findmore.setAttribute("id", "findmore");
findmore.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("findmore_label") + " "));
fragment.appendChild(findmore);
// ... "mozilla.org"
var moreplugins = document.createElement("a");
moreplugins.setAttribute("href", regionbundle.GetStringFromName("more_plugins_url"));
moreplugins.appendChild(document.createTextNode(regionbundle.GetStringFromName("more_plugins_label")));
findmore.appendChild(moreplugins);
// "Find updates for installed plugins at " ...
var findpluginupdates = document.createElement("div");
findpluginupdates.setAttribute("id", "findpluginupdates");
findpluginupdates.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("findpluginupdates_label") + " "));
fragment.appendChild(findpluginupdates);
// ... "mozilla.com/plugincheck"
var pluginupdates = document.createElement("a");
pluginupdates.setAttribute("href", regionbundle.GetStringFromName("pluginupdates_url"));
pluginupdates.appendChild(document.createTextNode(regionbundle.GetStringFromName("pluginupdates_label")));
findpluginupdates.appendChild(pluginupdates);
// "Help for installing plugins is available from " ...
var installhelp = document.createElement("div");
installhelp.setAttribute("id", "installhelp");
installhelp.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("installhelp_label") + " "));
fragment.appendChild(installhelp);
// ... "plugindoc.mozdev.org"
var plugindoc = document.createElement("a");
plugindoc.setAttribute("href", regionbundle.GetStringFromName("plugindoc_url"));
plugindoc.appendChild(document.createTextNode(regionbundle.GetStringFromName("plugindoc_label")));
installhelp.appendChild(plugindoc);
fragment.appendChild(document.createElement("hr"));
var stateNames = {};
["STATE_SOFTBLOCKED",
"STATE_BLOCKED",
"STATE_OUTDATED",
"STATE_VULNERABLE_UPDATE_AVAILABLE",
"STATE_VULNERABLE_NO_UPDATE"].forEach(function(label) {
stateNames[Ci.nsIBlocklistService[label]] = label;
});
for (var i = 0; i < aPlugins.length; i++) {
var plugin = aPlugins[i];
if (plugin) {
// "Shockwave Flash"
var plugname = document.createElement("h2");
plugname.setAttribute("class", "plugname");
plugname.appendChild(document.createTextNode(plugin.name));
fragment.appendChild(plugname);
var dl = document.createElement("dl");
fragment.appendChild(dl);
// "File: Flash Player.plugin"
var fileDd = document.createElement("dd");
var file = document.createElement("span");
file.setAttribute("class", "label");
file.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("file_label") + " "));
fileDd.appendChild(file);
fileDd.appendChild(document.createTextNode(plugin.pluginLibraries));
dl.appendChild(fileDd);
// "Version: "
var versionDd = document.createElement("dd");
var version = document.createElement("span");
version.setAttribute("class", "label");
version.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("version_label") + " "));
versionDd.appendChild(version);
versionDd.appendChild(document.createTextNode(plugin.version));
dl.appendChild(versionDd);
// "State: "
var stateDd = document.createElement("dd");
var state = document.createElement("span");
state.setAttribute("label", "state");
state.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("state_label") + " "));
stateDd.appendChild(state);
status = plugin.isActive ? "Enabled" : "Disabled";
if (plugin.blocklistState in stateNames) {
status += " (" + stateNames[plugin.blocklistState] + ")";
}
stateDd.appendChild(document.createTextNode(status));
dl.appendChild(stateDd);
// Plugin Description
var descDd = document.createElement("dd");
descDd.appendChild(document.createTextNode(plugin.description));
dl.appendChild(descDd);
// MIME Type table
var mimetypeTable = document.createElement("table");
mimetypeTable.setAttribute("border", "1");
mimetypeTable.setAttribute("class", "contenttable");
fragment.appendChild(mimetypeTable);
var thead = document.createElement("thead");
mimetypeTable.appendChild(thead);
var tr = document.createElement("tr");
thead.appendChild(tr);
// "MIME Type" column header
var typeTh = document.createElement("th");
typeTh.setAttribute("class", "type");
typeTh.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("mimetype_label")));
tr.appendChild(typeTh);
// "Description" column header
var descTh = document.createElement("th");
descTh.setAttribute("class", "desc");
descTh.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("description_label")));
tr.appendChild(descTh);
// "Suffixes" column header
var suffixesTh = document.createElement("th");
suffixesTh.setAttribute("class", "suff");
suffixesTh.appendChild(document.createTextNode(pluginsbundle.GetStringFromName("suffixes_label")));
tr.appendChild(suffixesTh);
var tbody = document.createElement("tbody");
mimetypeTable.appendChild(tbody);
var mimeTypes = plugin.pluginMimeTypes;
for (var j = 0; j < mimeTypes.length; j++) {
var mimetype = mimeTypes[j];
if (mimetype) {
var mimetypeRow = document.createElement("tr");
tbody.appendChild(mimetypeRow);
// "application/x-shockwave-flash"
var typename = document.createElement("td");
typename.appendChild(document.createTextNode(mimetype.type));
mimetypeRow.appendChild(typename);
// "Shockwave Flash"
var description = document.createElement("td");
description.appendChild(document.createTextNode(mimetype.description));
mimetypeRow.appendChild(description);
// "swf"
var suffixes = document.createElement("td");
suffixes.appendChild(document.createTextNode(mimetype.suffixes));
mimetypeRow.appendChild(suffixes);
}
}
}
}
document.getElementById("outside").appendChild(fragment);
});
</script>
</div>
</body>
</html>