Left: | ||
Right: |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 target = chrome.extension.onMessage; | 63 target = chrome.extension.onMessage; |
64 else | 64 else |
65 target = chrome.extension.onRequest; | 65 target = chrome.extension.onRequest; |
66 WrappedEventTarget.call(this, target); | 66 WrappedEventTarget.call(this, target); |
67 }; | 67 }; |
68 MessageEventTarget.prototype = { | 68 MessageEventTarget.prototype = { |
69 __proto__: WrappedEventTarget.prototype, | 69 __proto__: WrappedEventTarget.prototype, |
70 _wrapListener: function(listener) { | 70 _wrapListener: function(listener) { |
71 return function(message, sender, sendResponse) | 71 return function(message, sender, sendResponse) |
72 { | 72 { |
73 if (sender.tab && sender.tab.id >= 0) | 73 if ("Tab" in window && sender.tab && sender.tab.id >= 0) |
Wladimir Palant
2014/01/16 08:01:10
So we have content scripts receive messages where
Thomas Greiner
2014/01/16 10:15:30
Yes, that is the case and it seems like it's inten
Wladimir Palant
2014/01/16 10:44:49
Ok, this actually makes sense then.
| |
74 sender.tab = new Tab(sender.tab); | 74 sender.tab = new Tab(sender.tab); |
75 return listener(message, sender, sendResponse); | 75 return listener(message, sender, sendResponse); |
76 }; | 76 }; |
77 } | 77 } |
78 }; | 78 }; |
79 | 79 |
80 | 80 |
81 /* API */ | 81 /* API */ |
82 | 82 |
83 ext = { | 83 ext = { |
84 backgroundPage: { | 84 backgroundPage: { |
85 getWindow: function() | 85 getWindow: function() |
86 { | 86 { |
87 return chrome.extension.getBackgroundPage(); | 87 return chrome.extension.getBackgroundPage(); |
88 } | 88 } |
89 }, | 89 }, |
90 getURL: chrome.extension.getURL, | 90 getURL: chrome.extension.getURL, |
91 onMessage: new MessageEventTarget(), | 91 onMessage: new MessageEventTarget(), |
92 i18n: chrome.i18n | 92 i18n: chrome.i18n |
93 }; | 93 }; |
94 | 94 |
95 if ("runtime" in chrome && "sendMessage" in chrome.runtime) | 95 if ("runtime" in chrome && "sendMessage" in chrome.runtime) |
96 ext.backgroundPage.sendMessage = chrome.runtime.sendMessage; | 96 ext.backgroundPage.sendMessage = chrome.runtime.sendMessage; |
97 else if ("sendMessage" in chrome.extension) | 97 else if ("sendMessage" in chrome.extension) |
98 ext.backgroundPage.sendMessage = chrome.extension.sendMessage; | 98 ext.backgroundPage.sendMessage = chrome.extension.sendMessage; |
99 else | 99 else |
100 ext.backgroundPage.sendMessage = chrome.extension.sendRequest; | 100 ext.backgroundPage.sendMessage = chrome.extension.sendRequest; |
101 })(); | 101 })(); |
OLD | NEW |