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

Side by Side Diff: lib/devtools.js

Issue 29336084: Issue 2426 - Open block.html as a popup window (Closed)
Patch Set: Reduce callback checking boilerplate Created Feb. 15, 2016, 3:45 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
« no previous file with comments | « include.postload.js ('k') | lib/icon.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
30 // because data must persist after navigation/reload. 30 // because data must persist after navigation/reload.
31 let panels = Object.create(null); 31 let panels = Object.create(null);
32 32
33 function hasPanels() 33 function hasPanels()
34 { 34 {
35 return Object.keys(panels).length > 0; 35 return Object.keys(panels).length > 0;
36 } 36 }
37 37
38 function getActivePanel(page) 38 function getActivePanel(page)
39 { 39 {
40 let panel = panels[page._id]; 40 let panel = panels[page.id];
41 if(panel && !panel.reload && !panel.reloading) 41 if(panel && !panel.reload && !panel.reloading)
42 return panel; 42 return panel;
43 return null; 43 return null;
44 } 44 }
45 45
46 function getFilterInfo(filter) 46 function getFilterInfo(filter)
47 { 47 {
48 if (!filter) 48 if (!filter)
49 return null; 49 return null;
50 50
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 }; 203 };
204 204
205 /** 205 /**
206 * Checks whether a page is inspected by the devtools panel. 206 * Checks whether a page is inspected by the devtools panel.
207 * 207 *
208 * @param {Page} page 208 * @param {Page} page
209 * @return {boolean} 209 * @return {boolean}
210 */ 210 */
211 exports.hasPanel = function(page) 211 exports.hasPanel = function(page)
212 { 212 {
213 return page._id in panels; 213 return page.id in panels;
214 }; 214 };
215 215
216 function onBeforeRequest(details) 216 function onBeforeRequest(details)
217 { 217 {
218 let panel = panels[details.tabId]; 218 let panel = panels[details.tabId];
219 219
220 // Clear the devtools panel and reload the inspected tab without caching 220 // Clear the devtools panel and reload the inspected tab without caching
221 // when a new request is issued. However, make sure that we don't end up 221 // when a new request is issued. However, make sure that we don't end up
222 // in an infinite recursion if we already triggered a reload. 222 // in an infinite recursion if we already triggered a reload.
223 if (panel.reloading) 223 if (panel.reloading)
224 { 224 {
225 panel.reloading = false; 225 panel.reloading = false;
226 } 226 }
227 else 227 else
228 { 228 {
229 panel.records = []; 229 panel.records = [];
230 panel.port.postMessage({type: "reset"}); 230 panel.port.postMessage({type: "reset"});
231 231
232 // We can't repeat the request if it isn't a GET request. Chrome would 232 // We can't repeat the request if it isn't a GET request. Chrome would
233 // prompt the user to confirm reloading the page, and POST requests are 233 // prompt the user to confirm reloading the page, and POST requests are
234 // known to cause issues on many websites if repeated. 234 // known to cause issues on many websites if repeated.
235 if (details.method == "GET") 235 if (details.method == "GET")
236 panel.reload = true; 236 panel.reload = true;
237 } 237 }
238 } 238 }
239 239
240 function onLoading(page) 240 function onLoading(page)
241 { 241 {
242 let tabId = page._id; 242 let tabId = page.id;
243 let panel = panels[tabId]; 243 let panel = panels[tabId];
244 244
245 // Reloading the tab is the only way that allows bypassing all caches, in 245 // Reloading the tab is the only way that allows bypassing all caches, in
246 // order to see all requests in the devtools panel. Reloading must not be 246 // order to see all requests in the devtools panel. Reloading must not be
247 // performed before the tab changes to "loading", otherwise it will load the 247 // performed before the tab changes to "loading", otherwise it will load the
248 // previous URL. 248 // previous URL.
249 if (panel && panel.reload) 249 if (panel && panel.reload)
250 { 250 {
251 chrome.tabs.reload(tabId, {bypassCache: true}); 251 chrome.tabs.reload(tabId, {bypassCache: true});
252 252
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 if (!hasPanels()) 374 if (!hasPanels())
375 { 375 {
376 FilterNotifier.removeListener(onFilterChange); 376 FilterNotifier.removeListener(onFilterChange);
377 ext.pages.onLoading.removeListener(onLoading); 377 ext.pages.onLoading.removeListener(onLoading);
378 } 378 }
379 }); 379 });
380 380
381 panels[inspectedTabId] = {port: port, records: []}; 381 panels[inspectedTabId] = {port: port, records: []};
382 }); 382 });
OLDNEW
« no previous file with comments | « include.postload.js ('k') | lib/icon.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld