mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1074976 - Move function makeNicePluginName() into BroswerUtils.jsm module. r=felipe
This commit is contained in:
parent
1fcb2376e8
commit
c04cd51611
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource:///modules/SitePermissions.jsm");
|
||||
Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
const nsIQuotaManager = Components.interfaces.nsIQuotaManager;
|
||||
|
||||
@ -231,20 +232,6 @@ function onIndexedDBUsageCallback(uri, usage, fileUsage)
|
||||
}
|
||||
}
|
||||
|
||||
// XXX copied this from browser-plugins.js - is there a way to share?
|
||||
function makeNicePluginName(aName) {
|
||||
if (aName == "Shockwave Flash")
|
||||
return "Adobe Flash";
|
||||
|
||||
// Clean up the plugin name by stripping off any trailing version numbers
|
||||
// or "plugin". EG, "Foo Bar Plugin 1.23_02" --> "Foo Bar"
|
||||
// Do this by first stripping the numbers, etc. off the end, and then
|
||||
// removing "Plugin" (and then trimming to get rid of any whitespace).
|
||||
// (Otherwise, something like "Java(TM) Plug-in 1.7.0_07" gets mangled)
|
||||
let newName = aName.replace(/[\s\d\.\-\_\(\)]+$/, "").replace(/\bplug-?in\b/i, "").trim();
|
||||
return newName;
|
||||
}
|
||||
|
||||
function fillInPluginPermissionTemplate(aPluginName, aPermissionString) {
|
||||
let permPluginTemplate = document.getElementById("permPluginTemplate").cloneNode(true);
|
||||
permPluginTemplate.setAttribute("permString", aPermissionString);
|
||||
@ -288,7 +275,7 @@ function initPluginsRow() {
|
||||
for (let mimeType of plugin.getMimeTypes()) {
|
||||
let permString = pluginHost.getPermissionStringForType(mimeType);
|
||||
if (!permissionMap.has(permString)) {
|
||||
var name = makeNicePluginName(plugin.name);
|
||||
let name = BrowserUtils.makeNicePluginName(plugin.name);
|
||||
if (permString.startsWith("plugin-vulnerable:")) {
|
||||
name += " \u2014 " + vulnerableLabel;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ this.EXPORTED_SYMBOLS = [ "PluginContent" ];
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
Cu.import("resource://gre/modules/BrowserUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gNavigatorBundle", function() {
|
||||
const url = "chrome://browser/locale/browser.properties";
|
||||
@ -119,7 +120,7 @@ PluginContent.prototype = {
|
||||
|
||||
if (this.isKnownPlugin(pluginElement)) {
|
||||
pluginTag = pluginHost.getPluginTagForType(pluginElement.actualType);
|
||||
pluginName = this.makeNicePluginName(pluginTag.name);
|
||||
pluginName = BrowserUtils.makeNicePluginName(pluginTag.name);
|
||||
|
||||
permissionString = pluginHost.getPermissionStringForType(pluginElement.actualType);
|
||||
fallbackType = pluginElement.defaultFallbackType;
|
||||
@ -142,26 +143,6 @@ PluginContent.prototype = {
|
||||
};
|
||||
},
|
||||
|
||||
// Map the plugin's name to a filtered version more suitable for user UI.
|
||||
makeNicePluginName : function (aName) {
|
||||
if (aName == "Shockwave Flash")
|
||||
return "Adobe Flash";
|
||||
// Regex checks if aName begins with "Java" + non-letter char
|
||||
if (/^Java\W/.exec(aName))
|
||||
return "Java";
|
||||
|
||||
// Clean up the plugin name by stripping off parenthetical clauses,
|
||||
// trailing version numbers or "plugin".
|
||||
// EG, "Foo Bar (Linux) Plugin 1.23_02" --> "Foo Bar"
|
||||
// Do this by first stripping the numbers, etc. off the end, and then
|
||||
// removing "Plugin" (and then trimming to get rid of any whitespace).
|
||||
// (Otherwise, something like "Java(TM) Plug-in 1.7.0_07" gets mangled)
|
||||
let newName = aName.replace(/\(.*?\)/g, "").
|
||||
replace(/[\s\d\.\-\_\(\)]+$/, "").
|
||||
replace(/\bplug-?in\b/i, "").trim();
|
||||
return newName;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the visibility of the plugin overlay.
|
||||
*/
|
||||
@ -843,7 +824,7 @@ PluginContent.prototype = {
|
||||
|
||||
// For non-GMP plugins, remap the plugin name to a more user-presentable form.
|
||||
if (!gmpPlugin) {
|
||||
pluginName = this.makeNicePluginName(pluginName);
|
||||
pluginName = BrowserUtils.makeNicePluginName(pluginName);
|
||||
}
|
||||
|
||||
let messageString = gNavigatorBundle.formatStringFromName("crashedpluginsMessage.title", [pluginName], 1);
|
||||
|
@ -179,4 +179,29 @@ this.BrowserUtils = {
|
||||
|
||||
return "_blank";
|
||||
},
|
||||
|
||||
/**
|
||||
* Map the plugin's name to a filtered version more suitable for UI.
|
||||
*
|
||||
* @param aName The full-length name string of the plugin.
|
||||
* @return the simplified name string.
|
||||
*/
|
||||
makeNicePluginName: function (aName) {
|
||||
if (aName == "Shockwave Flash")
|
||||
return "Adobe Flash";
|
||||
// Regex checks if aName begins with "Java" + non-letter char
|
||||
if (/^Java\W/.exec(aName))
|
||||
return "Java";
|
||||
|
||||
// Clean up the plugin name by stripping off parenthetical clauses,
|
||||
// trailing version numbers or "plugin".
|
||||
// EG, "Foo Bar (Linux) Plugin 1.23_02" --> "Foo Bar"
|
||||
// Do this by first stripping the numbers, etc. off the end, and then
|
||||
// removing "Plugin" (and then trimming to get rid of any whitespace).
|
||||
// (Otherwise, something like "Java(TM) Plug-in 1.7.0_07" gets mangled)
|
||||
let newName = aName.replace(/\(.*?\)/g, "").
|
||||
replace(/[\s\d\.\-\_\(\)]+$/, "").
|
||||
replace(/\bplug-?in\b/i, "").trim();
|
||||
return newName;
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user