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 |
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 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", null); | 18 let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", null); |
19 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); | 19 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); |
20 let {MessageProxy, EventTarget, getSender} = require("ext_common"); | 20 let { |
| 21 _MessageProxy: MessageProxy, |
| 22 _EventTarget: EventTarget, |
| 23 _getSender: getSender |
| 24 } = require("ext_common"); |
21 exports.onMessage = new EventTarget(); | 25 exports.onMessage = new EventTarget(); |
22 | 26 |
23 let messageProxy = new MessageProxy( | 27 let messageProxy = new MessageProxy( |
24 Cc["@mozilla.org/globalmessagemanager;1"] | 28 Cc["@mozilla.org/globalmessagemanager;1"] |
25 .getService(Ci.nsIMessageListenerManager), | 29 .getService(Ci.nsIMessageListenerManager), |
26 exports.onMessage); | 30 exports.onMessage); |
27 onShutdown.add(function() | 31 onShutdown.add(function() |
28 { | 32 { |
29 messageProxy._disconnect(); | 33 messageProxy._disconnect(); |
30 }); | 34 }); |
(...skipping 11 matching lines...) Expand all Loading... |
42 }; | 46 }; |
43 exports.Page = Page; | 47 exports.Page = Page; |
44 | 48 |
45 function PageMap() | 49 function PageMap() |
46 { | 50 { |
47 this._map = new Map(); | 51 this._map = new Map(); |
48 | 52 |
49 Services.obs.addObserver(this, "message-manager-disconnect", true); | 53 Services.obs.addObserver(this, "message-manager-disconnect", true); |
50 onShutdown.add(function() | 54 onShutdown.add(function() |
51 { | 55 { |
52 Services.obs.removeObserver(this, "message-manager-disconnect", true); | 56 Services.obs.removeObserver(this, "message-manager-disconnect"); |
53 }); | 57 }.bind(this)); |
54 } | 58 } |
55 PageMap.prototype = { | 59 PageMap.prototype = { |
56 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRefer
ence]), | 60 QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakRefer
ence]), |
57 | 61 |
58 observe: function(subject, topic, data) | 62 observe: function(subject, topic, data) |
59 { | 63 { |
60 if (topic == "message-manager-disconnect") | 64 if (topic == "message-manager-disconnect") |
61 this._map.delete(subject); | 65 this._map.delete(subject); |
62 }, | 66 }, |
63 | 67 |
(...skipping 20 matching lines...) Expand all Loading... |
84 { | 88 { |
85 return this._map.has(page._sender); | 89 return this._map.has(page._sender); |
86 }, | 90 }, |
87 | 91 |
88 delete: function(page) | 92 delete: function(page) |
89 { | 93 { |
90 this._map.delete(page._sender); | 94 this._map.delete(page._sender); |
91 } | 95 } |
92 }; | 96 }; |
93 exports.PageMap = PageMap; | 97 exports.PageMap = PageMap; |
LEFT | RIGHT |