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

Side by Side Diff: lib/whitelisting.js

Issue 5464830253203456: Refactored the abstraction layer to address prerendered pages on Safari caused by leaky abstraction (Closed)
Patch Set: Addressed comments Created April 11, 2014, 2:47 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 | « lib/stats.js ('k') | metadata.chrome » ('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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 let {defaultMatcher} = require("matcher"); 18 let {defaultMatcher} = require("matcher");
19 let {WhitelistFilter} = require("filterClasses"); 19 let {WhitelistFilter} = require("filterClasses");
20 20
21 let tabsWithKeyException = new TabMap(true); 21 let pagesWithKeyException = new ext.PageMap();
22 22
23 let isWhitelisted = exports.isWhitelisted = function(url, parentUrl, type) 23 let isWhitelisted = exports.isWhitelisted = function(url, parentUrl, type)
24 { 24 {
25 let filter = defaultMatcher.matchesAny( 25 let filter = defaultMatcher.matchesAny(
26 stripFragmentFromURL(url), 26 stripFragmentFromURL(url),
27 type || "DOCUMENT", 27 type || "DOCUMENT",
28 extractHostFromURL(parentUrl || url), 28 extractHostFromURL(parentUrl || url),
29 false 29 false
30 ); 30 );
31 31
32 return (filter instanceof WhitelistFilter ? filter : null); 32 return (filter instanceof WhitelistFilter ? filter : null);
33 }; 33 };
34 34
35 let isFrameWhitelisted = exports.isFrameWhitelisted = function(tab, frame, type) 35 let isFrameWhitelisted = exports.isFrameWhitelisted = function(page, frame, type )
36 { 36 {
37 let urlsWithKeyException = tabsWithKeyException.get(tab); 37 let urlsWithKeyException = pagesWithKeyException.get(page);
38 38
39 for (; frame != null; frame = frame.parent) 39 for (; frame != null; frame = frame.parent)
40 { 40 {
41 if (urlsWithKeyException && stripFragmentFromURL(frame.url) in urlsWithKeyEx ception) 41 if (urlsWithKeyException && stripFragmentFromURL(frame.url) in urlsWithKeyEx ception)
42 return true; 42 return true;
43 if (isWhitelisted(frame.url, (frame.parent || {}).url, type)) 43 if (isWhitelisted(frame.url, (frame.parent || {}).url, type))
44 return true; 44 return true;
45 } 45 }
46 46
47 return false; 47 return false;
(...skipping 14 matching lines...) Expand all
62 uri.path, // REQUEST_URI 62 uri.path, // REQUEST_URI
63 uri.asciiHost + (uri.port != -1 ? ":" + uri.port : ""), // HTTP_HOST 63 uri.asciiHost + (uri.port != -1 ? ":" + uri.port : ""), // HTTP_HOST
64 window.navigator.userAgent // HTTP_USER_AGENT 64 window.navigator.userAgent // HTTP_USER_AGENT
65 ]; 65 ];
66 66
67 let key = match[1]; 67 let key = match[1];
68 let signature = match[3]; 68 let signature = match[3];
69 return verifySignature(key, signature, params.join("\0")); 69 return verifySignature(key, signature, params.join("\0"));
70 }; 70 };
71 71
72 let recordKeyException = function(tab, url) 72 let recordKeyException = function(page, url)
73 { 73 {
74 let urlsWithKeyException = tabsWithKeyException.get(tab); 74 let urlsWithKeyException = pagesWithKeyException.get(page);
75 75
76 if (!urlsWithKeyException) 76 if (!urlsWithKeyException)
77 { 77 {
78 urlsWithKeyException = {__proto__: null}; 78 urlsWithKeyException = {__proto__: null};
79 tabsWithKeyException.set(tab, urlsWithKeyException); 79 pagesWithKeyException.set(page, urlsWithKeyException);
80 } 80 }
81 81
82 urlsWithKeyException[url] = null; 82 urlsWithKeyException[url] = null;
83 }; 83 };
84 84
85 let processKeyException = exports.processKeyException = function(token, tab, fra me) 85 let processKeyException = exports.processKeyException = function(token, page, fr ame)
86 { 86 {
87 let url = stripFragmentFromURL(frame.url); 87 let url = stripFragmentFromURL(frame.url);
88 let docDomain = extractHostFromURL((frame.parent || frame).url); 88 let docDomain = extractHostFromURL((frame.parent || frame).url);
89 89
90 if (verifyKeyException(token, url, docDomain)) 90 if (verifyKeyException(token, url, docDomain))
91 recordKeyException(tab, url); 91 recordKeyException(page, url);
92 }; 92 };
OLDNEW
« no previous file with comments | « lib/stats.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld