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

Side by Side Diff: chrome/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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 chrome.tabs.query(rawInfo, function(tabs) 94 chrome.tabs.query(rawInfo, function(tabs)
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 onActivated: new ext._EventTarget() 103 onActivated: new ext._EventTarget(),
104 onRemoved: new ext._EventTarget()
104 }; 105 };
105 106
106 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) 107 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
107 { 108 {
108 if (changeInfo.status == "loading") 109 if (changeInfo.status == "loading")
109 ext.pages.onLoading._dispatch(new Page(tab)); 110 ext.pages.onLoading._dispatch(new Page(tab));
110 }); 111 });
111 112
112 chrome.webNavigation.onBeforeNavigate.addListener(function(details) 113 chrome.webNavigation.onBeforeNavigate.addListener(function(details)
113 { 114 {
(...skipping 17 matching lines...) Expand all
131 url: details.url 132 url: details.url
132 }) 133 })
133 ); 134 );
134 } 135 }
135 }); 136 });
136 } 137 }
137 }); 138 });
138 139
139 function forgetTab(tabId) 140 function forgetTab(tabId)
140 { 141 {
142 ext.pages.onRemoved._dispatch(tabId);
Sebastian Noack 2016/02/10 12:26:56 I guess we should dispatch the event with a Page o
kzar 2016/02/10 14:20:16 I wasn't sure how well it would work using a Page
143
141 ext._removeFromAllPageMaps(tabId); 144 ext._removeFromAllPageMaps(tabId);
142 delete framesOfTabs[tabId]; 145 delete framesOfTabs[tabId];
143 } 146 }
144 147
145 chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) 148 chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId)
146 { 149 {
147 forgetTab(removedTabId); 150 forgetTab(removedTabId);
148 }); 151 });
149 152
150 chrome.tabs.onRemoved.addListener(forgetTab); 153 chrome.tabs.onRemoved.addListener(forgetTab);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 if (callback) 582 if (callback)
580 callback(new Page(tab)); 583 callback(new Page(tab));
581 } 584 }
582 else 585 else
583 { 586 {
584 ext.pages.open(optionsUrl, callback); 587 ext.pages.open(optionsUrl, callback);
585 } 588 }
586 }); 589 });
587 }); 590 });
588 }; 591 };
592
593 /* Windows */
594 ext.windows = {
595 create: (createData, callback) =>
Sebastian Noack 2016/02/10 12:26:56 Nit: I'm not sure if using an arrow function is ap
kzar 2016/02/10 14:20:16 Done.
596 {
597 if (callback)
Sebastian Noack 2016/02/10 12:26:57 The logic here is duplicated from ext.tabs.open. W
kzar 2016/02/10 14:20:16 Done.
598 chrome.windows.create(createData, createdWindow =>
599 {
600 let createdTab = createdWindow.tabs[0];
601 var onUpdated = (tabId, changeInfo, tab) =>
602 {
603 if (tabId == createdTab.id && changeInfo.status == "complete")
604 {
605 chrome.tabs.onUpdated.removeListener(onUpdated);
606 callback(new Page(createdTab));
607 }
608 };
609 chrome.tabs.onUpdated.addListener(onUpdated);
610 });
611 else
612 chrome.windows.create(createData);
613 }
614 };
589 })(); 615 })();
OLDNEW

Powered by Google App Engine
This is Rietveld