diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-07-25 15:26:02 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-08-04 08:06:24 +0200 |
commit | 8b20931e129a5926bce6fa85218b487f309efad4 (patch) | |
tree | 1f54ae526650800cf3844031e152858079e13a56 | |
parent | b247982d37dad290c25d5618e80d5ee7767b30ba (diff) | |
download | UXP-8b20931e129a5926bce6fa85218b487f309efad4.tar UXP-8b20931e129a5926bce6fa85218b487f309efad4.tar.gz UXP-8b20931e129a5926bce6fa85218b487f309efad4.tar.lz UXP-8b20931e129a5926bce6fa85218b487f309efad4.tar.xz UXP-8b20931e129a5926bce6fa85218b487f309efad4.zip |
[PALEMOON] Bug 757726 - Populate Preferences' Applications list using PluginHost
-rw-r--r-- | application/palemoon/components/preferences/applications.js | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/application/palemoon/components/preferences/applications.js b/application/palemoon/components/preferences/applications.js index 5768de708..4388f290e 100644 --- a/application/palemoon/components/preferences/applications.js +++ b/application/palemoon/components/preferences/applications.js @@ -8,15 +8,10 @@ //****************************************************************************// // Constants & Enumeration Values -/* -#ifndef XP_MACOSX -*/ var Cc = Components.classes; var Ci = Components.interfaces; var Cr = Components.results; -/* -#endif -*/ + Components.utils.import('resource://gre/modules/Services.jsm'); const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed"; @@ -158,7 +153,7 @@ function isFeedType(t) { * * We create an instance of this wrapper for each entry we might display * in the prefpane, and we compose the instances from various sources, - * including navigator.plugins and the handler service. + * including plugins and the handler service. * * We don't implement all the original nsIHandlerInfo functionality, * just the stuff that the prefpane needs. @@ -272,7 +267,7 @@ HandlerInfoWrapper.prototype = { // What to do with content of this type. get preferredAction() { // If we have an enabled plugin, then the action is to use that plugin. - if (this.plugin && !this.isDisabledPluginType) + if (this.pluginName && !this.isDisabledPluginType) return kActionUsePlugin; // If the action is to use a helper app, but we don't have a preferred @@ -308,7 +303,7 @@ HandlerInfoWrapper.prototype = { // of any user configuration, and the default in that case is to always ask, // even though we never ask for content handled by a plugin, so special case // plugin-handled types by returning false here. - if (this.plugin && this.handledOnlyByPlugin) + if (this.pluginName && this.handledOnlyByPlugin) return false; // If this is a protocol type and the preferred action is "save to disk", @@ -1064,10 +1059,17 @@ var gApplicationsPane = { * check the pref ourselves to find out if it's enabled. */ _loadPluginHandlers: function() { - for (let i = 0; i < navigator.plugins.length; ++i) { - let plugin = navigator.plugins[i]; - for (let j = 0; j < plugin.length; ++j) { - let type = plugin[j].type; + "use strict"; + + let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost); + let pluginTags = pluginHost.getPluginTags(); + + for (let i = 0; i < pluginTags.length; ++i) { + let pluginTag = pluginTags[i]; + + let mimeTypes = pluginTag.getMimeTypes(); + for (let j = 0; j < mimeTypes.length; ++j) { + let type = mimeTypes[j]; let handlerInfoWrapper; if (type in this._handledTypes) @@ -1080,7 +1082,7 @@ var gApplicationsPane = { this._handledTypes[type] = handlerInfoWrapper; } - handlerInfoWrapper.plugin = plugin; + handlerInfoWrapper.pluginName = pluginTag.name; } } }, @@ -1274,7 +1276,7 @@ var gApplicationsPane = { case kActionUsePlugin: return this._prefsBundle.getFormattedString("usePluginIn", - [aHandlerInfo.plugin.name, + [aHandlerInfo.pluginName, this._brandShortName]); } }, @@ -1456,11 +1458,11 @@ var gApplicationsPane = { } // Create a menu item for the plugin. - if (handlerInfo.plugin) { + if (handlerInfo.pluginName) { var pluginMenuItem = document.createElement("menuitem"); pluginMenuItem.setAttribute("action", kActionUsePlugin); let label = this._prefsBundle.getFormattedString("usePluginIn", - [handlerInfo.plugin.name, + [handlerInfo.pluginName, this._brandShortName]); pluginMenuItem.setAttribute("label", label); pluginMenuItem.setAttribute("tooltiptext", label); @@ -1623,7 +1625,7 @@ var gApplicationsPane = { // Set the plugin state if we're enabling or disabling a plugin. if (action == kActionUsePlugin) handlerInfo.enablePluginType(); - else if (handlerInfo.plugin && !handlerInfo.isDisabledPluginType) + else if (handlerInfo.pluginName && !handlerInfo.isDisabledPluginType) handlerInfo.disablePluginType(); // Set the preferred application handler. |