OLD | NEW |
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 12 matching lines...) Expand all Loading... |
23 { | 23 { |
24 const {port} = require("messaging"); | 24 const {port} = require("messaging"); |
25 const {Prefs} = require("prefs"); | 25 const {Prefs} = require("prefs"); |
26 const {Utils} = require("utils"); | 26 const {Utils} = require("utils"); |
27 const {FilterStorage} = require("filterStorage"); | 27 const {FilterStorage} = require("filterStorage"); |
28 const {FilterNotifier} = require("filterNotifier"); | 28 const {FilterNotifier} = require("filterNotifier"); |
29 const {defaultMatcher} = require("matcher"); | 29 const {defaultMatcher} = require("matcher"); |
30 const {Notification: NotificationStorage} = require("notification"); | 30 const {Notification: NotificationStorage} = require("notification"); |
31 const {getActiveNotification, shouldDisplay, | 31 const {getActiveNotification, shouldDisplay, |
32 notificationClicked} = require("notificationHelper"); | 32 notificationClicked} = require("notificationHelper"); |
| 33 const {HitLogger} = require("hitLogger"); |
33 | 34 |
34 const { | 35 const { |
35 Filter, ActiveFilter, BlockingFilter, RegExpFilter | 36 Filter, ActiveFilter, BlockingFilter, RegExpFilter |
36 } = require("filterClasses"); | 37 } = require("filterClasses"); |
37 const {Synchronizer} = require("synchronizer"); | 38 const {Synchronizer} = require("synchronizer"); |
38 | 39 |
39 const info = require("info"); | 40 const info = require("info"); |
40 const { | 41 const { |
41 Subscription, | 42 Subscription, |
42 DownloadableSubscription, | 43 DownloadableSubscription, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 parseInt(info.applicationVersion, 10) >= 54 | 195 parseInt(info.applicationVersion, 10) >= 54 |
195 }; | 196 }; |
196 } | 197 } |
197 | 198 |
198 if (message.what == "senderId") | 199 if (message.what == "senderId") |
199 return sender.page.id; | 200 return sender.page.id; |
200 | 201 |
201 return info[message.what]; | 202 return info[message.what]; |
202 }); | 203 }); |
203 | 204 |
| 205 port.on("app.listen", (message, sender) => |
| 206 { |
| 207 getListenerFilters(sender.page).app = message.filter; |
| 208 }); |
| 209 |
| 210 port.on("app.collectHits", (message, sender) => |
| 211 { |
| 212 const logRequest = (log) => |
| 213 { |
| 214 let {filter, request} = log; |
| 215 let subscriptions = []; |
| 216 if (filter) |
| 217 { |
| 218 for (const soubscription of FilterStorage.subscriptions) |
| 219 { |
| 220 for (const text of soubscription.filters) |
| 221 { |
| 222 if (text == filter.text) |
| 223 subscriptions.push(soubscription.url); |
| 224 } |
| 225 } |
| 226 filter = convertObject(["text", "subscription"], filter); |
| 227 } |
| 228 request = convertObject(["url", "type", "docDomain", "thirdParty"], |
| 229 request); |
| 230 sendMessage("app", "devLog", request, filter, subscriptions); |
| 231 }; |
| 232 const removeTabListeners = (tabId) => |
| 233 { |
| 234 if (tabId == message.tab.id || tabId == sender.page.id) |
| 235 { |
| 236 HitLogger.off(message.tab.id, logRequest); |
| 237 browser.tabs.onRemoved.removeListener(removeTabListeners); |
| 238 } |
| 239 }; |
| 240 HitLogger.on(message.tab.id, logRequest); |
| 241 browser.tabs.onRemoved.addListener(removeTabListeners); |
| 242 }); |
| 243 |
204 port.on("app.open", (message, sender) => | 244 port.on("app.open", (message, sender) => |
205 { | 245 { |
206 if (message.what == "options") | 246 if (message.what == "options") |
207 { | 247 { |
208 showOptions(() => | 248 showOptions(() => |
209 { | 249 { |
210 if (!message.action) | 250 if (!message.action) |
211 return; | 251 return; |
212 | 252 |
213 sendMessage("app", message.action, ...message.args); | 253 sendMessage("app", message.action, ...message.args); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // "*.listen" messages to tackle #6440 | 516 // "*.listen" messages to tackle #6440 |
477 if (action == "listen") | 517 if (action == "listen") |
478 { | 518 { |
479 listen(type, filters, message.filter); | 519 listen(type, filters, message.filter); |
480 } | 520 } |
481 }); | 521 }); |
482 } | 522 } |
483 | 523 |
484 browser.runtime.onConnect.addListener(onConnect); | 524 browser.runtime.onConnect.addListener(onConnect); |
485 })(this); | 525 })(this); |
OLD | NEW |