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

Unified Diff: chrome/ext/background.js

Issue 5735785512828928: Remove tabs from TabMap onLoading instead of onBeforeNavigate on Safari (Closed)
Patch Set: Apparently you can used the reserved keyword "delete" as key when defining inline objects Created Jan. 23, 2014, 3:24 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | safari/ext/background.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/ext/background.js
===================================================================
--- a/chrome/ext/background.js
+++ b/chrome/ext/background.js
@@ -244,11 +244,15 @@
this.browserAction = new BrowserAction(tab.id);
- this.onBeforeNavigate = ext.tabs.onBeforeNavigate._bindToTab(this);
this.onLoading = ext.tabs.onLoading._bindToTab(this);
this.onCompleted = ext.tabs.onCompleted._bindToTab(this);
this.onActivated = ext.tabs.onActivated._bindToTab(this);
this.onRemoved = ext.tabs.onRemoved._bindToTab(this);
+
+ // the "beforeNavigate" event in Safari isn't dispatched when a new URL
+ // was entered into the address bar. So we can only use it only on Chrome,
+ // but we have to hide it from the browser-independent high level code.
+ this._onBeforeNavigate = ext.tabs._onBeforeNavigate._bindToTab(this);
};
Tab.prototype = {
get url()
@@ -283,12 +287,12 @@
}
};
- TabMap = function(deleteTabOnBeforeNavigate)
+ TabMap = function(deleteOnPageUnload)
{
this._map = {};
this._delete = this._delete.bind(this);
- this._deleteTabOnBeforeNavigate = deleteTabOnBeforeNavigate;
+ this._deleteOnPageUnload = deleteOnPageUnload;
};
TabMap.prototype = {
get: function(tab)
@@ -300,8 +304,8 @@
if (!(tab._id in this._map))
{
tab.onRemoved.addListener(this._delete);
- if (this._deleteTabOnBeforeNavigate)
- tab.onBeforeNavigate.addListener(this._delete);
+ if (this._deleteOnPageUnload)
+ tab._onBeforeNavigate.addListener(this._delete);
}
this._map[tab._id] = {tab: tab, value: value};
@@ -319,15 +323,15 @@
{
// delay so that other event handlers can still lookup this tab
setTimeout(this.delete.bind(this, tab), 0);
+ },
+ delete: function(tab)
+ {
+ delete this._map[tab._id];
+
+ tab.onRemoved.removeListener(this._delete);
+ tab._onBeforeNavigate.removeListener(this._delete);
}
};
- TabMap.prototype["delete"] = function(tab)
- {
- delete this._map[tab._id];
-
- tab.onRemoved.removeListener(this._delete);
- tab.onBeforeNavigate.removeListener(this._delete);
- };
/* Windows */
@@ -513,11 +517,15 @@
};
ext.tabs = {
- onBeforeNavigate: new BeforeNavigateTabEventTarget(),
onLoading: new LoadingTabEventTarget(),
onCompleted: new CompletedTabEventTarget(),
onActivated: new ActivatedTabEventTarget(),
- onRemoved: new RemovedTabEventTarget()
+ onRemoved: new RemovedTabEventTarget(),
+
+ // the "beforeNavigate" event in Safari isn't dispatched when a new URL
+ // was entered into the address bar. So we can only use it only on Chrome,
+ // but we have to hide it from the browser-independent high level code.
+ _onBeforeNavigate: new BeforeNavigateTabEventTarget()
};
ext.webRequest = {
« no previous file with comments | « no previous file | safari/ext/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld