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: Changed notification name Created Dec. 2, 2015, 11:20 a.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
« lib/child/contextMenu.js ('K') | « lib/child/contextMenu.js ('k') | 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");
tschuster 2015/12/02 12:14:17 Isn't event = {target: popup.triggernode} enough?
Wladimir Palant 2015/12/02 12:20:54 Fair enough, no point faking the notification prop
+ Object.defineProperty(event, "target", {"get": () => popup.triggerNode});
+ data = {
+ event: event,
+ addonInfo: {},
+ get wrappedJSObject() {return this;}
+ };
+ Services.obs.notifyObservers(data, "AdblockPlus:content-contextmenu", null);
}
- 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);
}
« lib/child/contextMenu.js ('K') | « lib/child/contextMenu.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld