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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 this._target.removeListener(this._wrappedListeners[idx]); | 49 this._target.removeListener(this._wrappedListeners[idx]); |
50 | 50 |
51 this._listeners.splice(idx, 1); | 51 this._listeners.splice(idx, 1); |
52 this._wrappedListeners.splice(idx, 1); | 52 this._wrappedListeners.splice(idx, 1); |
53 } | 53 } |
54 } | 54 } |
55 }; | 55 }; |
56 | 56 |
57 var MessageEventTarget = function() | 57 var MessageEventTarget = function() |
58 { | 58 { |
59 WrappedEventTarget.call(this, chrome.runtime.onMessage); | 59 WrappedEventTarget.call(this, (chrome.runtime || {}).onMessage || chrome.ext
ension.onRequest); |
60 }; | 60 }; |
61 MessageEventTarget.prototype = { | 61 MessageEventTarget.prototype = { |
62 __proto__: WrappedEventTarget.prototype, | 62 __proto__: WrappedEventTarget.prototype, |
63 _wrapListener: function(listener) { | 63 _wrapListener: function(listener) { |
64 return function(message, sender, sendResponse) | 64 return function(message, sender, sendResponse) |
65 { | 65 { |
66 listener(message, {tab: sender.tab && new Tab(sender.tab)}, sendResponse
); | 66 listener(message, {tab: sender.tab && new Tab(sender.tab)}, sendResponse
); |
67 }; | 67 }; |
68 } | 68 } |
69 }; | 69 }; |
70 | 70 |
| 71 |
71 /* API */ | 72 /* API */ |
72 | 73 |
73 ext = { | 74 ext = { |
74 backgroundPage: { | 75 backgroundPage: { |
75 sendMessage: function(message, responseCallback) | 76 sendMessage: (chrome.runtime || {}).sendMessage || chrome.extension.sendRe
quest, |
76 { | 77 getWindow: chrome.extension.getBackgroundPage |
77 chrome.runtime.sendMessage(message, responseCallback); | |
78 }, | |
79 getWindow: function() | |
80 { | |
81 return chrome.extension.getBackgroundPage(); | |
82 } | |
83 }, | 78 }, |
84 getURL: chrome.extension.getURL, | 79 getURL: chrome.extension.getURL, |
85 onMessage: new MessageEventTarget(), | 80 onMessage: new MessageEventTarget(), |
86 i18n: chrome.i18n | 81 i18n: chrome.i18n |
87 }; | 82 }; |
88 })(); | 83 })(); |
OLD | NEW |