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: Created Jan. 23, 2015, 9:47 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
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;
+ }
+ }
+ }
+ };
+})();
« chrome/ext/background.js ('K') | « chrome/ext/background.js ('k') | include.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld