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

Side by Side Diff: webrequest.js

Issue 28067007: Construct frame hierarchy using first request originating from it (Closed)
Patch Set: Created Nov. 13, 2013, 11:48 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 | « 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 Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 var type = details.type; 60 var type = details.type;
61 61
62 // Assume that the first request belongs to the top frame. Chrome may give the 62 // Assume that the first request belongs to the top frame. Chrome may give the
63 // top frame the type "object" instead of "main_frame". 63 // top frame the type "object" instead of "main_frame".
64 // https://code.google.com/p/chromium/issues/detail?id=281711 64 // https://code.google.com/p/chromium/issues/detail?id=281711
65 if (details.frameId == 0 && !(details.tabId in frames) && type == "object") 65 if (details.frameId == 0 && !(details.tabId in frames) && type == "object")
66 type = "main_frame"; 66 type = "main_frame";
67 67
68 if (type == "main_frame" || type == "sub_frame") 68 if (type == "main_frame" || type == "sub_frame")
69 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl); 69 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl);
70 else if (details.tabId in frames && !(details.frameId in frames[details.tabId] ))
71 recordFrame(details.tabId, details.frameId, details.parentFrameId, null);
70 72
71 if (type == "main_frame") 73 if (type == "main_frame")
72 return {}; 74 return {};
73 75
74 // Type names match Mozilla's with main_frame and sub_frame being the only exc eptions. 76 // Type names match Mozilla's with main_frame and sub_frame being the only exc eptions.
75 if (type == "sub_frame") 77 if (type == "sub_frame")
76 type = "SUBDOCUMENT"; 78 type = "SUBDOCUMENT";
77 else 79 else
78 type = type.toUpperCase(); 80 type = type.toUpperCase();
79 81
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ]; 142 ];
141 if (verifySignature(key, signature, params.join("\0"))) 143 if (verifySignature(key, signature, params.join("\0")))
142 frames[details.tabId][details.frameId].keyException = true; 144 frames[details.tabId][details.frameId].keyException = true;
143 } 145 }
144 } 146 }
145 147
146 function recordFrame(tabId, frameId, parentFrameId, frameUrl) 148 function recordFrame(tabId, frameId, parentFrameId, frameUrl)
147 { 149 {
148 if (!(tabId in frames)) 150 if (!(tabId in frames))
149 frames[tabId] = {}; 151 frames[tabId] = {};
152
153 if (frameUrl == null)
154 {
155 if (tabId in frames && parentFrameId in frames[tabId])
Wladimir Palant 2013/11/13 12:03:03 No point for the |tabId in frames| part of the che
156 frameUrl = frames[tabId][parentFrameId].url;
157 else
158 return; // We cannot do anything meaningful here
159 }
160
150 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId}; 161 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId};
151 } 162 }
152 163
153 function getFrameData(tabId, frameId) 164 function getFrameData(tabId, frameId)
154 { 165 {
155 if (tabId in frames && frameId in frames[tabId]) 166 if (tabId in frames && frameId in frames[tabId])
156 return frames[tabId][frameId]; 167 return frames[tabId][frameId];
157 else if (frameId > 0 && tabId in frames && 0 in frames[tabId]) 168 else if (frameId > 0 && tabId in frames && 0 in frames[tabId])
158 { 169 {
159 // We don't know anything about javascript: or data: frames, use top frame 170 // We don't know anything about javascript: or data: frames, use top frame
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 parent = frameData.parent; 211 parent = frameData.parent;
201 parentData = getFrameData(tabId, parent); 212 parentData = getFrameData(tabId, parent);
202 213
203 var frameUrl = frameData.url; 214 var frameUrl = frameData.url;
204 var parentUrl = (parentData ? parentData.url : frameUrl); 215 var parentUrl = (parentData ? parentData.url : frameUrl);
205 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) 216 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type))
206 return true; 217 return true;
207 } 218 }
208 return false; 219 return false;
209 } 220 }
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