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: Removed redundant logic in popup blocking changes. Created March 12, 2015, 7:45 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 specificOnly = isFrameWhitelisted(sourcePage, sourceFrame, "GENERICBLOCK ");
35 checkPotentialPopup(details.tabId, details.url, documentHost); 35
36 tabsLoading[details.tabId] = {
37 documentHost: documentHost,
38 specificOnly: specificOnly
39 };
40 checkPotentialPopup(details.tabId, details.url, specificOnly, documentHost);
36 }); 41 });
37 42
38 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) 43 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
39 { 44 {
40 if (!(tabId in tabsLoading)) 45 if (!(tabId in tabsLoading))
41 { 46 {
42 // Not a pop-up we've previously seen 47 // Not a pop-up we've previously seen
43 return; 48 return;
44 } 49 }
45 50
46 if ("url" in changeInfo) 51 if ("url" in changeInfo)
47 checkPotentialPopup(tabId, tab.url, tabsLoading[tabId]); 52 {
53 var source = tabsLoading[tabId];
54 checkPotentialPopup(tabId, tab.url, source.specificOnly, source.documentHo st);
55 }
48 56
49 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") 57 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank")
50 delete tabsLoading[tabId]; 58 delete tabsLoading[tabId];
51 }); 59 });
52 } 60 }
53 61
54 function checkPotentialPopup(tabId, url, documentHost) 62 function checkPotentialPopup(tabId, url, specificOnly, documentHost)
Sebastian Noack 2015/03/12 19:59:36 Nit: I'd put the documentHost first to match the s
kzar 2015/03/12 20:42:12 Done.
55 { 63 {
56 url = new URL(url || "about:blank"); 64 url = new URL(url || "about:blank");
57 65
58 var filter = defaultMatcher.matchesAny( 66 var filter = defaultMatcher.matchesAny(
59 stringifyURL(url), "POPUP", 67 stringifyURL(url), "POPUP",
60 documentHost, isThirdParty(url, documentHost) 68 documentHost, isThirdParty(url, documentHost),
69 undefined, specificOnly
Sebastian Noack 2015/03/12 19:59:36 Nit: Please null instead undefined.
kzar 2015/03/12 20:42:12 Done.
61 ); 70 );
62 71
63 if (filter instanceof BlockingFilter) 72 if (filter instanceof BlockingFilter)
64 chrome.tabs.remove(tabId); 73 chrome.tabs.remove(tabId);
65 } 74 }
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