| OLD | NEW |
| 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 if (type == "main_frame" || type == "sub_frame") | 68 var isFrame = (type == "main_frame" || type == "sub_frame"); |
| 69 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u
rl); | 69 if (!(details.tabId in frames && details.frameId in frames[details.tabId])) |
| 70 recordFrame(details.tabId, details.frameId, details.parentFrameId, isFrame ?
details.url : null); |
| 70 | 71 |
| 71 if (type == "main_frame") | 72 if (type == "main_frame") |
| 72 return {}; | 73 return {}; |
| 73 | 74 |
| 74 // Type names match Mozilla's with main_frame and sub_frame being the only exc
eptions. | 75 // Type names match Mozilla's with main_frame and sub_frame being the only exc
eptions. |
| 75 if (type == "sub_frame") | 76 if (type == "sub_frame") |
| 76 type = "SUBDOCUMENT"; | 77 type = "SUBDOCUMENT"; |
| 77 else | 78 else |
| 78 type = type.toUpperCase(); | 79 type = type.toUpperCase(); |
| 79 | 80 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 ]; | 141 ]; |
| 141 if (verifySignature(key, signature, params.join("\0"))) | 142 if (verifySignature(key, signature, params.join("\0"))) |
| 142 frames[details.tabId][details.frameId].keyException = true; | 143 frames[details.tabId][details.frameId].keyException = true; |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 function recordFrame(tabId, frameId, parentFrameId, frameUrl) | 147 function recordFrame(tabId, frameId, parentFrameId, frameUrl) |
| 147 { | 148 { |
| 148 if (!(tabId in frames)) | 149 if (!(tabId in frames)) |
| 149 frames[tabId] = {}; | 150 frames[tabId] = {}; |
| 150 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId}; | 151 else if (!(frameId in frames[tabId])) |
| 152 frames[tabId][frameId] = {url: frameUrl, parent: parentFrameId}; |
| 151 } | 153 } |
| 152 | 154 |
| 153 function getFrameData(tabId, frameId) | 155 function getFrameData(tabId, frameId) |
| 154 { | 156 { |
| 155 if (tabId in frames && frameId in frames[tabId]) | 157 if (tabId in frames && frameId in frames[tabId]) |
| 156 return frames[tabId][frameId]; | 158 return frames[tabId][frameId]; |
| 157 else if (frameId > 0 && tabId in frames && 0 in frames[tabId]) | 159 else if (frameId > 0 && tabId in frames && 0 in frames[tabId]) |
| 158 { | 160 { |
| 159 // We don't know anything about javascript: or data: frames, use top frame | 161 // We don't know anything about javascript: or data: frames, use top frame |
| 160 return frames[tabId][0]; | 162 return frames[tabId][0]; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 parent = frameData.parent; | 202 parent = frameData.parent; |
| 201 parentData = getFrameData(tabId, parent); | 203 parentData = getFrameData(tabId, parent); |
| 202 | 204 |
| 203 var frameUrl = frameData.url; | 205 var frameUrl = frameData.url; |
| 204 var parentUrl = (parentData ? parentData.url : frameUrl); | 206 var parentUrl = (parentData ? parentData.url : frameUrl); |
| 205 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) | 207 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) |
| 206 return true; | 208 return true; |
| 207 } | 209 } |
| 208 return false; | 210 return false; |
| 209 } | 211 } |
| OLD | NEW |