Index: safari/ext/content.js |
=================================================================== |
--- a/safari/ext/content.js |
+++ b/safari/ext/content.js |
@@ -21,6 +21,25 @@ |
safari.self.tab.dispatchMessage("loading"); |
+ /* Events */ |
+ |
+ var ContentMessageEventTarget = function() |
+ { |
+ MessageEventTarget.call(this, safari.self); |
+ }; |
+ ContentMessageEventTarget.prototype = { |
+ __proto__: MessageEventTarget.prototype, |
+ _getResponseDispatcher: function(event) |
+ { |
+ return event.target.tab; |
+ }, |
+ _getSenderDetails: function(event) |
+ { |
+ return {}; |
+ } |
+ }; |
+ |
+ |
/* Background page proxy */ |
var proxy = { |
objects: [], |
@@ -290,7 +309,15 @@ |
type = "other"; |
} |
- if (!safari.self.tab.canLoad(event, {type: "webRequest", payload: {url: event.url, type: type}})) |
+ if (!safari.self.tab.canLoad(event, { |
Felix Dahlke
2014/01/18 13:39:19
{ should go on its own line
Sebastian Noack
2014/01/19 10:19:40
Done.
|
+ type: "webRequest", |
+ payload: { |
+ url: event.url, |
+ type: type, |
+ documentUrl: document.location.href, |
+ isTopLevel: window == window.top |
+ } |
+ })) |
event.preventDefault(); |
}, true); |
@@ -298,12 +325,21 @@ |
/* API */ |
ext.backgroundPage = { |
- _eventTarget: safari.self, |
- _messageDispatcher: safari.self.tab, |
- |
- sendMessage: sendMessage, |
- getWindow: function() { return proxy.getObject(0); } |
+ sendMessage: function(message, responseCallback) { |
Felix Dahlke
2014/01/18 13:39:19
{ should go on its own line
Sebastian Noack
2014/01/19 10:19:40
Done.
|
+ _sendMessage( |
+ message, responseCallback, |
+ safari.self.tab, safari.self, |
+ { |
+ documentUrl: document.location.href, |
+ isTopLevel: window == window.top |
+ } |
+ ); |
+ }, |
+ getWindow: function() |
+ { |
+ return proxy.getObject(0); |
+ } |
}; |
- ext.onMessage = new MessageEventTarget(safari.self); |
+ ext.onMessage = new ContentMessageEventTarget(); |
})(); |