mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 711552 - Click to play plugins for desktop Firefox. r=felipe
This commit is contained in:
parent
f05628f8b5
commit
acc7a6a10c
@ -612,6 +612,8 @@ pref("plugins.hide_infobar_for_carbon_failure_plugin", false);
|
||||
pref("plugins.update.url", "https://www.mozilla.com/%LOCALE%/plugincheck/");
|
||||
pref("plugins.update.notifyUser", false);
|
||||
|
||||
pref("plugins.click_to_play", false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
pref("browser.preferences.instantApply", false);
|
||||
#else
|
||||
|
@ -256,6 +256,12 @@ function pageShowEventHandlers(event) {
|
||||
if (event.originalTarget == content.document) {
|
||||
charsetLoadListener(event);
|
||||
XULBrowserWindow.asyncUpdateUI();
|
||||
|
||||
// The PluginClickToPlay events are not fired when navigating using the
|
||||
// BF cache. |event.persisted| is true when the page is loaded from the
|
||||
// BF cache, so this code reshows the notification if necessary.
|
||||
if (event.persisted)
|
||||
gPluginHandler.reshowClickToPlayNotification();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1428,6 +1434,7 @@ function prepareForStartup() {
|
||||
gBrowser.addEventListener("PluginBlocklisted", gPluginHandler, true);
|
||||
gBrowser.addEventListener("PluginOutdated", gPluginHandler, true);
|
||||
gBrowser.addEventListener("PluginDisabled", gPluginHandler, true);
|
||||
gBrowser.addEventListener("PluginClickToPlay", gPluginHandler, true);
|
||||
gBrowser.addEventListener("NewPluginInstalled", gPluginHandler.newPluginInstalled, true);
|
||||
#ifdef XP_MACOSX
|
||||
gBrowser.addEventListener("npapi-carbon-event-model-failure", gPluginHandler, true);
|
||||
@ -5188,8 +5195,13 @@ var TabsProgressListener = {
|
||||
onLocationChange: function (aBrowser, aWebProgress, aRequest, aLocationURI,
|
||||
aFlags) {
|
||||
// Filter out any sub-frame loads
|
||||
if (aBrowser.contentWindow == aWebProgress.DOMWindow)
|
||||
if (aBrowser.contentWindow == aWebProgress.DOMWindow) {
|
||||
// initialize the click-to-play state
|
||||
aBrowser._clickToPlayDoorhangerShown = false;
|
||||
aBrowser._clickToPlayPluginsActivated = false;
|
||||
|
||||
FullZoom.onLocationChange(aLocationURI, false, aBrowser);
|
||||
}
|
||||
},
|
||||
|
||||
onRefreshAttempted: function (aBrowser, aWebProgress, aURI, aDelay, aSameURI) {
|
||||
@ -7143,6 +7155,10 @@ var gPluginHandler = {
|
||||
self.pluginUnavailable(plugin, event.type);
|
||||
break;
|
||||
|
||||
case "PluginClickToPlay":
|
||||
self._handleClickToPlayEvent(plugin);
|
||||
break;
|
||||
|
||||
case "PluginDisabled":
|
||||
let manageLink = doc.getAnonymousElementByAttribute(plugin, "class", "managePluginsLink");
|
||||
self.addLinkClickCallback(manageLink, "managePlugins");
|
||||
@ -7150,13 +7166,29 @@ var gPluginHandler = {
|
||||
}
|
||||
|
||||
// Hide the in-content UI if it's too big. The crashed plugin handler already did this.
|
||||
if (event.type != "PluginCrashed") {
|
||||
if (event.type != "PluginCrashed" && event.type != "PluginClickToPlay") {
|
||||
let overlay = doc.getAnonymousElementByAttribute(plugin, "class", "mainBox");
|
||||
if (self.isTooSmall(plugin, overlay))
|
||||
overlay.style.visibility = "hidden";
|
||||
}
|
||||
},
|
||||
|
||||
activatePlugins: function PH_activatePlugins(aContentWindow) {
|
||||
let browser = gBrowser.getBrowserForDocument(aContentWindow.document);
|
||||
browser._clickToPlayPluginsActivated = true;
|
||||
let cwu = aContentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
let plugins = cwu.plugins;
|
||||
for (let plugin of plugins) {
|
||||
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
if (!objLoadingContent.activated)
|
||||
objLoadingContent.playPlugin();
|
||||
}
|
||||
let notification = PopupNotifications.getNotification("click-to-play-plugins", browser);
|
||||
if (notification)
|
||||
notification.remove();
|
||||
},
|
||||
|
||||
newPluginInstalled : function(event) {
|
||||
// browser elements are anonymous so we can't just use target.
|
||||
var browser = event.originalTarget;
|
||||
@ -7210,6 +7242,53 @@ var gPluginHandler = {
|
||||
openHelpLink("plugin-crashed", false);
|
||||
},
|
||||
|
||||
// Event listener for click-to-play plugins.
|
||||
_handleClickToPlayEvent: function PH_handleClickToPlayEvent(aPlugin) {
|
||||
let doc = aPlugin.ownerDocument;
|
||||
let browser = gBrowser.getBrowserForDocument(doc.defaultView.top.document);
|
||||
if (browser._clickToPlayPluginsActivated) {
|
||||
let objLoadingContent = aPlugin.QueryInterface(Ci.nsIObjectLoadingContent);
|
||||
objLoadingContent.playPlugin();
|
||||
return;
|
||||
}
|
||||
|
||||
let overlay = doc.getAnonymousElementByAttribute(aPlugin, "class", "mainBox");
|
||||
overlay.addEventListener("click", function(aEvent) {
|
||||
if (aEvent.button == 0 && aEvent.isTrusted)
|
||||
gPluginHandler.activatePlugins(aEvent.target.ownerDocument.defaultView.top);
|
||||
}, true);
|
||||
|
||||
if (!browser._clickToPlayDoorhangerShown)
|
||||
gPluginHandler._showClickToPlayNotification(browser);
|
||||
},
|
||||
|
||||
reshowClickToPlayNotification: function PH_reshowClickToPlayNotification() {
|
||||
if (!Services.prefs.getBoolPref("plugins.click_to_play"))
|
||||
return;
|
||||
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
let contentWindow = browser.contentWindow;
|
||||
let cwu = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils);
|
||||
if (cwu.plugins.length)
|
||||
gPluginHandler._showClickToPlayNotification(browser);
|
||||
},
|
||||
|
||||
_showClickToPlayNotification: function PH_showClickToPlayNotification(aBrowser) {
|
||||
aBrowser._clickToPlayDoorhangerShown = true;
|
||||
let contentWindow = aBrowser.contentWindow;
|
||||
let messageString = gNavigatorBundle.getString("activatePluginsMessage.message");
|
||||
let action = {
|
||||
label: gNavigatorBundle.getString("activatePluginsMessage.label"),
|
||||
accessKey: gNavigatorBundle.getString("activatePluginsMessage.accesskey"),
|
||||
callback: function() { gPluginHandler.activatePlugins(contentWindow); }
|
||||
};
|
||||
let options = { dismissed: true };
|
||||
PopupNotifications.show(aBrowser, "click-to-play-plugins",
|
||||
messageString, "addons-notification-icon",
|
||||
action, null, options);
|
||||
},
|
||||
|
||||
// event listener for missing/blocklisted/outdated/carbonFailure plugins.
|
||||
pluginUnavailable: function (plugin, eventType) {
|
||||
let browser = gBrowser.getBrowserForDocument(plugin.ownerDocument
|
||||
|
@ -115,6 +115,9 @@ crashedpluginsMessage.learnMore=Learn More…
|
||||
carbonFailurePluginsMessage.message=This page asks to use a plugin that can only run in 32-bit mode
|
||||
carbonFailurePluginsMessage.restartButton.label=Restart in 32-bit mode
|
||||
carbonFailurePluginsMessage.restartButton.accesskey=R
|
||||
activatePluginsMessage.message=Would you like to activate the plugins on this page?
|
||||
activatePluginsMessage.label=Activate plugins
|
||||
activatePluginsMessage.accesskey=A
|
||||
|
||||
# Sanitize
|
||||
# LOCALIZATION NOTE (sanitizeDialog2.everything.title): When "Time range to
|
||||
|
@ -1191,7 +1191,8 @@ toolbar[iconsize="small"] #feed-button {
|
||||
.popup-notification-icon[popupid="addon-install-cancelled"],
|
||||
.popup-notification-icon[popupid="addon-install-blocked"],
|
||||
.popup-notification-icon[popupid="addon-install-failed"],
|
||||
.popup-notification-icon[popupid="addon-install-complete"] {
|
||||
.popup-notification-icon[popupid="addon-install-complete"],
|
||||
.popup-notification-icon[popupid="click-to-play-plugins"] {
|
||||
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.png);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
@ -2378,7 +2378,8 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
|
||||
.popup-notification-icon[popupid="addon-install-cancelled"],
|
||||
.popup-notification-icon[popupid="addon-install-blocked"],
|
||||
.popup-notification-icon[popupid="addon-install-failed"],
|
||||
.popup-notification-icon[popupid="addon-install-complete"] {
|
||||
.popup-notification-icon[popupid="addon-install-complete"],
|
||||
.popup-notification-icon[popupid="click-to-play-plugins"] {
|
||||
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.png);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
@ -2249,7 +2249,8 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
|
||||
.popup-notification-icon[popupid="addon-install-cancelled"],
|
||||
.popup-notification-icon[popupid="addon-install-blocked"],
|
||||
.popup-notification-icon[popupid="addon-install-failed"],
|
||||
.popup-notification-icon[popupid="addon-install-complete"] {
|
||||
.popup-notification-icon[popupid="addon-install-complete"],
|
||||
.popup-notification-icon[popupid="click-to-play-plugins"] {
|
||||
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric.png);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
|
@ -21,7 +21,9 @@
|
||||
<!ENTITY pluginWizard.finalPage.restart.label "&brandShortName; needs to be restarted for the plugin(s) to work.">
|
||||
|
||||
<!ENTITY missingPlugin "A plugin is needed to display this content.">
|
||||
<!ENTITY clickToPlayPlugin "Tap here to activate plugin.">
|
||||
<!-- LOCALIZATION NOTE (tapToPlayPlugin): Mobile (used for touch interfaces) only has one type of plugin possible. -->
|
||||
<!ENTITY tapToPlayPlugin "Tap here to activate plugin.">
|
||||
<!ENTITY clickToPlayPlugins "Click here to activate plugins.">
|
||||
<!ENTITY disabledPlugin "This plugin is disabled.">
|
||||
<!ENTITY blockedPlugin.label "This plugin has been blocked for your protection.">
|
||||
|
||||
|
@ -49,8 +49,8 @@
|
||||
xmlns:html="http://www.w3.org/1999/xhtml">
|
||||
<binding id="pluginProblem" inheritstyle="false">
|
||||
<resources>
|
||||
<stylesheet src="chrome://mozapps/skin/plugins/pluginProblem.css"/>
|
||||
<stylesheet src="chrome://mozapps/content/plugins/pluginProblemContent.css"/>
|
||||
<stylesheet src="chrome://mozapps/skin/plugins/pluginProblem.css"/>
|
||||
</resources>
|
||||
|
||||
<content>
|
||||
@ -58,7 +58,8 @@
|
||||
<xul:spacer flex="1"/>
|
||||
<xul:box class="icon"/>
|
||||
<html:div class="msg msgUnsupported">&missingPlugin;</html:div>
|
||||
<html:div class="msg msgClickToPlay">&clickToPlayPlugin;</html:div>
|
||||
<html:div class="msg msgTapToPlay">&tapToPlayPlugin;</html:div>
|
||||
<html:div class="msg msgClickToPlay">&clickToPlayPlugins;</html:div>
|
||||
<html:div class="msg msgDisabled">&disabledPlugin;</html:div>
|
||||
<html:div class="msg msgBlocked">&blockedPlugin.label;</html:div>
|
||||
<html:div class="msg msgCrashed"><!-- set at runtime --></html:div>
|
||||
|
@ -43,6 +43,7 @@ html|applet:not([height]), html|applet[height=""] {
|
||||
|
||||
:-moz-type-unsupported .msgUnsupported,
|
||||
:-moz-handler-clicktoplay .msgClickToPlay,
|
||||
:-moz-handler-clicktoplay .msgTapToPlay,
|
||||
:-moz-handler-disabled .msgDisabled,
|
||||
:-moz-handler-disabled .msgManagePlugins,
|
||||
:-moz-handler-blocked .msgBlocked,
|
||||
|
@ -60,6 +60,15 @@ html|a {
|
||||
text-shadow: rgba(0,0,0,0.8) 0 0 3.5px;
|
||||
}
|
||||
|
||||
:-moz-handler-clicktoplay,
|
||||
.msgClickToPlay {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
:-moz-handler-clicktoplay .msgTapToPlay {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.submitStatus div {
|
||||
min-height: 19px; /* height of biggest line (with throbber) */
|
||||
}
|
||||
|
@ -60,6 +60,23 @@ html|a {
|
||||
text-shadow: rgba(0,0,0,0.8) 0 0 3.5px;
|
||||
}
|
||||
|
||||
:-moz-handler-clicktoplay,
|
||||
.msgClickToPlay {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@media not all and (-moz-touch-enabled) {
|
||||
:-moz-handler-clicktoplay .msgTapToPlay {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (-moz-touch-enabled) {
|
||||
:-moz-handler-clicktoplay .msgClickToPlay {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.submitStatus div {
|
||||
min-height: 19px; /* height of biggest line (with throbber) */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user