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

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

Issue 5943816674607104: Issue 1983 - Dispatch onLoading event for prerendered pages (Closed)
Left Patch Set: Don't remove entry from framesOfTab Created Feb. 10, 2015, 12:42 p.m.
Right Patch Set: Simplified changes Created Feb. 10, 2015, 5:14 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 | « no previous file | no next file » | 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }; 103 };
104 104
105 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
106 {
107 if (changeInfo.status == "loading")
108 ext.pages.onLoading._dispatch(new Page(tab));
109 });
110
105 chrome.webNavigation.onBeforeNavigate.addListener(function(details) 111 chrome.webNavigation.onBeforeNavigate.addListener(function(details)
106 { 112 {
107 if (details.frameId == 0) 113 if (details.frameId == 0)
108 { 114 {
109 ext._removeFromAllPageMaps(details.tabId); 115 ext._removeFromAllPageMaps(details.tabId);
110 ext.pages.onLoading._dispatch(new Page({id: details.tabId, url: details.ur l})); 116
117 chrome.tabs.get(details.tabId, function()
118 {
119 // If the tab is prerendered, chrome.tabs.get() sets
120 // chrome.runtime.lastError and we have to dispatch the onLoading event,
121 // since the onUpdated event isn't dispatched for prerendered tabs.
122 // However, we have to keep relying on the unUpdated event for tabs that
123 // are already visible. Otherwise browser action changes get overridden
124 // when Chrome automatically resets them on navigation.
125 if (chrome.runtime.lastError)
126 {
127 ext.pages.onLoading._dispatch(
128 new Page({
129 id: details.tabId,
130 url: details.url
131 })
132 );
133 }
134 });
111 } 135 }
112 }); 136 });
113 137
114 function forgetTab(tabId) 138 function forgetTab(tabId)
115 { 139 {
116 ext._removeFromAllPageMaps(tabId); 140 ext._removeFromAllPageMaps(tabId);
117 delete framesOfTabs[tabId]; 141 delete framesOfTabs[tabId];
118 } 142 }
119 143
120 chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) 144 chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId)
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 callback(new Page(tab)); 513 callback(new Page(tab));
490 } 514 }
491 else 515 else
492 { 516 {
493 ext.pages.open(optionsUrl, callback); 517 ext.pages.open(optionsUrl, callback);
494 } 518 }
495 }); 519 });
496 }); 520 });
497 }; 521 };
498 })(); 522 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld