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

Delta Between Two Patch Sets: safari/ext/background.js

Issue 29334223: Issue 3532 - Generate animation images at runtime (Closed)
Left Patch Set: Iterate over size in inner loop Created Jan. 26, 2016, 5:09 p.m.
Right Patch Set: Addressed final nits Created Jan. 26, 2016, 10:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « metadata.safari ('k') | safari/icons/abp-16.png » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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; 157 let visiblePage = event.target._visiblePage;
158 var pageId = addPage(activeTab, activeTab.url, false); 158 if (visiblePage)
159 ext.pages.onActivated._dispatch(pages[pageId]); 159 ext.pages.onActivated._dispatch(visiblePage);
160 160
161 // 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
162 // 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
163 // 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
164 // toolbar item of the window, is reset to its intial configuration. 164 // toolbar item of the window, is reset to its intial configuration.
165 updateToolbarItemForPage(event.target._visiblePage, event.target.browserWind ow); 165 updateToolbarItemForPage(visiblePage, event.target.browserWindow);
166 }, true); 166 }, true);
167 167
168 168
169 /* Pages */ 169 /* Pages */
170 170
171 var pages = Object.create(null); 171 var pages = Object.create(null);
172 var pageCounter = 0; 172 var pageCounter = 0;
173 173
174 var Page = function(id, tab, url) 174 var Page = function(id, tab, url)
175 { 175 {
176 this._id = id; 176 this._id = id;
177 this._tab = tab; 177 this._tab = tab;
178 this._frames = [{url: new URL(url || "about:blank"), parent: null}]; 178 this._frames = [{url: new URL(url), parent: null}];
179 179
180 if (tab.page) 180 if (tab.page)
181 this._messageProxy = new ext._MessageProxy(tab.page); 181 this._messageProxy = new ext._MessageProxy(tab.page);
182 else 182 else
183 // 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
184 // 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
185 this._messageProxy = { 185 this._messageProxy = {
186 handleRequest: function() {}, 186 handleRequest: function() {},
187 handleResponse: function() {}, 187 handleResponse: function() {},
188 sendMessage: function() {} 188 sendMessage: function() {}
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 tab.activate(); 742 tab.activate();
743 if (callback) 743 if (callback)
744 callback(page); 744 callback(page);
745 return; 745 return;
746 } 746 }
747 } 747 }
748 748
749 ext.pages.open(optionsUrl, callback); 749 ext.pages.open(optionsUrl, callback);
750 }; 750 };
751 })(); 751 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld