| LEFT | RIGHT |
| 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 13 matching lines...) Expand all Loading... |
| 24 this._messageDispatcher = messageDispatcher; | 24 this._messageDispatcher = messageDispatcher; |
| 25 this._responseCallbacks = {__proto__: null}; | 25 this._responseCallbacks = {__proto__: null}; |
| 26 this._responseCallbackCounter = 0; | 26 this._responseCallbackCounter = 0; |
| 27 }; | 27 }; |
| 28 MessageProxy.prototype = { | 28 MessageProxy.prototype = { |
| 29 _sendResponse: function(request, message) | 29 _sendResponse: function(request, message) |
| 30 { | 30 { |
| 31 var response = {}; | 31 var response = {}; |
| 32 for (var prop in request) | 32 for (var prop in request) |
| 33 response[prop] = request[prop]; | 33 response[prop] = request[prop]; |
| 34 if (typeof message != "undefined") | 34 response.payload = message; |
| 35 response.payload = message; | |
| 36 | 35 |
| 37 this._messageDispatcher.dispatchMessage("response", response); | 36 this._messageDispatcher.dispatchMessage("response", response); |
| 38 }, | 37 }, |
| 39 handleRequest: function(request, sender) | 38 handleRequest: function(request, sender) |
| 40 { | 39 { |
| 41 if ("callbackId" in request) | 40 if ("callbackId" in request) |
| 42 { | 41 { |
| 43 var sent = false; | 42 var sent = false; |
| 44 var sendResponse = function(message) | 43 var sendResponse = function(message) |
| 45 { | 44 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 62 } | 61 } |
| 63 }, | 62 }, |
| 64 handleResponse: function(response) | 63 handleResponse: function(response) |
| 65 { | 64 { |
| 66 var callbackId = response.callbackId; | 65 var callbackId = response.callbackId; |
| 67 var callback = this._responseCallbacks[callbackId]; | 66 var callback = this._responseCallbacks[callbackId]; |
| 68 if (callback) | 67 if (callback) |
| 69 { | 68 { |
| 70 delete this._responseCallbacks[callbackId]; | 69 delete this._responseCallbacks[callbackId]; |
| 71 | 70 |
| 72 if ("payload" in response) | 71 if (typeof response.payload != "undefined") |
| 73 callback(response.payload); | 72 callback(response.payload); |
| 74 } | 73 } |
| 75 }, | 74 }, |
| 76 sendMessage: function(message, responseCallback, extra) | 75 sendMessage: function(message, responseCallback, extra) |
| 77 { | 76 { |
| 78 var request = {payload: message}; | 77 var request = {payload: message}; |
| 79 | 78 |
| 80 if (responseCallback) | 79 if (responseCallback) |
| 81 { | 80 { |
| 82 request.callbackId = ++this._responseCallbackCounter; | 81 request.callbackId = ++this._responseCallbackCounter; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 }; | 211 }; |
| 213 | 212 |
| 214 | 213 |
| 215 /* Utils */ | 214 /* Utils */ |
| 216 | 215 |
| 217 ext.getURL = function(path) | 216 ext.getURL = function(path) |
| 218 { | 217 { |
| 219 return safari.extension.baseURI + path; | 218 return safari.extension.baseURI + path; |
| 220 }; | 219 }; |
| 221 })(); | 220 })(); |
| LEFT | RIGHT |