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

Side by Side Diff: ext/background.js

Issue 29723555: Noissue - Make ext._removeFromAllPageMaps private (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 15, 2018, 6:23 a.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 | « no previous file | no next file » | 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-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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 { 53 {
54 this._map.clear(); 54 this._map.clear();
55 nonEmptyPageMaps.delete(this); 55 nonEmptyPageMaps.delete(this);
56 }, 56 },
57 delete(page) 57 delete(page)
58 { 58 {
59 this._delete(page.id); 59 this._delete(page.id);
60 } 60 }
61 }; 61 };
62 62
63 ext._removeFromAllPageMaps = pageId => 63 function removeFromAllPageMaps(pageId)
64 { 64 {
65 for (let pageMap of nonEmptyPageMaps) 65 for (let pageMap of nonEmptyPageMaps)
66 pageMap._delete(pageId); 66 pageMap._delete(pageId);
67 }; 67 }
68
68 69
69 /* Pages */ 70 /* Pages */
70 71
71 let Page = ext.Page = function(tab) 72 let Page = ext.Page = function(tab)
72 { 73 {
73 this.id = tab.id; 74 this.id = tab.id;
74 this._url = tab.url && new URL(tab.url); 75 this._url = tab.url && new URL(tab.url);
75 76
76 this.browserAction = new BrowserAction(tab.id); 77 this.browserAction = new BrowserAction(tab.id);
77 this.contextMenus = new ContextMenus(this); 78 this.contextMenus = new ContextMenus(this);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 return frame; 151 return frame;
151 } 152 }
152 153
153 function updatePageFrameStructure(frameId, tabId, url, parentFrameId) 154 function updatePageFrameStructure(frameId, tabId, url, parentFrameId)
154 { 155 {
155 if (frameId == 0) 156 if (frameId == 0)
156 { 157 {
157 let page = new Page({id: tabId, url}); 158 let page = new Page({id: tabId, url});
158 159
159 ext._removeFromAllPageMaps(tabId); 160 removeFromAllPageMaps(tabId);
160 161
161 browser.tabs.get(tabId, () => 162 browser.tabs.get(tabId, () =>
162 { 163 {
163 // If the tab is prerendered, browser.tabs.get() sets 164 // If the tab is prerendered, browser.tabs.get() sets
164 // browser.runtime.lastError and we have to dispatch the onLoading 165 // browser.runtime.lastError and we have to dispatch the onLoading
165 // event, since the onUpdated event isn't dispatched for prerendered 166 // event, since the onUpdated event isn't dispatched for prerendered
166 // tabs. However, we have to keep relying on the onUpdated event for 167 // tabs. However, we have to keep relying on the onUpdated event for
167 // tabs that are already visible. Otherwise browser action changes get 168 // tabs that are already visible. Otherwise browser action changes get
168 // overridden when Chrome automatically resets them on navigation. 169 // overridden when Chrome automatically resets them on navigation.
169 if (browser.runtime.lastError) 170 if (browser.runtime.lastError)
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 { 273 {
273 updatePageFrameStructure(details.frameId, details.tabId, url, 274 updatePageFrameStructure(details.frameId, details.tabId, url,
274 details.parentFrameId); 275 details.parentFrameId);
275 } 276 }
276 }); 277 });
277 278
278 function forgetTab(tabId) 279 function forgetTab(tabId)
279 { 280 {
280 ext.pages.onRemoved._dispatch(tabId); 281 ext.pages.onRemoved._dispatch(tabId);
281 282
282 ext._removeFromAllPageMaps(tabId); 283 removeFromAllPageMaps(tabId);
283 framesOfTabs.delete(tabId); 284 framesOfTabs.delete(tabId);
284 } 285 }
285 286
286 browser.tabs.onReplaced.addListener((addedTabId, removedTabId) => 287 browser.tabs.onReplaced.addListener((addedTabId, removedTabId) =>
287 { 288 {
288 forgetTab(removedTabId); 289 forgetTab(removedTabId);
289 }); 290 });
290 291
291 browser.tabs.onRemoved.addListener(forgetTab); 292 browser.tabs.onRemoved.addListener(forgetTab);
292 293
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 ext.windows = { 691 ext.windows = {
691 create(createData, callback) 692 create(createData, callback)
692 { 693 {
693 browser.windows.create(createData, createdWindow => 694 browser.windows.create(createData, createdWindow =>
694 { 695 {
695 afterTabLoaded(callback)(createdWindow.tabs[0]); 696 afterTabLoaded(callback)(createdWindow.tabs[0]);
696 }); 697 });
697 } 698 }
698 }; 699 };
699 } 700 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld