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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 }, | 98 }, |
99 sendMessage(message, responseCallback) | 99 sendMessage(message, responseCallback) |
100 { | 100 { |
101 browser.tabs.sendMessage(this.id, message, responseCallback); | 101 browser.tabs.sendMessage(this.id, message, responseCallback); |
102 } | 102 } |
103 }; | 103 }; |
104 | 104 |
105 ext.getPage = id => new Page({id: parseInt(id, 10)}); | 105 ext.getPage = id => new Page({id: parseInt(id, 10)}); |
106 | 106 |
107 function afterTabLoaded(callback) | |
108 { | |
109 return openedTab => | |
110 { | |
111 let onUpdated = (tabId, changeInfo, tab) => | |
112 { | |
113 if (tabId == openedTab.id && changeInfo.status == "complete") | |
114 { | |
115 browser.tabs.onUpdated.removeListener(onUpdated); | |
116 callback(new Page(openedTab)); | |
117 } | |
118 }; | |
119 browser.tabs.onUpdated.addListener(onUpdated); | |
120 }; | |
121 } | |
122 | |
123 ext.pages = { | 107 ext.pages = { |
124 onLoading: new ext._EventTarget(), | 108 onLoading: new ext._EventTarget(), |
125 onActivated: new ext._EventTarget(), | 109 onActivated: new ext._EventTarget(), |
126 onRemoved: new ext._EventTarget() | 110 onRemoved: new ext._EventTarget() |
127 }; | 111 }; |
128 | 112 |
129 browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => | 113 browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => |
130 { | 114 { |
131 if (changeInfo.status == "loading") | 115 if (changeInfo.status == "loading") |
132 ext.pages.onLoading._dispatch(new Page(tab)); | 116 ext.pages.onLoading._dispatch(new Page(tab)); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 return frames.get(0) || null; | 566 return frames.get(0) || null; |
583 } | 567 } |
584 }; | 568 }; |
585 } | 569 } |
586 | 570 |
587 return ext.onMessage._dispatch( | 571 return ext.onMessage._dispatch( |
588 message, sender, sendResponse | 572 message, sender, sendResponse |
589 ).includes(true); | 573 ).includes(true); |
590 }); | 574 }); |
591 } | 575 } |
OLD | NEW |