LEFT | RIGHT |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 19 matching lines...) Expand all Loading... |
30 { | 30 { |
31 this._eventEmitter = new EventEmitter(); | 31 this._eventEmitter = new EventEmitter(); |
32 this._onMessage = this._onMessage.bind(this); | 32 this._onMessage = this._onMessage.bind(this); |
33 ext.onMessage.addListener(this._onMessage); | 33 ext.onMessage.addListener(this._onMessage); |
34 }; | 34 }; |
35 | 35 |
36 Port.prototype = { | 36 Port.prototype = { |
37 _onMessage: function(message, sender, sendResponse) | 37 _onMessage: function(message, sender, sendResponse) |
38 { | 38 { |
39 let async = false; | 39 let async = false; |
40 let callbacks = this._eventEmitter._callbacks[message.type]; | 40 let callbacks = this._eventEmitter._listeners[message.type]; |
41 | 41 |
42 if (callbacks) | 42 if (callbacks) |
43 { | 43 { |
44 for (let callback of callbacks) | 44 for (let callback of callbacks) |
45 { | 45 { |
46 let response = callback(message, sender); | 46 let response = callback(message, sender); |
47 | 47 |
48 if (response && typeof response.then == "function") | 48 if (response && typeof response.then == "function") |
49 { | 49 { |
50 response.then( | 50 response.then( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 exports.getPort = function(window) | 125 exports.getPort = function(window) |
126 { | 126 { |
127 let port = new Port(); | 127 let port = new Port(); |
128 window.addEventListener("unload", () => | 128 window.addEventListener("unload", () => |
129 { | 129 { |
130 port.disconnect(); | 130 port.disconnect(); |
131 }); | 131 }); |
132 return port; | 132 return port; |
133 }; | 133 }; |
134 | 134 |
LEFT | RIGHT |