mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 967969 - Handle click-to-play plugin events in Metro [r=rsilveira]
--HG-- rename : mobile/android/chrome/content/PluginHelper.js => browser/metro/base/content/contenthandlers/PluginHelper.js
This commit is contained in:
parent
10bfb0a173
commit
ffefd2c7f7
@ -64,6 +64,7 @@ var Browser = {
|
||||
messageManager.loadFrameScript("chrome://browser/content/contenthandlers/SelectionHandler.js", true);
|
||||
messageManager.loadFrameScript("chrome://browser/content/contenthandlers/ContextMenuHandler.js", true);
|
||||
messageManager.loadFrameScript("chrome://browser/content/contenthandlers/ConsoleAPIObserver.js", true);
|
||||
messageManager.loadFrameScript("chrome://browser/content/contenthandlers/PluginHelper.js", true);
|
||||
} catch (e) {
|
||||
// XXX whatever is calling startup needs to dump errors!
|
||||
dump("###########" + e + "\n");
|
||||
|
101
browser/metro/base/content/contenthandlers/PluginHelper.js
Normal file
101
browser/metro/base/content/contenthandlers/PluginHelper.js
Normal file
@ -0,0 +1,101 @@
|
||||
/* 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/. */
|
||||
"use strict";
|
||||
|
||||
dump("### PluginHelper.js loaded\n");
|
||||
|
||||
/**
|
||||
* Handle events generated by plugin click-to-play code.
|
||||
*
|
||||
* This "PluginBindingAttached" fires when a "pluginProblem" XBL binding is
|
||||
* created. This binding overlays plugin content when the plugin is missing,
|
||||
* blocked, click-to-play, or replaced by a "preview" extension plugin like
|
||||
* Shumway or PDF.js.
|
||||
*/
|
||||
var PluginHelper = {
|
||||
init: function () {
|
||||
addEventListener("PluginBindingAttached", this, true, true);
|
||||
},
|
||||
|
||||
handleEvent: function handleEvent(aEvent) {
|
||||
switch (aEvent.type) {
|
||||
case "PluginBindingAttached":
|
||||
this.handlePluginBindingAttached(aEvent);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
getPluginMimeType: function (plugin) {
|
||||
var tagMimetype;
|
||||
if (plugin instanceof plugin.ownerDocument.defaultView.HTMLAppletElement) {
|
||||
tagMimetype = "application/x-java-vm";
|
||||
} else {
|
||||
tagMimetype = plugin.QueryInterface(Components.interfaces.nsIObjectLoadingContent)
|
||||
.actualType;
|
||||
|
||||
if (tagMimetype == "") {
|
||||
tagMimetype = plugin.type;
|
||||
}
|
||||
}
|
||||
return tagMimetype;
|
||||
},
|
||||
|
||||
handlePluginBindingAttached: function (aEvent) {
|
||||
let plugin = aEvent.target;
|
||||
let doc = plugin.ownerDocument;
|
||||
let overlay = doc.getAnonymousElementByAttribute(plugin, "anonid", "main");
|
||||
if (!overlay || overlay._bindingHandled) {
|
||||
return;
|
||||
}
|
||||
overlay._bindingHandled = true;
|
||||
|
||||
let eventType = PluginHelper._getBindingType(plugin);
|
||||
if (!eventType) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (eventType) {
|
||||
case "PluginPlayPreview": {
|
||||
// Load the "preview" handler (an extension plugin like Shumway or PDF.js).
|
||||
let previewContent = doc.getAnonymousElementByAttribute(plugin, "class", "previewPluginContent");
|
||||
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
|
||||
let mimeType = PluginHelper.getPluginMimeType(plugin);
|
||||
let playPreviewInfo = pluginHost.getPlayPreviewInfo(mimeType);
|
||||
|
||||
let iframe = previewContent.getElementsByClassName("previewPluginContentFrame")[0];
|
||||
if (!iframe) {
|
||||
// lazy initialization of the iframe
|
||||
iframe = doc.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
|
||||
iframe.className = "previewPluginContentFrame";
|
||||
previewContent.appendChild(iframe);
|
||||
}
|
||||
iframe.src = playPreviewInfo.redirectURL;
|
||||
break;
|
||||
}
|
||||
|
||||
case "PluginNotFound": {
|
||||
// TODO: Display a message about missing plugins (bug 936907)
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Helper to get the binding handler type from a plugin object
|
||||
_getBindingType: function(plugin) {
|
||||
if (!(plugin instanceof Ci.nsIObjectLoadingContent))
|
||||
return null;
|
||||
|
||||
switch (plugin.pluginFallbackType) {
|
||||
case Ci.nsIObjectLoadingContent.PLUGIN_UNSUPPORTED:
|
||||
return "PluginNotFound";
|
||||
case Ci.nsIObjectLoadingContent.PLUGIN_PLAY_PREVIEW:
|
||||
return "PluginPlayPreview";
|
||||
default:
|
||||
// Metro Firefox does not yet support other fallback types.
|
||||
return null;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
PluginHelper.init();
|
@ -59,6 +59,7 @@ chrome.jar:
|
||||
content/contenthandlers/FormHelper.js (content/contenthandlers/FormHelper.js)
|
||||
content/contenthandlers/ConsoleAPIObserver.js (content/contenthandlers/ConsoleAPIObserver.js)
|
||||
content/contenthandlers/Content.js (content/contenthandlers/Content.js)
|
||||
content/contenthandlers/PluginHelper.js (content/contenthandlers/PluginHelper.js)
|
||||
|
||||
content/library/SelectionPrototype.js (content/library/SelectionPrototype.js)
|
||||
|
||||
|
@ -573,7 +573,12 @@ pref("pdfjs.previousHandler.alwaysAskBeforeHandling", false);
|
||||
#endif
|
||||
|
||||
#ifdef NIGHTLY_BUILD
|
||||
// Shumay is currently experimental. Toggle this pref to enable Shumway for
|
||||
// testing and development.
|
||||
pref("shumway.disabled", true);
|
||||
// When Shumway is enabled, use it all the time, not only when Flash is set to
|
||||
// click-to-play (because Metro doesn't even load the native Flash plugin).
|
||||
pref("shumway.ignoreCTP", true);
|
||||
#endif
|
||||
|
||||
// The maximum amount of decoded image data we'll willingly keep around (we
|
||||
|
Loading…
Reference in New Issue
Block a user