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

Unified Diff: lib/ui.js

Issue 29338861: Issue 3851 - Implement subscribe link handling via process scripts (Closed)
Patch Set: Created March 21, 2016, 7:25 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
« lib/child/subscribeLinks.js ('K') | « lib/child/subscribeLinks.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
@@ -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");
@@ -445,26 +446,17 @@ let UI = exports.UI =
// 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();
Erik 2016/04/06 03:11:41 should this line not be removed too?
Wladimir Palant 2016/04/18 15:38:40 Done.
// 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 +918,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
« lib/child/subscribeLinks.js ('K') | « lib/child/subscribeLinks.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld