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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 browser.runtime.onConnect.addListener(newPort => | 234 browser.runtime.onConnect.addListener(newPort => |
235 { | 235 { |
236 let match = newPort.name.match(/^devtools-(\d+)$/); | 236 let match = newPort.name.match(/^devtools-(\d+)$/); |
237 if (!match) | 237 if (!match) |
238 return; | 238 return; |
239 | 239 |
240 let inspectedTabId = parseInt(match[1], 10); | 240 let inspectedTabId = parseInt(match[1], 10); |
241 let localOnBeforeRequest = onBeforeRequest.bind(); | 241 let localOnBeforeRequest = onBeforeRequest.bind(); |
242 let panel = {port: newPort, records: []}; | 242 let panel = {port: newPort, records: []}; |
| 243 let hitListener = addRecord.bind(null, panel); |
243 | 244 |
244 browser.webRequest.onBeforeRequest.addListener( | 245 browser.webRequest.onBeforeRequest.addListener( |
245 localOnBeforeRequest, | 246 localOnBeforeRequest, |
246 { | 247 { |
247 urls: ["http://*/*", "https://*/*"], | 248 urls: ["http://*/*", "https://*/*"], |
248 types: ["main_frame"], | 249 types: ["main_frame"], |
249 tabId: inspectedTabId | 250 tabId: inspectedTabId |
250 } | 251 } |
251 ); | 252 ); |
252 | 253 |
253 if (panels.size == 0) | 254 if (panels.size == 0) |
254 { | 255 { |
255 ext.pages.onLoading.addListener(onLoading); | 256 ext.pages.onLoading.addListener(onLoading); |
256 FilterNotifier.on("filter.added", onFilterAdded); | 257 FilterNotifier.on("filter.added", onFilterAdded); |
257 FilterNotifier.on("filter.removed", onFilterRemoved); | 258 FilterNotifier.on("filter.removed", onFilterRemoved); |
258 FilterNotifier.on("subscription.added", onSubscriptionAdded); | 259 FilterNotifier.on("subscription.added", onSubscriptionAdded); |
259 } | 260 } |
260 | 261 |
261 let hitListener = addRecord.bind(null, panel); | |
262 | |
263 newPort.onDisconnect.addListener(() => | 262 newPort.onDisconnect.addListener(() => |
264 { | 263 { |
265 HitLogger.off(inspectedTabId, hitListener); | 264 HitLogger.removeListener(inspectedTabId, hitListener); |
266 panels.delete(inspectedTabId); | 265 panels.delete(inspectedTabId); |
267 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); | 266 browser.webRequest.onBeforeRequest.removeListener(localOnBeforeRequest); |
268 | 267 |
269 if (panels.size == 0) | 268 if (panels.size == 0) |
270 { | 269 { |
271 ext.pages.onLoading.removeListener(onLoading); | 270 ext.pages.onLoading.removeListener(onLoading); |
272 FilterNotifier.off("filter.added", onFilterAdded); | 271 FilterNotifier.off("filter.added", onFilterAdded); |
273 FilterNotifier.off("filter.removed", onFilterRemoved); | 272 FilterNotifier.off("filter.removed", onFilterRemoved); |
274 FilterNotifier.off("subscription.added", onSubscriptionAdded); | 273 FilterNotifier.off("subscription.added", onSubscriptionAdded); |
275 } | 274 } |
276 }); | 275 }); |
277 | 276 |
278 HitLogger.on(inspectedTabId, hitListener); | 277 HitLogger.addListener(inspectedTabId, hitListener); |
279 panels.set(inspectedTabId, panel); | 278 panels.set(inspectedTabId, panel); |
280 }); | 279 }); |
LEFT | RIGHT |