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

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

Issue 5735785512828928: Remove tabs from TabMap onLoading instead of onBeforeNavigate on Safari (Closed)
Left Patch Set: Created Jan. 23, 2014, 11:33 a.m.
Right Patch Set: Apparently you can used the reserved keyword "delete" as key when defining inline objects Created Jan. 23, 2014, 3:24 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 | safari/ext/background.js » ('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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 activate: function() 280 activate: function()
281 { 281 {
282 chrome.tabs.update(this._id, {selected: true}); 282 chrome.tabs.update(this._id, {selected: true});
283 }, 283 },
284 sendMessage: function(message, responseCallback) 284 sendMessage: function(message, responseCallback)
285 { 285 {
286 sendMessage(this._id, message, responseCallback); 286 sendMessage(this._id, message, responseCallback);
287 } 287 }
288 }; 288 };
289 289
290 TabMap = function(deleteTabOnBeforeNavigate) 290 TabMap = function(deleteOnPageUnload)
291 { 291 {
292 this._map = {}; 292 this._map = {};
293 293
294 this._delete = this._delete.bind(this); 294 this._delete = this._delete.bind(this);
295 this._deleteTabOnBeforeNavigate = deleteTabOnBeforeNavigate; 295 this._deleteOnPageUnload = deleteOnPageUnload;
296 }; 296 };
297 TabMap.prototype = { 297 TabMap.prototype = {
298 get: function(tab) 298 get: function(tab)
299 { 299 {
300 return (this._map[tab._id] || {}).value; 300 return (this._map[tab._id] || {}).value;
301 }, 301 },
302 set: function(tab, value) 302 set: function(tab, value)
303 { 303 {
304 if (!(tab._id in this._map)) 304 if (!(tab._id in this._map))
305 { 305 {
306 tab.onRemoved.addListener(this._delete); 306 tab.onRemoved.addListener(this._delete);
307 if (this._deleteTabOnBeforeNavigate) 307 if (this._deleteOnPageUnload)
308 tab._onBeforeNavigate.addListener(this._delete); 308 tab._onBeforeNavigate.addListener(this._delete);
309 } 309 }
310 310
311 this._map[tab._id] = {tab: tab, value: value}; 311 this._map[tab._id] = {tab: tab, value: value};
312 }, 312 },
313 has: function(tab) 313 has: function(tab)
314 { 314 {
315 return tab._id in this._map; 315 return tab._id in this._map;
316 }, 316 },
317 clear: function() 317 clear: function()
318 { 318 {
319 for (var id in this._map) 319 for (var id in this._map)
320 this.delete(this._map[id].tab); 320 this.delete(this._map[id].tab);
321 }, 321 },
322 _delete: function(tab) 322 _delete: function(tab)
323 { 323 {
324 // delay so that other event handlers can still lookup this tab 324 // delay so that other event handlers can still lookup this tab
325 setTimeout(this.delete.bind(this, tab), 0); 325 setTimeout(this.delete.bind(this, tab), 0);
326 } 326 },
327 }; 327 delete: function(tab)
328 TabMap.prototype["delete"] = function(tab) 328 {
329 { 329 delete this._map[tab._id];
330 delete this._map[tab._id]; 330
331 331 tab.onRemoved.removeListener(this._delete);
332 tab.onRemoved.removeListener(this._delete); 332 tab._onBeforeNavigate.removeListener(this._delete);
333 tab._onBeforeNavigate.removeListener(this._delete); 333 }
334 }; 334 };
335 335
336 336
337 /* Windows */ 337 /* Windows */
338 338
339 Window = function(win) 339 Window = function(win)
340 { 340 {
341 this._id = win.id; 341 this._id = win.id;
342 this.visible = win.status != "minimized"; 342 this.visible = win.status != "minimized";
343 }; 343 };
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (isContextMenuHidden) 577 if (isContextMenuHidden)
578 return; 578 return;
579 579
580 chrome.contextMenus.removeAll(); 580 chrome.contextMenus.removeAll();
581 isContextMenuHidden = true; 581 isContextMenuHidden = true;
582 } 582 }
583 }; 583 };
584 584
585 ext.onMessage = new BackgroundMessageEventTarget(); 585 ext.onMessage = new BackgroundMessageEventTarget();
586 })(); 586 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld