Bug 734323 - Invisible plugins added to the DOM after the 'load' event will not prompt a doorhanger to appear. r=margaret

This commit is contained in:
Jared Wein 2012-03-22 13:54:06 -07:00
parent 589f9135f9
commit 87ff948644

View File

@ -1456,6 +1456,9 @@ function Tab(aURL, aParams) {
this._zoom = 1.0;
this.userScrollPos = { x: 0, y: 0 };
this.contentDocumentIsDisplayed = true;
this.clickToPlayPluginDoorhangerShown = false;
this.clickToPlayPluginsActivated = false;
this.loadEventProcessed = false;
}
Tab.prototype = {
@ -1763,6 +1766,7 @@ Tab.prototype = {
}
case "load": {
this.loadEventProcessed = true;
// Show a plugin doorhanger if there are no clickable overlays showing
let contentWindow = this.browser.contentWindow;
let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
@ -1885,14 +1889,20 @@ Tab.prototype = {
case "PluginClickToPlay": {
let plugin = aEvent.target;
let overlay = plugin.ownerDocument.getAnonymousElementByAttribute(plugin, "class", "mainBox");
if (!overlay)
if (this.clickToPlayPluginsActivated) {
PluginHelper.playPlugin(plugin);
return;
}
// If the overlay is too small, hide the overlay and act like this
// is a hidden plugin object
if (PluginHelper.isTooSmall(plugin, overlay)) {
overlay.style.visibility = "hidden";
let overlay = plugin.ownerDocument.getAnonymousElementByAttribute(plugin, "class", "mainBox");
if (!overlay || PluginHelper.isTooSmall(plugin, overlay)) {
if (overlay)
overlay.style.visibility = "hidden";
if (this.loadEventProcessed && !this.clickToPlayPluginDoorhangerShown)
PluginHelper.showDoorHanger(this);
return;
}
@ -1903,7 +1913,10 @@ Tab.prototype = {
return;
e.preventDefault();
}
PluginHelper.playAllPlugins(e.target.ownerDocument.defaultView);
let win = e.target.ownerDocument.defaultView.top;
let tab = BrowserApp.getTabForWindow(win);
tab.clickToPlayPluginsActivated = true;
PluginHelper.playAllPlugins(win);
}, true);
break;
}
@ -1964,6 +1977,11 @@ Tab.prototype = {
contentType = browser.contentDocument.contentType;
}
// Reset state of click-to-play plugin notifications.
this.clickToPlayPluginDoorhangerShown = false;
this.clickToPlayPluginsActivated = false;
this.loadEventProcessed = false;
let message = {
gecko: {
type: "Content:LocationChange",
@ -3849,6 +3867,7 @@ var ClipboardHelper = {
var PluginHelper = {
showDoorHanger: function(aTab) {
aTab.clickToPlayPluginDoorhangerShown = true;
let message = Strings.browser.GetStringFromName("clickToPlayPlugins.message");
let buttons = [
{
@ -3875,11 +3894,13 @@ var PluginHelper = {
if (!plugins || !plugins.length)
return;
for (let plugin of plugins) {
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (!objLoadingContent.activated)
objLoadingContent.playPlugin();
}
plugins.forEach(this.playPlugin);
},
playPlugin: function(plugin) {
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (!objLoadingContent.activated)
objLoadingContent.playPlugin();
},
getPluginPreference: function getPluginPreference() {