Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 return {}; | 58 return {}; |
59 | 59 |
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 var isFrame = (type == "main_frame" || type == "sub_frame"); | 68 if (type == "main_frame" || type == "sub_frame") |
69 if (!(details.tabId in frames && details.frameId in frames[details.tabId])) | 69 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl); |
70 recordFrame(details.tabId, details.frameId, details.parentFrameId, isFrame ? details.url : null); | 70 else if (details.tabId in frames && !(details.frameId in frames[details.tabId] )) |
Wladimir Palant
2013/11/06 15:23:14
Frame URLs can change - a different URL can load i
| |
71 recordFrame(details.tabId, details.frameId, details.parentFrameId, null); | |
71 | 72 |
72 if (type == "main_frame") | 73 if (type == "main_frame") |
73 return {}; | 74 return {}; |
74 | 75 |
75 // 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. |
76 if (type == "sub_frame") | 77 if (type == "sub_frame") |
77 type = "SUBDOCUMENT"; | 78 type = "SUBDOCUMENT"; |
78 else | 79 else |
79 type = type.toUpperCase(); | 80 type = type.toUpperCase(); |
80 | 81 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 ]; | 142 ]; |
142 if (verifySignature(key, signature, params.join("\0"))) | 143 if (verifySignature(key, signature, params.join("\0"))) |
143 frames[details.tabId][details.frameId].keyException = true; | 144 frames[details.tabId][details.frameId].keyException = true; |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
147 function recordFrame(tabId, frameId, parentFrameId, frameUrl) | 148 function recordFrame(tabId, frameId, parentFrameId, frameUrl) |
148 { | 149 { |
149 if (!(tabId in frames)) | 150 if (!(tabId in frames)) |
150 frames[tabId] = {}; | 151 frames[tabId] = {}; |
151 else if (!(frameId in frames[tabId])) | 152 |
152 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId}; | 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 | |
161 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId}; | |
153 } | 162 } |
154 | 163 |
155 function getFrameData(tabId, frameId) | 164 function getFrameData(tabId, frameId) |
156 { | 165 { |
157 if (tabId in frames && frameId in frames[tabId]) | 166 if (tabId in frames && frameId in frames[tabId]) |
158 return frames[tabId][frameId]; | 167 return frames[tabId][frameId]; |
159 else if (frameId > 0 && tabId in frames && 0 in frames[tabId]) | 168 else if (frameId > 0 && tabId in frames && 0 in frames[tabId]) |
160 { | 169 { |
161 // 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 |
162 return frames[tabId][0]; | 171 return frames[tabId][0]; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 parent = frameData.parent; | 211 parent = frameData.parent; |
203 parentData = getFrameData(tabId, parent); | 212 parentData = getFrameData(tabId, parent); |
204 | 213 |
205 var frameUrl = frameData.url; | 214 var frameUrl = frameData.url; |
206 var parentUrl = (parentData ? parentData.url : frameUrl); | 215 var parentUrl = (parentData ? parentData.url : frameUrl); |
207 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) | 216 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) |
208 return true; | 217 return true; |
209 } | 218 } |
210 return false; | 219 return false; |
211 } | 220 } |
LEFT | RIGHT |