Index: safari/background.js |
=================================================================== |
--- a/safari/background.js |
+++ b/safari/background.js |
@@ -35,6 +35,21 @@ |
} |
}; |
+ var LoadingTabEventTarget = function(target) |
+ { |
+ WrappedEventTarget.call(this, target, "message", false); |
+ }; |
+ LoadingTabEventTarget.prototype = { |
+ __proto__: WrappedEventTarget.prototype, |
+ _wrapListener: function(listener) |
+ { |
+ return function (event) { |
+ if (event.name == "loading" && event.message == event.target.url) |
Felix Dahlke
2013/11/15 13:28:38
Shouldn't we check if event.target is an instance
Sebastian Noack
2013/11/15 13:45:29
Shouldn't be required here. Only tabs can send mes
|
+ listener(new Tab(event.target)); |
+ }; |
+ } |
+ }; |
+ |
Tab = function(tab) |
{ |
this._tab = tab; |
@@ -42,7 +57,7 @@ |
this._eventTarget = tab; |
this._messageDispatcher = tab.page; |
- this.onBeforeNavigate = new TabEventTarget(tab, "beforeNavigate", false); |
+ this.onLoading = new LoadingTabEventTarget(tab); |
this.onCompleted = new TabEventTarget(tab, "navigate", false); |
this.onActivated = new TabEventTarget(tab, "activate", false); |
this.onRemoved = new TabEventTarget(tab, "close", false); |
@@ -490,7 +505,7 @@ |
}; |
ext.tabs = { |
- onBeforeNavigate: new TabEventTarget(safari.application, "beforeNavigate", true), |
+ onLoading: new LoadingTabEventTarget(safari.application), |
onCompleted: new TabEventTarget(safari.application, "navigate", true), |
onActivated: new TabEventTarget(safari.application, "activate", true), |
onRemoved: new TabEventTarget(safari.application, "close", true) |