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

Side by Side Diff: popupBlocker.js

Issue 5138680696012800: Issue 616 - Enforce $generichide and $genericblock in Chrome (Closed)
Patch Set: Consider $genericblock when blocking popups. Created March 12, 2015, 7:18 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 | « background.js ('k') | webrequest.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-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 tabsLoading[details.tabId] = documentHost; 34 var frame = sourceFrame;
35 checkPotentialPopup(details.tabId, details.url, documentHost); 35 var specificOnly = false;
36 while (frame && !specificOnly)
37 {
38 specificOnly = isFrameWhitelisted(sourcePage, frame, "GENERICBLOCK");
39 frame = frame.parent;
40 }
41
42 tabsLoading[details.tabId] = {
43 documentHost: documentHost,
44 specificOnly: specificOnly
45 };
46 checkPotentialPopup(details.tabId, details.url, specificOnly, documentHost);
36 }); 47 });
37 48
38 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) 49 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
39 { 50 {
40 if (!(tabId in tabsLoading)) 51 if (!(tabId in tabsLoading))
41 { 52 {
42 // Not a pop-up we've previously seen 53 // Not a pop-up we've previously seen
43 return; 54 return;
44 } 55 }
45 56
46 if ("url" in changeInfo) 57 if ("url" in changeInfo)
47 checkPotentialPopup(tabId, tab.url, tabsLoading[tabId]); 58 {
59 var source = tabsLoading[tabId];
60 checkPotentialPopup(tabId, tab.url, source.specificOnly, source.documentHo st);
61 }
48 62
49 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") 63 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank")
50 delete tabsLoading[tabId]; 64 delete tabsLoading[tabId];
51 }); 65 });
52 } 66 }
53 67
54 function checkPotentialPopup(tabId, url, documentHost) 68 function checkPotentialPopup(tabId, url, specificOnly, documentHost)
55 { 69 {
56 url = new URL(url || "about:blank"); 70 url = new URL(url || "about:blank");
57 71
58 var filter = defaultMatcher.matchesAny( 72 var filter = defaultMatcher.matchesAny(
59 stringifyURL(url), "POPUP", 73 stringifyURL(url), "POPUP",
60 documentHost, isThirdParty(url, documentHost) 74 documentHost, isThirdParty(url, documentHost),
75 undefined, specificOnly
61 ); 76 );
62 77
63 if (filter instanceof BlockingFilter) 78 if (filter instanceof BlockingFilter)
64 chrome.tabs.remove(tabId); 79 chrome.tabs.remove(tabId);
65 } 80 }
OLDNEW
« no previous file with comments | « background.js ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld