From da0a9f854ff5d2d2a78dae776cc0a6bd75e9765a Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 25 Jul 2018 15:26:02 +0200 Subject: [PALEMOON] Bug 757726 - Populate Preferences' Applications list using PluginHost --- .../components/preferences/applications.js | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'application') diff --git a/application/palemoon/components/preferences/applications.js b/application/palemoon/components/preferences/applications.js index 5768de7089..4388f290e4 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. -- cgit v1.2.3