Index: lib/ui.js |
=================================================================== |
--- a/lib/ui.js |
+++ b/lib/ui.js |
@@ -14,16 +14,17 @@ |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
Cu.import("resource://gre/modules/Services.jsm"); |
let {Utils} = require("utils"); |
+let {port} = require("messaging"); |
let {Prefs} = require("prefs"); |
let {Policy} = require("contentPolicy"); |
let {FilterStorage} = require("filterStorage"); |
let {FilterNotifier} = require("filterNotifier"); |
let {RequestNotifier} = require("requestNotifier"); |
let {Filter} = require("filterClasses"); |
let {Subscription, SpecialSubscription, DownloadableSubscription} = require("subscriptionClasses"); |
let {Synchronizer} = require("synchronizer"); |
@@ -440,31 +441,18 @@ let UI = exports.UI = |
return; |
this._showNotification(window, button, notification); |
}); |
// Add "anti-adblock messages" notification |
initAntiAdblockNotification(); |
- // Frame script URL has to be randomized due to caching |
- // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1051238) |
- let frameScript = "chrome://adblockplus/content/subscribeLinkHandler.js?" + Math.random(); |
- |
// Initialize subscribe link handling |
- let callback = this.subscribeLinkClicked.bind(this); |
- let messageManager = Cc["@mozilla.org/globalmessagemanager;1"] |
- .getService(Ci.nsIMessageListenerManager); |
- messageManager.loadFrameScript(frameScript, true); |
- messageManager.addMessageListener("AdblockPlus:SubscribeLink", callback); |
- onShutdown.add(() => { |
- messageManager.broadcastAsyncMessage("AdblockPlus:Shutdown", frameScript); |
- messageManager.removeDelayedFrameScript(frameScript); |
- messageManager.removeMessageListener("AdblockPlus:SubscribeLink", callback); |
- }); |
+ port.on("subscribeLinkClick", data => this.subscribeLinkClicked(data)); |
// Execute first-run actions if a window is open already, otherwise it |
// will happen in applyToWindow() when a window is opened. |
this.firstRunActions(this.currentWindow); |
}, |
addToolbarButton: function() |
{ |
@@ -926,22 +914,22 @@ let UI = exports.UI = |
}, false); |
request.send(); |
} |
else |
notifyUser(); |
}, |
/** |
- * Called whenever subscribeLinkHandler.js intercepts clicks on abp: links |
+ * Called whenever child/subscribeLinks module intercepts clicks on abp: links |
* as well as links to subscribe.adblockplus.org. |
*/ |
- subscribeLinkClicked: function(message) |
+ subscribeLinkClicked: function({title, url, |
+ mainSubscriptionTitle, mainSubscriptionURL}) |
{ |
- let {title, url, mainSubscriptionTitle, mainSubscriptionURL} = message.data; |
if (!url) |
return; |
// Default title to the URL |
if (!title) |
title = url; |
// Main subscription needs both title and URL |