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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return frame; | 123 return frame; |
124 } | 124 } |
125 | 125 |
126 chrome.webNavigation.onBeforeNavigate.addListener(function(details) | 126 chrome.webNavigation.onBeforeNavigate.addListener(function(details) |
127 { | 127 { |
128 // Capture parent frame here because onCommitted doesn't get this info. | 128 // Capture parent frame here because onCommitted doesn't get this info. |
129 var frame = createFrame(details.tabId, details.frameId); | 129 var frame = createFrame(details.tabId, details.frameId); |
130 frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; | 130 frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; |
131 }); | 131 }); |
132 | 132 |
133 chrome.webNavigation.onCommitted.addListener(function(details) | 133 ext._updatePageFrameStructure = function(frameId, tabId, url) |
134 { | 134 { |
135 if (details.frameId == 0) | 135 if (frameId == 0) |
136 { | 136 { |
137 ext._removeFromAllPageMaps(details.tabId); | 137 ext._removeFromAllPageMaps(tabId); |
138 | 138 |
139 chrome.tabs.get(details.tabId, function() | 139 chrome.tabs.get(tabId, function() |
140 { | 140 { |
141 // If the tab is prerendered, chrome.tabs.get() sets | 141 // If the tab is prerendered, chrome.tabs.get() sets |
142 // chrome.runtime.lastError and we have to dispatch the onLoading event, | 142 // chrome.runtime.lastError and we have to dispatch the onLoading event, |
143 // since the onUpdated event isn't dispatched for prerendered tabs. | 143 // since the onUpdated event isn't dispatched for prerendered tabs. |
144 // However, we have to keep relying on the unUpdated event for tabs that | 144 // However, we have to keep relying on the unUpdated event for tabs that |
145 // are already visible. Otherwise browser action changes get overridden | 145 // are already visible. Otherwise browser action changes get overridden |
146 // when Chrome automatically resets them on navigation. | 146 // when Chrome automatically resets them on navigation. |
147 if (chrome.runtime.lastError) | 147 if (chrome.runtime.lastError) |
148 { | 148 { |
149 ext.pages.onLoading._dispatch( | 149 ext.pages.onLoading._dispatch( |
150 new Page({ | 150 new Page({ |
151 id: details.tabId, | 151 id: tabId, |
152 url: details.url | 152 url: url |
153 }) | 153 }) |
154 ); | 154 ); |
155 } | 155 } |
156 }); | 156 }); |
157 } | 157 } |
158 | 158 |
159 // Update frame URL in frame structure | 159 // Update frame URL in frame structure |
160 var frame = createFrame(details.tabId, details.frameId); | 160 var frame = createFrame(tabId, frameId); |
161 frame.url = new URL(details.url); | 161 frame.url = new URL(url); |
| 162 }; |
| 163 |
| 164 chrome.webNavigation.onCommitted.addListener(function(details) |
| 165 { |
| 166 ext._updatePageFrameStructure(details.frameId, details.tabId, details.url); |
162 }); | 167 }); |
163 | 168 |
164 function forgetTab(tabId) | 169 function forgetTab(tabId) |
165 { | 170 { |
166 ext.pages.onRemoved._dispatch(tabId); | 171 ext.pages.onRemoved._dispatch(tabId); |
167 | 172 |
168 ext._removeFromAllPageMaps(tabId); | 173 ext._removeFromAllPageMaps(tabId); |
169 delete framesOfTabs[tabId]; | 174 delete framesOfTabs[tabId]; |
170 } | 175 } |
171 | 176 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 ext.windows = { | 632 ext.windows = { |
628 create: function(createData, callback) | 633 create: function(createData, callback) |
629 { | 634 { |
630 chrome.windows.create(createData, function(createdWindow) | 635 chrome.windows.create(createData, function(createdWindow) |
631 { | 636 { |
632 afterTabLoaded(callback)(createdWindow.tabs[0]); | 637 afterTabLoaded(callback)(createdWindow.tabs[0]); |
633 }); | 638 }); |
634 } | 639 } |
635 }; | 640 }; |
636 })(); | 641 })(); |
OLD | NEW |