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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 } | 147 } |
148 }; | 148 }; |
149 | 149 |
150 safari.application.addEventListener("activate", function(event) | 150 safari.application.addEventListener("activate", function(event) |
151 { | 151 { |
152 // this event is also dispatched on windows that got focused. But we | 152 // this event is also dispatched on windows that got focused. But we |
153 // are only interested in tabs, which became active in their window. | 153 // are only interested in tabs, which became active in their window. |
154 if (!(event.target instanceof SafariBrowserTab)) | 154 if (!(event.target instanceof SafariBrowserTab)) |
155 return; | 155 return; |
156 | 156 |
157 var activeTab = event.target.browserWindow.activeTab; | |
158 var pageId = addPage(activeTab, activeTab.url, false); | |
Sebastian Noack
2016/01/26 16:12:38
Add page registers a new page (in our data structu
kzar
2016/01/26 22:59:30
Acknowledged.
| |
159 ext.pages.onActivated._dispatch(pages[pageId]); | |
160 | |
157 // update the toolbar item for the page visible in the tab that just | 161 // update the toolbar item for the page visible in the tab that just |
158 // became active. If we can't find that page (e.g. when a page was | 162 // became active. If we can't find that page (e.g. when a page was |
159 // opened in a new tab, and our content script didn't run yet), the | 163 // opened in a new tab, and our content script didn't run yet), the |
160 // toolbar item of the window, is reset to its intial configuration. | 164 // toolbar item of the window, is reset to its intial configuration. |
161 updateToolbarItemForPage(event.target._visiblePage, event.target.browserWind ow); | 165 updateToolbarItemForPage(event.target._visiblePage, event.target.browserWind ow); |
162 }, true); | 166 }, true); |
163 | 167 |
164 | 168 |
165 /* Pages */ | 169 /* Pages */ |
166 | 170 |
167 var pages = Object.create(null); | 171 var pages = Object.create(null); |
168 var pageCounter = 0; | 172 var pageCounter = 0; |
169 | 173 |
170 var Page = function(id, tab, url) | 174 var Page = function(id, tab, url) |
171 { | 175 { |
172 this._id = id; | 176 this._id = id; |
173 this._tab = tab; | 177 this._tab = tab; |
174 this._frames = [{url: new URL(url), parent: null}]; | 178 this._frames = [{url: new URL(url || "about:blank"), parent: null}]; |
Sebastian Noack
2016/01/26 16:12:37
This change seems to be unrelated.
Sebastian Noack
2016/01/26 22:44:50
It seems that you forgot to reply here. At least t
kzar
2016/01/26 22:59:30
Whoops, you're right. Somehow in the past I was se
| |
175 | 179 |
176 if (tab.page) | 180 if (tab.page) |
177 this._messageProxy = new ext._MessageProxy(tab.page); | 181 this._messageProxy = new ext._MessageProxy(tab.page); |
178 else | 182 else |
179 // while the new tab page is shown on Safari 7, the 'page' property | 183 // while the new tab page is shown on Safari 7, the 'page' property |
180 // of the tab is undefined, and we can't send messages to that page | 184 // of the tab is undefined, and we can't send messages to that page |
181 this._messageProxy = { | 185 this._messageProxy = { |
182 handleRequest: function() {}, | 186 handleRequest: function() {}, |
183 handleResponse: function() {}, | 187 handleResponse: function() {}, |
184 sendMessage: function() {} | 188 sendMessage: function() {} |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 if ("active" in info && info.active != isPageActive(page)) | 290 if ("active" in info && info.active != isPageActive(page)) |
287 continue; | 291 continue; |
288 if ("lastFocusedWindow" in info && info.lastFocusedWindow != (win == saf ari.application.activeBrowserWindow)) | 292 if ("lastFocusedWindow" in info && info.lastFocusedWindow != (win == saf ari.application.activeBrowserWindow)) |
289 continue; | 293 continue; |
290 | 294 |
291 matchedPages.push(page); | 295 matchedPages.push(page); |
292 }; | 296 }; |
293 | 297 |
294 callback(matchedPages); | 298 callback(matchedPages); |
295 }, | 299 }, |
296 onLoading: new ext._EventTarget() | 300 onLoading: new ext._EventTarget(), |
301 onActivated: new ext._EventTarget(), | |
297 }; | 302 }; |
298 | 303 |
299 safari.application.addEventListener("close", function(event) | 304 safari.application.addEventListener("close", function(event) |
300 { | 305 { |
301 // this event is dispatched on closing windows and tabs. However when a | 306 // this event is dispatched on closing windows and tabs. However when a |
302 // window is closed, it is first dispatched on each tab in the window and | 307 // window is closed, it is first dispatched on each tab in the window and |
303 // then on the window itself. But we are only interested in closed tabs. | 308 // then on the window itself. But we are only interested in closed tabs. |
304 if (!(event.target instanceof SafariBrowserTab)) | 309 if (!(event.target instanceof SafariBrowserTab)) |
305 return; | 310 return; |
306 | 311 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 tab.activate(); | 742 tab.activate(); |
738 if (callback) | 743 if (callback) |
739 callback(page); | 744 callback(page); |
740 return; | 745 return; |
741 } | 746 } |
742 } | 747 } |
743 | 748 |
744 ext.pages.open(optionsUrl, callback); | 749 ext.pages.open(optionsUrl, callback); |
745 }; | 750 }; |
746 })(); | 751 })(); |
OLD | NEW |