Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: safari/ext/background.js

Issue 29336084: Issue 2426 - Open block.html as a popup window (Closed)
Patch Set: Open block.html as a popup window Created Feb. 8, 2016, 12:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 var isPageActive = function(page) 216 var isPageActive = function(page)
217 { 217 {
218 var tab = page._tab; 218 var tab = page._tab;
219 var win = tab.browserWindow; 219 var win = tab.browserWindow;
220 return win && tab == win.activeTab && page == tab._visiblePage; 220 return win && tab == win.activeTab && page == tab._visiblePage;
221 }; 221 };
222 222
223 var forgetPage = function(id) 223 var forgetPage = function(id)
224 { 224 {
225 ext.pages.onRemoved._dispatch(id);
226
225 ext._removeFromAllPageMaps(id); 227 ext._removeFromAllPageMaps(id);
226 228
227 delete pages[id]._tab._pages[id]; 229 delete pages[id]._tab._pages[id];
228 delete pages[id]; 230 delete pages[id];
229 }; 231 };
230 232
231 var replacePage = function(page) 233 var replacePage = function(page)
232 { 234 {
233 var tab = page._tab; 235 var tab = page._tab;
234 tab._visiblePage = page; 236 tab._visiblePage = page;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if ("lastFocusedWindow" in info && info.lastFocusedWindow != (win == saf ari.application.activeBrowserWindow)) 300 if ("lastFocusedWindow" in info && info.lastFocusedWindow != (win == saf ari.application.activeBrowserWindow))
299 continue; 301 continue;
300 302
301 matchedPages.push(page); 303 matchedPages.push(page);
302 }; 304 };
303 305
304 callback(matchedPages); 306 callback(matchedPages);
305 }, 307 },
306 onLoading: new ext._EventTarget(), 308 onLoading: new ext._EventTarget(),
307 onActivated: new ext._EventTarget(), 309 onActivated: new ext._EventTarget(),
310 onRemoved: new ext._EventTarget()
308 }; 311 };
309 312
310 safari.application.addEventListener("close", function(event) 313 safari.application.addEventListener("close", function(event)
311 { 314 {
312 // this event is dispatched on closing windows and tabs. However when a 315 // this event is dispatched on closing windows and tabs. However when a
313 // window is closed, it is first dispatched on each tab in the window and 316 // window is closed, it is first dispatched on each tab in the window and
314 // then on the window itself. But we are only interested in closed tabs. 317 // then on the window itself. But we are only interested in closed tabs.
315 if (!(event.target instanceof SafariBrowserTab)) 318 if (!(event.target instanceof SafariBrowserTab))
316 return; 319 return;
317 320
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 { 750 {
748 tab.activate(); 751 tab.activate();
749 if (callback) 752 if (callback)
750 callback(page); 753 callback(page);
751 return; 754 return;
752 } 755 }
753 } 756 }
754 757
755 ext.pages.open(optionsUrl, callback); 758 ext.pages.open(optionsUrl, callback);
756 }; 759 };
760
761 /* Windows */
762 ext.windows = {
763 // Safari doesn't provide as rich a windows API as Chrome does, so instead
764 // of chrome.windows.create we have to fall back to just opening a new tab.
765 create: function(createData, callback)
766 {
767 if (createData && createData.url)
Sebastian Noack 2016/02/10 12:26:57 Just assume the URL to be given? If it's missing,
kzar 2016/02/10 14:20:17 Done.
768 ext.pages.open(createData.url, callback);
769 }
770 };
757 })(); 771 })();
OLDNEW

Powered by Google App Engine
This is Rietveld