OLD | NEW |
1 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) | 1 chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) |
2 { | 2 { |
3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; | 3 return ext.onMessage._dispatch(message, {}, sendResponse).indexOf(true) != -1; |
4 }); | 4 }); |
| 5 |
| 6 ext.onExtensionUnloaded = (function() |
| 7 { |
| 8 var port = null; |
| 9 |
| 10 return { |
| 11 addListener: function(listener) |
| 12 { |
| 13 if (!port) |
| 14 port = chrome.runtime.connect(); |
| 15 |
| 16 // When the extension is reloaded, disabled or uninstalled the |
| 17 // background page dies and automatically disconnects all ports |
| 18 port.onDisconnect.addListener(listener); |
| 19 }, |
| 20 removeListener: function(listener) |
| 21 { |
| 22 if (port) |
| 23 { |
| 24 port.onDisconnect.removeListener(listener) |
| 25 |
| 26 if (!port.onDisconnect.hasListeners()) |
| 27 { |
| 28 port.disconnect(); |
| 29 port = null; |
| 30 } |
| 31 } |
| 32 } |
| 33 }; |
| 34 })(); |
OLD | NEW |