Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/hitLogger.js

Issue 29705719: Issue 6402 - Split filter hit / request logging out into own API (Closed)
Left Patch Set: Addressed Sebastian's feedback Created May 3, 2018, 3:55 p.m.
Right Patch Set: Addressed Manish's feedback Created May 9, 2018, 5:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/devtools.js ('k') | lib/popupBlocker.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 * 74 *
75 * @param {number[]} tabIds 75 * @param {number[]} tabIds
76 * The tabIds associated with the request 76 * The tabIds associated with the request
77 * @param {Object} request 77 * @param {Object} request
78 * The request to log 78 * The request to log
79 * @param {string} request.url 79 * @param {string} request.url
80 * The URL of the request 80 * The URL of the request
81 * @param {string} request.type 81 * @param {string} request.type
82 * The request type 82 * The request type
83 * @param {string} request.docDomain 83 * @param {string} request.docDomain
84 * The IDN-decoded hostname of the document 84 * The hostname of the document
85 * @param {boolean} request.thirdParty 85 * @param {boolean} request.thirdParty
86 * Whether the origin of the request and document differs 86 * Whether the origin of the request and document differs
87 * @param {?string} request.sitekey 87 * @param {?string} request.sitekey
88 * The active sitekey if there is any 88 * The active sitekey if there is any
89 * @param {?boolean} request.specificOnly 89 * @param {?boolean} request.specificOnly
90 * Whether generic filters should be ignored 90 * Whether generic filters should be ignored
91 * @param {?BlockingFilter} filter 91 * @param {?BlockingFilter} filter
92 * The matched filter or null if there is no match 92 * The matched filter or null if there is no match
93 */ 93 */
94 exports.logRequest = (tabIds, request, filter) => 94 exports.logRequest = (tabIds, request, filter) =>
95 { 95 {
96 for (let tabId of tabIds) 96 for (let tabId of tabIds)
97 eventEmitter.emit(tabId, request, filter); 97 eventEmitter.emit(tabId, request, filter);
98 }; 98 };
99 99
100 /** 100 /**
101 * Logs active element hiding filters for a tab. 101 * Logs active element hiding filters for a tab.
102 * 102 *
103 * @param {number} tabId The ID of the tab, the elements were hidden in 103 * @param {number} tabId The ID of the tab, the elements were hidden in
104 * @param {string[]} selectors The selectors of applied ElemHideFilters 104 * @param {string[]} selectors The selectors of applied ElemHideFilters
105 * @param {string[]} filters The text of applied ElemHideEmulationFilters 105 * @param {string[]} filters The text of applied ElemHideEmulationFilters
106 * @param {string} docDomain The IDN-decoded hostname of the document 106 * @param {string} docDomain The hostname of the document
107 */ 107 */
108 function logHiddenElements(tabId, selectors, filters, docDomain) 108 function logHiddenElements(tabId, selectors, filters, docDomain)
109 { 109 {
110 if (HitLogger.hasListener(tabId)) 110 if (HitLogger.hasListener(tabId))
111 { 111 {
112 for (let subscription of FilterStorage.subscriptions) 112 for (let subscription of FilterStorage.subscriptions)
113 { 113 {
114 if (subscription.disabled) 114 if (subscription.disabled)
115 continue; 115 continue;
116 116
(...skipping 15 matching lines...) Expand all
132 } 132 }
133 133
134 /** 134 /**
135 * Logs a whitelisting filter that disables (some kind of) 135 * Logs a whitelisting filter that disables (some kind of)
136 * blocking for a particular document. 136 * blocking for a particular document.
137 * 137 *
138 * @param {number} tabId The tabId the whitelisting is active for 138 * @param {number} tabId The tabId the whitelisting is active for
139 * @param {string} url The url of the whitelisted document 139 * @param {string} url The url of the whitelisted document
140 * @param {number} typeMask The bit mask of whitelisting types checked 140 * @param {number} typeMask The bit mask of whitelisting types checked
141 * for 141 * for
142 * @param {string} docDomain The IDN-decoded hostname of the parent 142 * @param {string} docDomain The hostname of the parent document
143 * document
144 * @param {WhitelistFilter} filter The matched whitelisting filter 143 * @param {WhitelistFilter} filter The matched whitelisting filter
145 */ 144 */
146 exports.logWhitelistedDocument = (tabId, url, typeMask, docDomain, filter) => 145 exports.logWhitelistedDocument = (tabId, url, typeMask, docDomain, filter) =>
147 { 146 {
148 if (HitLogger.hasListener(tabId)) 147 if (HitLogger.hasListener(tabId))
149 { 148 {
150 for (let type of nonRequestTypes) 149 for (let type of nonRequestTypes)
151 { 150 {
152 if (typeMask & filter.contentType & RegExpFilter.typeMap[type]) 151 if (typeMask & filter.contentType & RegExpFilter.typeMap[type])
153 eventEmitter.emit(tabId, {url, type, docDomain}, filter); 152 eventEmitter.emit(tabId, {url, type, docDomain}, filter);
154 } 153 }
155 } 154 }
156 }; 155 };
157 156
158 port.on("hitLogger.traceElemHide", (message, sender) => 157 port.on("hitLogger.traceElemHide", (message, sender) =>
159 { 158 {
160 logHiddenElements( 159 logHiddenElements(
161 sender.page.id, message.selectors, message.filters, 160 sender.page.id, message.selectors, message.filters,
162 extractHostFromFrame(sender.frame) 161 extractHostFromFrame(sender.frame)
163 ); 162 );
164 }); 163 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld