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

Side by Side Diff: lib/cssInjection.js

Issue 29705719: Issue 6402 - Split filter hit / request logging out into own API (Closed)
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:
View unified diff | Download patch
« no previous file with comments | « lib/csp.js ('k') | lib/devtools.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 /** @module cssInjection */ 18 /** @module cssInjection */
19 19
20 "use strict"; 20 "use strict";
21 21
22 const {RegExpFilter} = require("../adblockpluscore/lib/filterClasses"); 22 const {RegExpFilter} = require("../adblockpluscore/lib/filterClasses");
23 const {ElemHide} = require("../adblockpluscore/lib/elemHide"); 23 const {ElemHide} = require("../adblockpluscore/lib/elemHide");
24 const {ElemHideEmulation} = require("../adblockpluscore/lib/elemHideEmulation"); 24 const {ElemHideEmulation} = require("../adblockpluscore/lib/elemHideEmulation");
25 const {checkWhitelisted} = require("./whitelisting"); 25 const {checkWhitelisted} = require("./whitelisting");
26 const {extractHostFromFrame} = require("./url"); 26 const {extractHostFromFrame} = require("./url");
27 const {port} = require("./messaging"); 27 const {port} = require("./messaging");
28 const devtools = require("./devtools"); 28 const {HitLogger} = require("./hitLogger");
29 const info = require("../buildtools/info"); 29 const info = require("../buildtools/info");
30 30
31 // Chromium's support for tabs.removeCSS is still a work in progress and the 31 // Chromium's support for tabs.removeCSS is still a work in progress and the
32 // API is likely to be different from Firefox's; for now we just don't use it 32 // API is likely to be different from Firefox's; for now we just don't use it
33 // at all, even if it's available. 33 // at all, even if it's available.
34 // See https://crbug.com/608854 34 // See https://crbug.com/608854
35 const styleSheetRemovalSupported = info.platform == "gecko"; 35 const styleSheetRemovalSupported = info.platform == "gecko";
36 36
37 const selectorGroupSize = 1024; 37 const selectorGroupSize = 1024;
38 38
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 removeStyleSheet(tabId, frameId, oldStyleSheet); 157 removeStyleSheet(tabId, frameId, oldStyleSheet);
158 158
159 frame.injectedStyleSheets.set(groupName, styleSheet); 159 frame.injectedStyleSheets.set(groupName, styleSheet);
160 return true; 160 return true;
161 } 161 }
162 162
163 port.on("elemhide.getSelectors", (message, sender) => 163 port.on("elemhide.getSelectors", (message, sender) =>
164 { 164 {
165 let selectors = []; 165 let selectors = [];
166 let emulatedPatterns = []; 166 let emulatedPatterns = [];
167 let trace = devtools.hasPanel(sender.page.id); 167 let trace = HitLogger.hasListener(sender.page.id);
168 let inline = !userStyleSheetsSupported; 168 let inline = !userStyleSheetsSupported;
169 169
170 if (!checkWhitelisted(sender.page, sender.frame, null, 170 if (!checkWhitelisted(sender.page, sender.frame, null,
171 RegExpFilter.typeMap.DOCUMENT | 171 RegExpFilter.typeMap.DOCUMENT |
172 RegExpFilter.typeMap.ELEMHIDE)) 172 RegExpFilter.typeMap.ELEMHIDE))
173 { 173 {
174 let hostname = extractHostFromFrame(sender.frame); 174 let hostname = extractHostFromFrame(sender.frame);
175 let specificOnly = checkWhitelisted(sender.page, sender.frame, null, 175 let specificOnly = checkWhitelisted(sender.page, sender.frame, null,
176 RegExpFilter.typeMap.GENERICHIDE); 176 RegExpFilter.typeMap.GENERICHIDE);
177 177
(...skipping 24 matching lines...) Expand all
202 response.inlineEmulated = true; 202 response.inlineEmulated = true;
203 203
204 return response; 204 return response;
205 }); 205 });
206 206
207 port.on("elemhide.injectSelectors", (message, sender) => 207 port.on("elemhide.injectSelectors", (message, sender) =>
208 { 208 {
209 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, 209 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors,
210 message.groupName, message.appendOnly); 210 message.groupName, message.appendOnly);
211 }); 211 });
OLDNEW
« no previous file with comments | « lib/csp.js ('k') | lib/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld