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

Unified Diff: lib/options.js

Issue 29727584: Issue 6499 (Closed)
Patch Set: Created March 19, 2018, 1:55 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/options.js
===================================================================
--- a/lib/options.js
+++ b/lib/options.js
@@ -21,7 +21,6 @@
const {getDecodedHostname} = require("url");
const {checkWhitelisted} = require("whitelisting");
-const {port} = require("messaging");
const info = require("info");
const optionsUrl = "options.html";
@@ -107,17 +106,26 @@
if (!tab)
return;
- function onMessage(message, sender)
+ function onMessage(message, port)
{
- if (message.type == "app.listen" &&
- sender.page && sender.page.id == tab.id)
- {
- port.off("app.listen", onMessage);
- callback(new ext.Page(tab));
- }
+ if (message.type != "app.listen")
+ return;
+
+ port.onMessage.removeListener(onMessage);
+ callback(new ext.Page(tab));
}
- port.on("app.listen", onMessage);
+ function onConnect(port)
+ {
+ let {name, sender} = port;
+ if (name != "ui" || !sender || sender.tab.id != tab.id)
+ return;
+
+ browser.runtime.onConnect.removeListener(onConnect);
+ port.onMessage.addListener(onMessage);
+ }
+
+ browser.runtime.onConnect.addListener(onConnect);
});
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld