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

Unified Diff: popup.js

Issue 29338491: Issue 3823 - Split up message responder code (Closed)
Patch Set: Rebased Created March 19, 2016, 7:43 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/messaging.js ('K') | « metadata.common ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: popup.js
===================================================================
--- a/popup.js
+++ b/popup.js
@@ -23,6 +23,7 @@
var Prefs = require("prefs").Prefs;
var checkWhitelisted = require("whitelisting").checkWhitelisted;
var getDecodedHostname = require("url").getDecodedHostname;
+var port = require("messaging").port;
var page = null;
@@ -57,7 +58,7 @@
});
// Attach event listeners
- ext.onMessage.addListener(onMessage);
+ port.on("composer.ready", onComposerReady);
document.getElementById("enabled").addEventListener("click", toggleEnabled, false);
document.getElementById("clickhide").addEventListener("click", activateClickHide, false);
document.getElementById("clickhide-cancel").addEventListener("click", cancelClickHide, false);
@@ -79,12 +80,12 @@
function onUnload()
{
- ext.onMessage.removeListener(onMessage);
+ port.off("composer.ready", onComposerReady);
Wladimir Palant 2016/03/21 11:59:40 IMHO, this shouldn't be necessary - each context (
Sebastian Noack 2016/03/21 13:26:02 If we would use window.chrome.runtime.onMessage un
Wladimir Palant 2016/03/21 13:58:01 I disagree. Current API requires developers to rem
Sebastian Noack 2016/03/21 15:26:59 Done.
}
-function onMessage(message, sender, callback)
+function onComposerReady(message, sender)
{
- if (message.type == "composer.ready" && sender.page.id == page.id)
+ if (sender.page.id == page.id)
document.body.classList.remove("nohtml");
}
« lib/messaging.js ('K') | « metadata.common ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld