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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 { | 95 { |
96 callback(tabs.map(function(tab) | 96 callback(tabs.map(function(tab) |
97 { | 97 { |
98 return new Page(tab); | 98 return new Page(tab); |
99 })); | 99 })); |
100 }); | 100 }); |
101 }, | 101 }, |
102 onLoading: new ext._EventTarget() | 102 onLoading: new ext._EventTarget() |
103 }; | 103 }; |
104 | 104 |
| 105 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
| 106 { |
| 107 if (changeInfo.status == "loading") |
| 108 ext.pages.onLoading._dispatch(new Page(tab)); |
| 109 }); |
| 110 |
| 111 chrome.webNavigation.onBeforeNavigate.addListener(function(details) |
| 112 { |
| 113 if (details.frameId == 0) |
| 114 { |
| 115 ext._removeFromAllPageMaps(details.tabId); |
| 116 |
| 117 chrome.tabs.get(details.tabId, function() |
| 118 { |
| 119 // If the tab is prerendered, chrome.tabs.get() sets |
| 120 // chrome.runtime.lastError and we have to dispatch the onLoading event, |
| 121 // since the onUpdated event isn't dispatched for prerendered tabs. |
| 122 // However, we have to keep relying on the unUpdated event for tabs that |
| 123 // are already visible. Otherwise browser action changes get overridden |
| 124 // when Chrome automatically resets them on navigation. |
| 125 if (chrome.runtime.lastError) |
| 126 { |
| 127 ext.pages.onLoading._dispatch( |
| 128 new Page({ |
| 129 id: details.tabId, |
| 130 url: details.url |
| 131 }) |
| 132 ); |
| 133 } |
| 134 }); |
| 135 } |
| 136 }); |
| 137 |
105 function forgetTab(tabId) | 138 function forgetTab(tabId) |
106 { | 139 { |
107 ext._removeFromAllPageMaps(tabId); | 140 ext._removeFromAllPageMaps(tabId); |
108 delete framesOfTabs[tabId]; | 141 delete framesOfTabs[tabId]; |
109 } | 142 } |
110 | |
111 chrome.webNavigation.onBeforeNavigate.addListener(function(details) | |
112 { | |
113 if (details.frameId == 0) | |
114 { | |
115 forgetTab(tabId); | |
116 ext.pages.onLoading._dispatch(new Page(tab)); | |
117 } | |
118 }); | |
119 | 143 |
120 chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) | 144 chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) |
121 { | 145 { |
122 forgetTab(removedTabId); | 146 forgetTab(removedTabId); |
123 }); | 147 }); |
124 | 148 |
125 chrome.tabs.onRemoved.addListener(forgetTab); | 149 chrome.tabs.onRemoved.addListener(forgetTab); |
126 | 150 |
127 | 151 |
128 /* Browser actions */ | 152 /* Browser actions */ |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 callback(new Page(tab)); | 513 callback(new Page(tab)); |
490 } | 514 } |
491 else | 515 else |
492 { | 516 { |
493 ext.pages.open(optionsUrl, callback); | 517 ext.pages.open(optionsUrl, callback); |
494 } | 518 } |
495 }); | 519 }); |
496 }); | 520 }); |
497 }; | 521 }; |
498 })(); | 522 })(); |
LEFT | RIGHT |