Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
Bug 1456625 - Remove replacement XBL binding (Backout cb51f3bada90) r…
Browse files Browse the repository at this point in the history
…=Felipe

MozReview-Commit-ID: KlvjWWi3LkN
  • Loading branch information
timdream committed May 24, 2018
1 parent 8a3e638 commit d6fedf7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 96 deletions.
77 changes: 15 additions & 62 deletions browser/modules/PluginContent.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ var PluginContent = function(global) {
this.init(global);
};

const FLASH_MIME_TYPE = "application/x-shockwave-flash";
const REPLACEMENT_STYLE_SHEET = Services.io.newURI("chrome://pluginproblem/content/pluginReplaceBinding.css");

const OVERLAY_DISPLAY = {
HIDDEN: 0, // The overlay will be transparent
BLANK: 1, // The overlay will be just a grey box
Expand All @@ -49,7 +46,6 @@ PluginContent.prototype = {

// Note that the XBL binding is untrusted
global.addEventListener("PluginBindingAttached", this, true, true);
global.addEventListener("PluginPlaceholderReplaced", this, true, true);
global.addEventListener("PluginCrashed", this, true);
global.addEventListener("PluginOutdated", this, true);
global.addEventListener("PluginInstantiated", this, true);
Expand All @@ -73,7 +69,6 @@ PluginContent.prototype = {
let global = this.global;

global.removeEventListener("PluginBindingAttached", this, true);
global.removeEventListener("PluginPlaceholderReplaced", this, true, true);
global.removeEventListener("PluginCrashed", this, true);
global.removeEventListener("PluginOutdated", this, true);
global.removeEventListener("PluginInstantiated", this, true);
Expand Down Expand Up @@ -182,15 +177,6 @@ PluginContent.prototype = {
},

_getPluginInfo(pluginElement) {
if (ChromeUtils.getClassName(pluginElement) === "HTMLAnchorElement") {
// Anchor elements are our place holders, and we only have them for Flash
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
return {
pluginName: "Shockwave Flash",
mimetype: FLASH_MIME_TYPE,
permissionString: pluginHost.getPermissionStringForType(FLASH_MIME_TYPE)
};
}
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
pluginElement.QueryInterface(Ci.nsIObjectLoadingContent);

Expand Down Expand Up @@ -494,35 +480,15 @@ PluginContent.prototype = {
}

if (eventType == "HiddenPlugin") {
let win = event.target.defaultView;
if (!win.mozHiddenPluginTouched) {
let pluginTag = event.tag.QueryInterface(Ci.nsIPluginTag);
if (win.top.document != this.content.document) {
return;
}
this._showClickToPlayNotification(pluginTag, false);
let winUtils = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
try {
winUtils.loadSheet(REPLACEMENT_STYLE_SHEET, win.AGENT_SHEET);
win.mozHiddenPluginTouched = true;
} catch (e) {
Cu.reportError("Error adding plugin replacement style sheet: " + e);
}
let pluginTag = event.tag.QueryInterface(Ci.nsIPluginTag);
if (event.target.defaultView.top.document != this.content.document) {
return;
}
this._showClickToPlayNotification(pluginTag, false);
}

let plugin = event.target;

if (eventType == "PluginPlaceholderReplaced") {
plugin.removeAttribute("href");
let overlay = this.getPluginUI(plugin, "main");
this.setVisibility(plugin, overlay, OVERLAY_DISPLAY.FULL);
// Add pseudo class so our styling will take effect
InspectorUtils.addPseudoClassLock(plugin, "-moz-handler-clicktoplay");
overlay.addEventListener("click", this, true);
return;
}

if (!(plugin instanceof Ci.nsIObjectLoadingContent))
return;

Expand Down Expand Up @@ -699,19 +665,12 @@ PluginContent.prototype = {
_handleClickToPlayEvent(plugin) {
let doc = plugin.ownerDocument;
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);
let permissionString;
if (ChromeUtils.getClassName(plugin) === "HTMLAnchorElement") {
// We only have replacement content for Flash installs
permissionString = pluginHost.getPermissionStringForType(FLASH_MIME_TYPE);
} else {
let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
// guard against giving pluginHost.getPermissionStringForType a type
// not associated with any known plugin
if (!this.isKnownPlugin(objLoadingContent))
return;
permissionString = pluginHost.getPermissionStringForType(objLoadingContent.actualType);
}

let objLoadingContent = plugin.QueryInterface(Ci.nsIObjectLoadingContent);
// guard against giving pluginHost.getPermissionStringForType a type
// not associated with any known plugin
if (!this.isKnownPlugin(objLoadingContent))
return;
let permissionString = pluginHost.getPermissionStringForType(objLoadingContent.actualType);
let principal = doc.defaultView.top.document.nodePrincipal;
let pluginPermission = Services.perms.testPermissionFromPrincipal(principal, permissionString);

Expand Down Expand Up @@ -773,19 +732,14 @@ PluginContent.prototype = {
let pluginHost = Cc["@mozilla.org/plugin/host;1"].getService(Ci.nsIPluginHost);

let pluginFound = false;
let placeHolderFound = false;
for (let plugin of plugins) {
plugin.QueryInterface(Ci.nsIObjectLoadingContent);
if (!this.isKnownPlugin(plugin)) {
continue;
}
if (pluginInfo.permissionString == pluginHost.getPermissionStringForType(plugin.actualType)) {
let overlay = this.getPluginUI(plugin, "main");
if (ChromeUtils.getClassName(plugin) === "HTMLAnchorElement") {
placeHolderFound = true;
} else {
pluginFound = true;
}
pluginFound = true;
if (newState == "block" || newState == "blockalways" || newState == "continueblocking") {
if (overlay) {
overlay.addEventListener("click", this, true);
Expand All @@ -801,12 +755,11 @@ PluginContent.prototype = {
}
}

// If there are no instances of the plugin on the page any more, what the
// user probably needs is for us to allow and then refresh. Additionally, if
// this is content that requires HLS or we replaced the placeholder the page
// needs to be refreshed for it to insert its plugins
// If there are no instances of the plugin on the page any more or if we've
// noted that the content needs to be reloaded due to replacing HLS, what the
// user probably needs is for us to allow and then refresh.
if (newState != "block" && newState != "blockalways" && newState != "continueblocking" &&
(!pluginFound || placeHolderFound || contentWindow.pluginRequiresReload)) {
(!pluginFound || contentWindow.pluginRequiresReload)) {
this.reloadPage();
}
this.updateNotificationUI();
Expand Down
9 changes: 0 additions & 9 deletions toolkit/pluginproblem/content/pluginProblem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,4 @@
</constructor>
</implementation>
</binding>

<binding id="replacement" extends="chrome://pluginproblem/content/pluginProblem.xml#pluginProblem" inheritstyle="false" chromeOnlyContent="true" bindToUntrustedContent="true">
<implementation>
<constructor>
this.dispatchEvent(new CustomEvent("PluginPlaceholderReplaced"));
</constructor>
</implementation>
</binding>

</bindings>
4 changes: 0 additions & 4 deletions toolkit/pluginproblem/content/pluginProblemContent.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ html|applet:not([height]), html|applet[height=""] {
height: 200px;
}

a .mainBox,
:-moz-handler-clicktoplay .mainBox,
:-moz-handler-vulnerable-updatable .mainBox,
:-moz-handler-vulnerable-no-update .mainBox,
:-moz-handler-blocked .mainBox {
-moz-user-focus: normal;
}
a .mainBox:focus,
:-moz-handler-clicktoplay .mainBox:focus,
:-moz-handler-vulnerable-updatable .mainBox:focus,
:-moz-handler-vulnerable-no-update .mainBox:focus,
Expand Down Expand Up @@ -72,7 +70,6 @@ a .mainBox:focus,
direction: rtl;
}

a .hoverBox,
:-moz-handler-clicktoplay .hoverBox,
:-moz-handler-vulnerable-updatable .hoverBox,
:-moz-handler-vulnerable-no-update .hoverBox {
Expand All @@ -90,7 +87,6 @@ a .hoverBox,
display: none;
}

a .msgClickToPlay,
:-moz-handler-clicktoplay .msgClickToPlay,
:-moz-handler-vulnerable-updatable .msgVulnerabilityStatus,
:-moz-handler-vulnerable-updatable .msgCheckForUpdates,
Expand Down
17 changes: 0 additions & 17 deletions toolkit/pluginproblem/content/pluginReplaceBinding.css

This file was deleted.

1 change: 0 additions & 1 deletion toolkit/pluginproblem/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ toolkit.jar:
pluginproblem/pluginProblem.xml (content/pluginProblem.xml)
pluginproblem/pluginProblemContent.css (content/pluginProblemContent.css)
pluginproblem/pluginProblemBinding.css (content/pluginProblemBinding.css)
pluginproblem/pluginReplaceBinding.css (content/pluginReplaceBinding.css)
4 changes: 1 addition & 3 deletions toolkit/themes/shared/plugins/pluginProblem.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ html|a {
:-moz-handler-blocked .icon {
background-image: url(chrome://mozapps/skin/plugins/contentPluginBlocked.png);
}
a .icon,
:-moz-handler-clicktoplay .icon {
background-image: url(chrome://mozapps/skin/plugins/plugin.svg);
fill: var(--grey-10);
Expand All @@ -98,8 +97,7 @@ a .icon,
}

/* on desktop, don't ever show the tap-to-play UI: that is for mobile only */
:-moz-handler-clicktoplay .msgTapToPlay,
a .msgTapToPlay {
:-moz-handler-clicktoplay .msgTapToPlay {
display: none;
}

Expand Down

0 comments on commit d6fedf7

Please sign in to comment.