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

Unified Diff: ext/content.js

Issue 29403564: Issue 5083 - Merges chrome subdirectory to top level directory (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome
Patch Set: Created April 10, 2017, 6:52 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
« no previous file with comments | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/content.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/ext/content.js
@@ -0,0 +1,36 @@
+"use strict";
+
+chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
+{
+ return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1;
+});
+
+(function()
+{
+ let port = null;
+
+ ext.onExtensionUnloaded = {
+ addListener(listener)
+ {
+ if (!port)
+ port = chrome.runtime.connect();
+
+ // When the extension is reloaded, disabled or uninstalled the
+ // background page dies and automatically disconnects all ports
+ port.onDisconnect.addListener(listener);
+ },
+ removeListener(listener)
+ {
+ if (port)
+ {
+ port.onDisconnect.removeListener(listener);
+
+ if (!port.onDisconnect.hasListeners())
+ {
+ port.disconnect();
+ port = null;
+ }
+ }
+ }
+ };
+}());
« no previous file with comments | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld