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

Side by Side Diff: webrequest.js

Issue 8699074: Fixed: Requests by javascript: or data: frames aren`t being blocked (Closed)
Patch Set: Created Oct. 29, 2012, 12:44 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 | « no previous file | 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
1 /* 1 /*
2 * This file is part of the Adblock Plus extension, 2 * This file is part of the Adblock Plus extension,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 } 121 }
122 122
123 function recordFrame(tabId, frameId, parentFrameId, frameUrl) 123 function recordFrame(tabId, frameId, parentFrameId, frameUrl)
124 { 124 {
125 if (!(tabId in frames)) 125 if (!(tabId in frames))
126 frames[tabId] = {}; 126 frames[tabId] = {};
127 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId}; 127 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId};
128 } 128 }
129 129
130 function getFrameUrl(tabId, frameId) 130 function getFrameData(tabId, frameId)
131 { 131 {
132 if (tabId in frames && frameId in frames[tabId]) 132 if (tabId in frames && frameId in frames[tabId])
133 return frames[tabId][frameId].url; 133 return frames[tabId][frameId];
134 else if (frameId > 0 && tabId in frames && 0 in frames[tabId])
135 {
136 // We don't know anything about javascript: or data: frames, use top frame
137 return frames[tabId][0];
138 }
134 return null; 139 return null;
135 } 140 }
136 141
137 function getFrameParent(tabId, frameId) 142 function getFrameUrl(tabId, frameId)
138 { 143 {
139 if (tabId in frames && frameId in frames[tabId]) 144 var frameData = getFrameData(tabId, frameId);
140 return frames[tabId][frameId].parent; 145 return (frameData ? frameData.url : null);
141 return -1;
142 } 146 }
143 147
144 function forgetTab(tabId) 148 function forgetTab(tabId)
145 { 149 {
146 delete frames[tabId]; 150 delete frames[tabId];
147 } 151 }
148 152
149 function checkRequest(type, tabId, url, frameId) 153 function checkRequest(type, tabId, url, frameId)
150 { 154 {
151 if (isFrameWhitelisted(tabId, frameId)) 155 if (isFrameWhitelisted(tabId, frameId))
(...skipping 25 matching lines...) Expand all
177 } 181 }
178 182
179 return filter; 183 return filter;
180 } 184 }
181 185
182 function isFrameWhitelisted(tabId, frameId, type) 186 function isFrameWhitelisted(tabId, frameId, type)
183 { 187 {
184 var parent = frameId; 188 var parent = frameId;
185 while (parent != -1) 189 while (parent != -1)
186 { 190 {
187 var parentUrl = getFrameUrl(tabId, parent); 191 var parentData = getFrameData(tabId, parent);
188 if (parentUrl && isWhitelisted(parentUrl, type)) 192 if (!parentData)
193 break;
194
195 if (isWhitelisted(parentData.url, type) || "keyException" in parentData)
189 return true; 196 return true;
190 if (parentUrl && "keyException" in frames[tabId][frameId]) 197 parent = parentData.parent;
191 return true;
192 parent = getFrameParent(tabId, parent);
193 } 198 }
194 return false; 199 return false;
195 } 200 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld