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

Delta Between Two Patch Sets: popupBlocker.js

Issue 5138680696012800: Issue 616 - Enforce $generichide and $genericblock in Chrome (Closed)
Left Patch Set: Consider $genericblock when blocking popups. Created March 12, 2015, 7:18 p.m.
Right Patch Set: Updated adblockplustests dependency Created Oct. 5, 2015, 9:52 a.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 | « dependencies ('k') | webrequest.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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 13 matching lines...) Expand all
24 var sourcePage = new ext.Page({id: details.sourceTabId}); 24 var sourcePage = new ext.Page({id: details.sourceTabId});
25 var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId); 25 var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId);
26 26
27 if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame)) 27 if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame))
28 return; 28 return;
29 29
30 var documentHost = extractHostFromFrame(sourceFrame); 30 var documentHost = extractHostFromFrame(sourceFrame);
31 if (!documentHost) 31 if (!documentHost)
32 return; 32 return;
33 33
34 var frame = sourceFrame; 34 var specificOnly = isFrameWhitelisted(sourcePage, sourceFrame,
35 var specificOnly = false; 35 RegExpFilter.typeMap.GENERICBLOCK);
36 while (frame && !specificOnly)
37 {
38 specificOnly = isFrameWhitelisted(sourcePage, frame, "GENERICBLOCK");
39 frame = frame.parent;
40 }
41 36
42 tabsLoading[details.tabId] = { 37 tabsLoading[details.tabId] = {
43 documentHost: documentHost, 38 documentHost: documentHost,
44 specificOnly: specificOnly 39 specificOnly: specificOnly
45 }; 40 };
46 checkPotentialPopup(details.tabId, details.url, specificOnly, documentHost); 41 checkPotentialPopup(details.tabId, details.url, documentHost, specificOnly);
47 }); 42 });
48 43
49 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) 44 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
50 { 45 {
51 if (!(tabId in tabsLoading)) 46 if (!(tabId in tabsLoading))
52 { 47 {
53 // Not a pop-up we've previously seen 48 // Not a pop-up we've previously seen
54 return; 49 return;
55 } 50 }
56 51
57 if ("url" in changeInfo) 52 if ("url" in changeInfo)
58 { 53 {
59 var source = tabsLoading[tabId]; 54 var source = tabsLoading[tabId];
60 checkPotentialPopup(tabId, tab.url, source.specificOnly, source.documentHo st); 55 checkPotentialPopup(tabId, tab.url, source.documentHost,
56 source.specificOnly);
61 } 57 }
62 58
63 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") 59 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank")
64 delete tabsLoading[tabId]; 60 delete tabsLoading[tabId];
65 }); 61 });
66 } 62 }
67 63
68 function checkPotentialPopup(tabId, url, specificOnly, documentHost) 64 function checkPotentialPopup(tabId, url, documentHost, specificOnly)
69 { 65 {
70 url = new URL(url || "about:blank"); 66 url = new URL(url || "about:blank");
71 67
72 var filter = defaultMatcher.matchesAny( 68 var filter = defaultMatcher.matchesAny(
73 stringifyURL(url), "POPUP", 69 stringifyURL(url), RegExpFilter.typeMap.POPUP,
74 documentHost, isThirdParty(url, documentHost), 70 documentHost, isThirdParty(url, documentHost),
75 undefined, specificOnly 71 null, specificOnly
76 ); 72 );
77 73
78 if (filter instanceof BlockingFilter) 74 if (filter instanceof BlockingFilter)
79 chrome.tabs.remove(tabId); 75 chrome.tabs.remove(tabId);
80 } 76 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld