| 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-2017 eyeo GmbH | 3  * Copyright (C) 2006-2017 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 16 matching lines...) Expand all  Loading... | 
| 27 const {extractHostFromFrame} = require("url"); | 27 const {extractHostFromFrame} = require("url"); | 
| 28 const {port} = require("messaging"); | 28 const {port} = require("messaging"); | 
| 29 | 29 | 
| 30 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", "GENERICBLOCK", "GENERICHIDE"]; | 30 const nonRequestTypes = ["DOCUMENT", "ELEMHIDE", "GENERICBLOCK", "GENERICHIDE"]; | 
| 31 | 31 | 
| 32 // Mapping of inspected tabs to their devpanel page | 32 // Mapping of inspected tabs to their devpanel page | 
| 33 // and recorded items. We can't use a PageMap here, | 33 // and recorded items. We can't use a PageMap here, | 
| 34 // because data must persist after navigation/reload. | 34 // because data must persist after navigation/reload. | 
| 35 let panels = new Map(); | 35 let panels = new Map(); | 
| 36 | 36 | 
|  | 37 function isActivePanel(panel) | 
|  | 38 { | 
|  | 39   return panel && !panel.reload && !panel.reloading; | 
|  | 40 } | 
|  | 41 | 
| 37 function getActivePanel(page) | 42 function getActivePanel(page) | 
| 38 { | 43 { | 
| 39   let panel = panels.get(page.id); | 44   let panel = panels.get(page.id); | 
| 40   if (panel && !panel.reload && !panel.reloading) | 45   if (isActivePanel(panel)) | 
| 41     return panel; | 46     return panel; | 
| 42   return null; | 47   return null; | 
| 43 } | 48 } | 
| 44 | 49 | 
| 45 function getFilterInfo(filter) | 50 function getFilterInfo(filter) | 
| 46 { | 51 { | 
| 47   if (!filter) | 52   if (!filter) | 
| 48     return null; | 53     return null; | 
| 49 | 54 | 
| 50   let userDefined = false; | 55   let userDefined = false; | 
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 109     request.docDomain, | 114     request.docDomain, | 
| 110     request.thirdParty, | 115     request.thirdParty, | 
| 111     request.sitekey, | 116     request.sitekey, | 
| 112     request.specificOnly | 117     request.specificOnly | 
| 113   ); | 118   ); | 
| 114 } | 119 } | 
| 115 | 120 | 
| 116 /** | 121 /** | 
| 117  * Logs a request to the devtools panel. | 122  * Logs a request to the devtools panel. | 
| 118  * | 123  * | 
| 119  * @param {Page}     page          The page the request occured on | 124  * @param {?Page}    page          The page the request occured on or null if | 
|  | 125  *                                 the request isn't associated with a page | 
| 120  * @param {string}   url           The URL of the request | 126  * @param {string}   url           The URL of the request | 
| 121  * @param {string}   type          The request type | 127  * @param {string}   type          The request type | 
| 122  * @param {string}   docDomain     The IDN-decoded hostname of the document | 128  * @param {string}   docDomain     The IDN-decoded hostname of the document | 
| 123  * @param {boolean}  thirdParty    Whether the origin of the request and | 129  * @param {boolean}  thirdParty    Whether the origin of the request and | 
| 124  *                                 document differs | 130  *                                 document differs | 
| 125  * @param {?string}  sitekey       The active sitekey if there is any | 131  * @param {?string}  sitekey       The active sitekey if there is any | 
| 126  * @param {?boolean} specificOnly  Whether generic filters should be ignored | 132  * @param {?boolean} specificOnly  Whether generic filters should be ignored | 
| 127  * @param {?BlockingFilter} filter The matched filter or null if there is no | 133  * @param {?BlockingFilter} filter The matched filter or null if there is no | 
| 128  *                                 match | 134  *                                 match | 
| 129  */ | 135  */ | 
| 130 exports.logRequest = function(page, url, type, docDomain, | 136 exports.logRequest = function(page, url, type, docDomain, | 
| 131                               thirdParty, sitekey, | 137                               thirdParty, sitekey, | 
| 132                               specificOnly, filter) | 138                               specificOnly, filter) | 
| 133 { | 139 { | 
| 134   let panel = getActivePanel(page); | 140   if (panels.size == 0) | 
| 135   if (panel) | 141     return; | 
| 136   { | 142 | 
| 137     let request = {url, type, docDomain, thirdParty, sitekey, specificOnly}; | 143   let request = {url, type, docDomain, thirdParty, sitekey, specificOnly}; | 
| 138     addRecord(panel, request, filter); | 144   for (let [tabId, panel] of panels) | 
| 139   } | 145     if ((!page || page.id == tabId) && isActivePanel(panel)) | 
|  | 146       addRecord(panel, request, filter); | 
| 140 }; | 147 }; | 
| 141 | 148 | 
| 142 /** | 149 /** | 
| 143  * Logs active element hiding filters to the devtools panel. | 150  * Logs active element hiding filters to the devtools panel. | 
| 144  * | 151  * | 
| 145  * @param {Page}     page       The page the elements were hidden on | 152  * @param {Page}     page       The page the elements were hidden on | 
| 146  * @param {string[]} selectors  The selectors of applied ElemHideFilters | 153  * @param {string[]} selectors  The selectors of applied ElemHideFilters | 
| 147  * @param {string[]} filters    The text of applied ElemHideEmulationFilters | 154  * @param {string[]} filters    The text of applied ElemHideEmulationFilters | 
| 148  * @param {string}   docDomain  The IDN-decoded hostname of the document | 155  * @param {string}   docDomain  The IDN-decoded hostname of the document | 
| 149  */ | 156  */ | 
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 370   panels.set(inspectedTabId, {port: newPort, records: []}); | 377   panels.set(inspectedTabId, {port: newPort, records: []}); | 
| 371 }); | 378 }); | 
| 372 | 379 | 
| 373 port.on("devtools.traceElemHide", (message, sender) => | 380 port.on("devtools.traceElemHide", (message, sender) => | 
| 374 { | 381 { | 
| 375   logHiddenElements( | 382   logHiddenElements( | 
| 376     sender.page, message.selectors, message.filters, | 383     sender.page, message.selectors, message.filters, | 
| 377     extractHostFromFrame(sender.frame) | 384     extractHostFromFrame(sender.frame) | 
| 378   ); | 385   ); | 
| 379 }); | 386 }); | 
| OLD | NEW | 
|---|