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

Unified Diff: safari/ext/content.js

Issue 6346177440120832: Added abstraction for frames, to fix domain-based rules, whitelisting and ad counter on Safari (Closed)
Patch Set: Created Dec. 21, 2013, 7:48 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
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();
})();
« safari/ext/common.js ('K') | « safari/ext/common.js ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld