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

Side by Side Diff: lib/popupBlocker.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Reduce inline eslint-disable comments Created Feb. 8, 2017, 7:27 a.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/notificationHelper.js ('k') | lib/prefs.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 popupBlocker */ 18 /** @module popupBlocker */
19 19
20 "use strict"; 20 "use strict";
21 21
22 const {defaultMatcher} = require("matcher"); 22 const {defaultMatcher} = require("matcher");
23 const {BlockingFilter} = require("filterClasses"); 23 const {BlockingFilter, RegExpFilter} = require("filterClasses");
24 const {stringifyURL, isThirdParty, extractHostFromFrame} = require("url"); 24 const {stringifyURL, isThirdParty, extractHostFromFrame} = require("url");
25 const {checkWhitelisted} = require("whitelisting"); 25 const {checkWhitelisted} = require("whitelisting");
26 const {logRequest} = require("devtools"); 26 const {logRequest} = require("devtools");
27 27
28 let loadingPopups = Object.create(null); 28 let loadingPopups = Object.create(null);
29 29
30 function hasLoadingPopups() 30 function hasLoadingPopups()
31 { 31 {
32 return Object.keys(loadingPopups).length > 0; 32 return Object.keys(loadingPopups).length > 0;
33 } 33 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 forgetPopup(details.tabId); 88 forgetPopup(details.tabId);
89 } 89 }
90 90
91 chrome.webNavigation.onCreatedNavigationTarget.addListener(details => 91 chrome.webNavigation.onCreatedNavigationTarget.addListener(details =>
92 { 92 {
93 if (!hasLoadingPopups()) 93 if (!hasLoadingPopups())
94 { 94 {
95 chrome.webRequest.onBeforeRequest.addListener( 95 chrome.webRequest.onBeforeRequest.addListener(
96 onBeforeRequest, 96 onBeforeRequest,
97 { 97 {
98 urls: ["<all_urls>"], 98 urls: ["<all_urls>"],
99 types: ["main_frame"] 99 types: ["main_frame"]
100 } 100 }
101 ); 101 );
102 102
103 chrome.webNavigation.onCompleted.addListener(onCompleted); 103 chrome.webNavigation.onCompleted.addListener(onCompleted);
104 chrome.tabs.onRemoved.addListener(forgetPopup); 104 chrome.tabs.onRemoved.addListener(forgetPopup);
105 } 105 }
106 106
107 let tabId = details.tabId; 107 let {tabId} = details;
108 let popup = loadingPopups[tabId] = { 108 let popup = loadingPopups[tabId] = {
109 url: details.url, 109 url: details.url,
110 sourcePage: new ext.Page({id: details.sourceTabId}), 110 sourcePage: new ext.Page({id: details.sourceTabId}),
111 sourceFrame: null 111 sourceFrame: null
112 }; 112 };
113 let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId); 113 let frame = ext.getFrame(details.sourceTabId, details.sourceFrameId);
114 114
115 if (checkWhitelisted(popup.sourcePage, frame)) 115 if (checkWhitelisted(popup.sourcePage, frame))
116 { 116 {
117 forgetPopup(tabId); 117 forgetPopup(tabId);
118 } 118 }
119 else 119 else
120 { 120 {
121 popup.sourceFrame = frame; 121 popup.sourceFrame = frame;
122 checkPotentialPopup(tabId, popup); 122 checkPotentialPopup(tabId, popup);
123 } 123 }
124 }); 124 });
OLDNEW
« no previous file with comments | « lib/notificationHelper.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld