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

Delta Between Two Patch Sets: lib/whitelisting.js

Issue 6393086494113792: Issue 154 - Added devtools panel showing blocked and blockable items (Closed)
Left Patch Set: Use chrome.runtime.onConnect directly Created Feb. 2, 2016, 11:19 a.m.
Right Patch Set: Adapt for UI changes generating domain specific filters when necessary Created Feb. 3, 2016, 10:40 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 | « lib/filterComposer.js ('k') | metadata.chrome » ('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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return filter; 46 return filter;
47 } 47 }
48 48
49 /** 49 /**
50 * Gets the active whitelisting filter for the document associated 50 * Gets the active whitelisting filter for the document associated
51 * with the given page/frame, or null if it's not whitelisted. 51 * with the given page/frame, or null if it's not whitelisted.
52 * 52 *
53 * @param {Page} page 53 * @param {Page} page
54 * @param {Frame} [frame] 54 * @param {Frame} [frame]
55 * @param {number} [typeMask=RegExpFilter.typeMap.DOCUMENT] 55 * @param {number} [typeMask=RegExpFilter.typeMap.DOCUMENT]
56 * @return {WhitelistFilter?} 56 * @return {?WhitelistFilter}
57 */ 57 */
58 exports.checkWhitelisted = function(page, frame, typeMask) 58 exports.checkWhitelisted = function(page, frame, typeMask)
59 { 59 {
60 if (typeof typeMask == "undefined") 60 if (typeof typeMask == "undefined")
61 typeMask = RegExpFilter.typeMap.DOCUMENT; 61 typeMask = RegExpFilter.typeMap.DOCUMENT;
62 62
63 if (frame) 63 if (frame)
64 { 64 {
65 let filter = null; 65 let filter = null;
66 66
67 while (frame && !filter) 67 while (frame && !filter)
68 { 68 {
69 let parent = frame.parent; 69 let parent = frame.parent;
70 let docDomain = extractHostFromFrame(parent); 70 let docDomain = extractHostFromFrame(parent);
71 let sitekey = getKey(page, frame); 71 let sitekey = getKey(page, frame);
72 72
73 filter = match(page, frame.url, typeMask, docDomain, sitekey); 73 filter = match(page, frame.url, typeMask, docDomain, sitekey);
74 frame = parent; 74 frame = parent;
75 } 75 }
76 76
77 return filter; 77 return filter;
78 } 78 }
79 79
80 return match(page, page.url, typeMask); 80 return match(page, page.url, typeMask);
81 }; 81 };
82
83 // Compatibility with adblockplusui, to be removed when updating the dependency
84 exports.isFrameWhitelisted = exports.checkWhitelisted;
85 82
86 let getKey = 83 let getKey =
87 /** 84 /**
88 * Gets the public key, previously recorded for the given page 85 * Gets the public key, previously recorded for the given page
89 * and frame, to be considered for the $sitekey filter option. 86 * and frame, to be considered for the $sitekey filter option.
90 * 87 *
91 * @param {Page} page 88 * @param {Page} page
92 * @param {Frame} frame 89 * @param {Frame} frame
93 * @return {string} 90 * @return {string}
94 */ 91 */
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 { 144 {
148 if (token.indexOf("_") < 0) 145 if (token.indexOf("_") < 0)
149 return; 146 return;
150 147
151 let [key, signature] = token.split("_", 2); 148 let [key, signature] = token.split("_", 2);
152 key = key.replace(/=/g, ""); 149 key = key.replace(/=/g, "");
153 150
154 if (verifyKey(key, signature, frame.url)) 151 if (verifyKey(key, signature, frame.url))
155 recordKey(page, frame.url, key); 152 recordKey(page, frame.url, key);
156 }; 153 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld