Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 }; | 105 }; |
106 | 106 |
107 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) | 107 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
108 { | 108 { |
109 if (changeInfo.status == "loading") | 109 if (changeInfo.status == "loading") |
110 ext.pages.onLoading._dispatch(new Page(tab)); | 110 ext.pages.onLoading._dispatch(new Page(tab)); |
111 }); | 111 }); |
112 | 112 |
113 function createFrame(tabId, frameId) | 113 function createFrame(tabId, frameId) |
114 { | 114 { |
115 var frames = framesOfTabs[details.tabId]; | 115 var frames = framesOfTabs[tabId]; |
kzar
2016/09/01 11:06:48
It should be `tabId` and `frameId` rather than `de
Wladimir Palant
2016/09/05 15:48:25
Ouch, not sure how I missed that in the testing. F
| |
116 if (!frames) | 116 if (!frames) |
117 frames = framesOfTabs[details.tabId] = Object.create(null); | 117 frames = framesOfTabs[tabId] = Object.create(null); |
118 | 118 |
119 var frame = frames[details.frameId]; | 119 var frame = frames[frameId]; |
120 if (!frame) | 120 if (!frame) |
121 frame = frames[details.frameId] = {}; | 121 frame = frames[frameId] = {}; |
kzar
2016/08/31 16:06:39
Nit: Seems inconsistent to do `Object.create(null)
Wladimir Palant
2016/08/31 19:13:44
Yes, seems inconsistent but other than the frames
kzar
2016/09/01 11:06:48
Acknowledged.
| |
122 | 122 |
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 = frames[details.parentFrameId] || null; | 130 frame.parent = framesOfTabs[details.tabId][details.parentFrameId] || null; |
kzar
2016/08/31 16:06:39
Since both times we use createFrame we just want t
Wladimir Palant
2016/08/31 19:13:44
Frankly, I think that this would specialize the fu
kzar
2016/09/01 11:06:48
Acknowledged.
kzar
2016/09/01 12:46:15
We don't assign the frame's URL here in case the n
kzar
2016/09/01 13:22:57
OK it turns out both onCommitted and onBeforeNavig
kzar
2016/09/01 13:39:13
I have something working now, I hope you don't min
| |
131 }); | 131 }); |
132 | 132 |
133 chrome.webNavigation.onCommitted.addListener(function(details) | 133 chrome.webNavigation.onCommitted.addListener(function(details) |
134 { | 134 { |
135 if (details.frameId == 0) | 135 if (details.frameId == 0) |
136 { | 136 { |
137 ext._removeFromAllPageMaps(details.tabId); | 137 ext._removeFromAllPageMaps(details.tabId); |
138 | 138 |
139 chrome.tabs.get(details.tabId, function() | 139 chrome.tabs.get(details.tabId, function() |
140 { | 140 { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 ext.windows = { | 636 ext.windows = { |
637 create: function(createData, callback) | 637 create: function(createData, callback) |
638 { | 638 { |
639 chrome.windows.create(createData, function(createdWindow) | 639 chrome.windows.create(createData, function(createdWindow) |
640 { | 640 { |
641 afterTabLoaded(callback)(createdWindow.tabs[0]); | 641 afterTabLoaded(callback)(createdWindow.tabs[0]); |
642 }); | 642 }); |
643 } | 643 } |
644 }; | 644 }; |
645 })(); | 645 })(); |
LEFT | RIGHT |