Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/ui.js

Issue 29331700: Issue 3223 - Implement context menu fallback for SeaMonkey Mail and Thunderbird (Closed)
Patch Set: Created Dec. 1, 2015, 2:48 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/ui.js
===================================================================
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -1595,24 +1595,35 @@ let UI = exports.UI =
/**
* Adds Adblock Plus menu items to the content area context menu when it shows
* up.
*/
fillContentContextMenu: function(/**Element*/ popup)
{
let window = popup.ownerDocument.defaultView;
- if (!window.gContextMenuContentData ||
- typeof window.gContextMenuContentData.addonInfo != "object" ||
- typeof window.gContextMenuContentData.addonInfo.adblockplus != "object")
+ let data = window.gContextMenuContentData;
+ if (!data)
{
- return;
+ // This is SeaMonkey Mail or Thunderbird, they won't get context menu data
+ // for us. Send the notification ourselves.
+ let event = new Event("contextmenu");
+ Object.defineProperty(event, "target", {"get": () => popup.triggerNode});
+ data = {
+ event: event,
+ addonInfo: {},
+ get wrappedJSObject() {return this;}
+ };
+ Services.obs.notifyObservers(data, "content-contextmenu", null);
Wladimir Palant 2015/12/02 11:21:46 I thought a bit more about this and it's probably
}
- let items = window.gContextMenuContentData.addonInfo.adblockplus;
+ if (typeof data.addonInfo != "object" || typeof data.addonInfo.adblockplus != "object")
+ return;
+
+ let items = data.addonInfo.adblockplus;
let clicked = null;
let menuItems = [];
function menuItemTriggered(id, nodeData)
{
clicked = id;
this.blockItem(window, id, nodeData);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld