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

Side by Side Diff: popupBlocker.js

Issue 9496013: Pop-up blocking functionality for Chrome (Closed)
Patch Set: Fixed wrong return statement Created March 4, 2013, 11:46 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 | « metadata.chrome ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of the Adblock Plus extension,
3 * Copyright (C) 2006-2012 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 var tabsLoading = {};
19
20 chrome.tabs.onCreated.addListener(function(tab)
21 {
22 if (!("openerTabId" in tab))
23 {
24 // This isn't a pop-up
25 return;
26 }
27
28 if (isFrameWhitelisted(tab.openerTabId, 0))
29 return;
30
31 var openerUrl = getFrameUrl(tab.openerTabId, 0);
32 if (!openerUrl)
33 {
34 // We don't know the opener tab
35 return;
36 }
37 tabsLoading[tab.id] = openerUrl;
38
39 checkPotentialPopup(tab, openerUrl);
40 });
41
42 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
43 {
44 if (!(tabId in tabsLoading))
45 {
46 // Not a pop-up we've previously seen
47 return;
48 }
49
50 if ("url" in changeInfo)
51 checkPotentialPopup(tab, tabsLoading[tabId]);
52
53 if ("status" in changeInfo && changeInfo.status == "complete")
54 delete tabsLoading[tabId];
55 });
56
57
58 function checkPotentialPopup(tab)
59 {
60 var requestHost = extractHostFromURL(tab.url);
61 var documentHost = extractHostFromURL(tabsLoading[tab.id]);
62 var thirdParty = isThirdParty(requestHost, documentHost);
63 var filter = defaultMatcher.matchesAny(tab.url || "about:blank", "POPUP", docu mentHost, thirdParty);
64 if (filter instanceof BlockingFilter)
65 chrome.tabs.remove(tab.id);
66 }
OLDNEW
« no previous file with comments | « metadata.chrome ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld