| 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-2015 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 global.ext.backgroundPage = { | 47 global.ext.backgroundPage = { |
| 48 _sendRawMessage: function(message) | 48 _sendRawMessage: function(message) |
| 49 { | 49 { |
| 50 if (messageQueue) | 50 if (messageQueue) |
| 51 messageQueue.push(message); | 51 messageQueue.push(message); |
| 52 else | 52 else |
| 53 backgroundFrame.contentWindow.postMessage(message, "*"); | 53 backgroundFrame.contentWindow.postMessage(message, "*"); |
| 54 }, | 54 }, |
| 55 sendMessage: function(message, responseCallback) | 55 sendMessage: function(message, responseCallback) |
| 56 { | 56 { |
| 57 var messageId = ++maxMessageId; |
| 58 |
| 57 this._sendRawMessage({ | 59 this._sendRawMessage({ |
| 58 type: "message", | 60 type: "message", |
| 59 messageId: ++maxMessageId, | 61 messageId: messageId, |
| 60 payload: message | 62 payload: message |
| 61 }); | 63 }); |
| 62 | 64 |
| 63 if (responseCallback) | 65 if (responseCallback) |
| 64 { | 66 { |
| 65 var callbackWrapper = function(event) | 67 var callbackWrapper = function(event) |
| 66 { | 68 { |
| 67 if (event.data.type == "response" && event.data.messageId == rawMessag
e.messageId) | 69 if (event.data.type == "response" && event.data.messageId == messageId
) |
| 68 { | 70 { |
| 69 window.removeEventListener("message", callbackWrapper, false); | 71 window.removeEventListener("message", callbackWrapper, false); |
| 70 responseCallback(event.data.payload); | 72 responseCallback(event.data.payload); |
| 71 } | 73 } |
| 72 }; | 74 }; |
| 73 window.addEventListener("message", callbackWrapper, false); | 75 window.addEventListener("message", callbackWrapper, false); |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 }; | 78 }; |
| 77 })(this); | 79 })(this); |
| LEFT | RIGHT |