| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 23 matching lines...) Expand all Loading... |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 var getSender = global.ext._getSender = function(origin) | 36 var getSender = global.ext._getSender = function(origin) |
| 37 { | 37 { |
| 38 if (origin instanceof Ci.nsIDOMXULElement) | 38 if (origin instanceof Ci.nsIDOMXULElement) |
| 39 return origin.messageManager; | 39 return origin.messageManager; |
| 40 else if (origin instanceof Ci.nsIMessageSender) | 40 else if (origin instanceof Ci.nsIMessageSender) |
| 41 return origin; | 41 return origin; |
| 42 else | 42 else |
| 43 return null; | 43 return null; |
| 44 } | 44 }; |
| 45 | 45 |
| 46 var MessageProxy = global.ext._MessageProxy = function(messageManager, message
Target) | 46 var MessageProxy = global.ext._MessageProxy = function(messageManager, message
Target) |
| 47 { | 47 { |
| 48 this._messageManager = messageManager; | 48 this._messageManager = messageManager; |
| 49 this._messageTarget = messageTarget; | 49 this._messageTarget = messageTarget; |
| 50 this._callbacks = new Map(); | 50 this._callbacks = new Map(); |
| 51 this._responseCallbackCounter = 0; | 51 this._responseCallbackCounter = 0; |
| 52 | 52 |
| 53 this._handleRequest = this._handleRequest.bind(this); | 53 this._handleRequest = this._handleRequest.bind(this); |
| 54 this._handleResponse = this._handleResponse.bind(this); | 54 this._handleResponse = this._handleResponse.bind(this); |
| 55 this._messageManager.addMessageListener("AdblockPlus:Message", this._handleR
equest); | 55 this._messageManager.addMessageListener("AdblockPlus:Message", this._handleR
equest); |
| 56 this._messageManager.addMessageListener("AdblockPlus:Response", this._handle
Response); | 56 this._messageManager.addMessageListener("AdblockPlus:Response", this._handle
Response); |
| 57 } | 57 }; |
| 58 MessageProxy.prototype = { | 58 MessageProxy.prototype = { |
| 59 _disconnect: function() | 59 _disconnect: function() |
| 60 { | 60 { |
| 61 this._messageManager.removeMessageListener("AdblockPlus:Message", this._ha
ndleRequest); | 61 this._messageManager.removeMessageListener("AdblockPlus:Message", this._ha
ndleRequest); |
| 62 this._messageManager.removeMessageListener("AdblockPlus:Response", this._h
andleResponse); | 62 this._messageManager.removeMessageListener("AdblockPlus:Response", this._h
andleResponse); |
| 63 }, | 63 }, |
| 64 | 64 |
| 65 _sendResponse: function(sender, callbackId, message) | 65 _sendResponse: function(sender, callbackId, message) |
| 66 { | 66 { |
| 67 var response = { | 67 var response = { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 for (var i = 0; i < this._listeners.length; i++) | 150 for (var i = 0; i < this._listeners.length; i++) |
| 151 results.push(this._listeners[i].apply(null, arguments)); | 151 results.push(this._listeners[i].apply(null, arguments)); |
| 152 | 152 |
| 153 return results; | 153 return results; |
| 154 } | 154 } |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 if (typeof exports == "object") | 157 if (typeof exports == "object") |
| 158 exports = global.ext; | 158 exports = global.ext; |
| 159 })(this); | 159 })(this); |
| OLD | NEW |