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: Rebased and addressed comments Created Jan. 19, 2014, 10:40 a.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,17 @@
type = "other";
}
- if (!safari.self.tab.canLoad(event, {type: "webRequest", payload: {url: event.url, type: type}}))
+ if (!safari.self.tab.canLoad(
+ event, {
+ type: "webRequest",
+ payload: {
+ url: event.url,
+ type: type,
+ documentUrl: document.location.href,
+ isTopLevel: window == window.top
+ }
+ }
+ ))
{
event.preventDefault();
@@ -307,14 +336,25 @@
/* API */
ext.backgroundPage = {
- _eventTarget: safari.self,
- _messageDispatcher: safari.self.tab,
-
- sendMessage: sendMessage,
- getWindow: function() { return proxy.getObject(0); }
+ sendMessage: function(message, responseCallback)
+ {
+ _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 does not pass the element which the context menu is refering to
// so we need to add it to the event's user info.
« chrome/ext/background.js ('K') | « safari/ext/common.js ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld