Left: | ||
Right: |
OLD | NEW |
---|---|
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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 if (!frames) | 116 if (!frames) |
117 frames = framesOfTabs[tabId] = Object.create(null); | 117 frames = framesOfTabs[tabId] = Object.create(null); |
118 | 118 |
119 var frame = frames[frameId]; | 119 var frame = frames[frameId]; |
120 if (!frame) | 120 if (!frame) |
121 frame = frames[frameId] = {}; | 121 frame = frames[frameId] = {}; |
122 | 122 |
123 return frame; | 123 return frame; |
124 } | 124 } |
125 | 125 |
126 chrome.webNavigation.onBeforeNavigate.addListener(function(details) | |
127 { | |
128 // Capture parent frame here because onCommitted doesn't get this info. | |
129 var frame = createFrame(details.tabId, details.frameId); | |
130 frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; | |
131 }); | |
132 | |
133 var eagerlyUpdatedPages = new ext.PageMap(); | 126 var eagerlyUpdatedPages = new ext.PageMap(); |
134 | 127 |
135 ext._updatePageFrameStructure = function(frameId, tabId, url, eager) | 128 ext._updatePageFrameStructure = function(frameId, tabId, url, eager) |
136 { | 129 { |
137 if (frameId == 0) | 130 if (frameId == 0) |
138 { | 131 { |
139 let page = new Page({id: tabId, url: url}); | 132 let page = new Page({id: tabId, url: url}); |
140 | 133 |
141 if (eagerlyUpdatedPages.get(page) != url) | 134 if (eagerlyUpdatedPages.get(page) != url) |
142 { | 135 { |
(...skipping 18 matching lines...) Expand all Loading... | |
161 ext.pages.onLoading._dispatch(page); | 154 ext.pages.onLoading._dispatch(page); |
162 }); | 155 }); |
163 } | 156 } |
164 } | 157 } |
165 | 158 |
166 // Update frame URL in frame structure | 159 // Update frame URL in frame structure |
167 var frame = createFrame(tabId, frameId); | 160 var frame = createFrame(tabId, frameId); |
168 frame.url = new URL(url); | 161 frame.url = new URL(url); |
169 }; | 162 }; |
170 | 163 |
164 chrome.webNavigation.onBeforeNavigate.addListener(function(details) | |
165 { | |
166 // Capture parent frame here because onCommitted doesn't get this info. | |
167 var frame = createFrame(details.tabId, details.frameId); | |
168 frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; | |
169 | |
170 // Chrome will sometimes perform requests for pre-rendered pages before | |
171 // navigation was confirmed and the onComitted event was fired. Those | |
172 // requests will often wrongly be considered to be third party, since we | |
173 // don't know the correct document domain for requests until after we've | |
174 // updated the page structure. As a work around we update the page | |
175 // structure eagerly for new tabs (which includes pre-rendered pages). | |
176 if (!(details.tabId in framesOfTabs)) | |
Wladimir Palant
2016/11/14 15:56:29
While this is probably not wrong, I think that you
kzar
2016/11/15 12:19:28
Well so far the issue only described a problem wit
| |
177 ext._updatePageFrameStructure(details.frameId, details.tabId, details.url) ; | |
178 }); | |
179 | |
171 chrome.webNavigation.onCommitted.addListener(function(details) | 180 chrome.webNavigation.onCommitted.addListener(function(details) |
172 { | 181 { |
173 ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); | 182 ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); |
174 }); | 183 }); |
175 | 184 |
176 function forgetTab(tabId) | 185 function forgetTab(tabId) |
177 { | 186 { |
178 ext.pages.onRemoved._dispatch(tabId); | 187 ext.pages.onRemoved._dispatch(tabId); |
179 | 188 |
180 ext._removeFromAllPageMaps(tabId); | 189 ext._removeFromAllPageMaps(tabId); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 ext.windows = { | 648 ext.windows = { |
640 create: function(createData, callback) | 649 create: function(createData, callback) |
641 { | 650 { |
642 chrome.windows.create(createData, function(createdWindow) | 651 chrome.windows.create(createData, function(createdWindow) |
643 { | 652 { |
644 afterTabLoaded(callback)(createdWindow.tabs[0]); | 653 afterTabLoaded(callback)(createdWindow.tabs[0]); |
645 }); | 654 }); |
646 } | 655 } |
647 }; | 656 }; |
648 })(); | 657 })(); |
OLD | NEW |