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

Unified Diff: chrome/ext/content.js

Issue 5186743326212096: Issue 1843 - Deactivate "Block element" dialog when extension is disabled/uninstalled/reloaded (Closed)
Patch Set: Re-phrased comment Created Jan. 26, 2015, 4:11 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 | « chrome/ext/background.js ('k') | include.postload.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/content.js
===================================================================
--- a/chrome/ext/content.js
+++ b/chrome/ext/content.js
@@ -2,3 +2,33 @@
{
return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1;
});
+
+ext.onExtensionUnloaded = (function()
+{
+ var port = null;
+
+ return {
+ addListener: function(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: function(listener)
+ {
+ if (port)
+ {
+ port.onDisconnect.removeListener(listener)
+
+ if (!port.onDisconnect.hasListeners())
+ {
+ port.disconnect();
+ port = null;
+ }
+ }
+ }
+ };
+})();
« no previous file with comments | « chrome/ext/background.js ('k') | include.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld