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

Side by Side Diff: safari/ext/common.js

Issue 5092502491103232: Deal with preloadded pages in Safari 7.0 (Closed)
Patch Set: Created Jan. 23, 2014, 3:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « safari/ext/background.js ('k') | safari/ext/content.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 MessageEventTarget = function(target) 62 MessageEventTarget = function(target)
63 { 63 {
64 WrappedEventTarget.call(this, target, "message", false); 64 WrappedEventTarget.call(this, target, "message", false);
65 }; 65 };
66 MessageEventTarget.prototype = { 66 MessageEventTarget.prototype = {
67 __proto__: WrappedEventTarget.prototype, 67 __proto__: WrappedEventTarget.prototype,
68 _wrapListener: function(listener) 68 _wrapListener: function(listener)
69 { 69 {
70 return function(event) 70 return function(event)
71 { 71 {
72 if (event.name == "request") 72 if (event.name == "request" && !this._ignoreIf(event))
73 listener(event.message.payload, this._getSenderDetails(event), functio n(message) 73 listener(event.message.payload, this._getSenderDetails(event), functio n(message)
74 { 74 {
75 this._getResponseDispatcher(event).dispatchMessage("response", 75 this._getResponseDispatcher(event).dispatchMessage("response",
76 { 76 {
77 requestId: event.message.requestId, 77 requestId: event.message.requestId,
78 payload: message 78 payload: message
79 }); 79 });
80 }.bind(this)); 80 }.bind(this));
81 }.bind(this); 81 }.bind(this);
82 } 82 }
83 }; 83 };
84 84
85 85
86 /* Message passing */ 86 /* Message passing */
87 87
88 var requestCounter = 0; 88 var requestCounter = 0;
89 89
90 _sendMessage = function(message, responseCallback, messageDispatcher, response EventTarget, extra) 90 _sendMessage = function(message, responseCallback, messageDispatcher, response EventTarget, extra)
91 { 91 {
92 var requestId = ++requestCounter; 92 var requestId = ++requestCounter;
93 93
94 if (responseCallback) 94 if (responseCallback)
95 { 95 {
96 var responseListener = function(event) 96 var responseListener = function(event)
97 { 97 {
98 if (event.name == "response" && event.message.requestId == requestId) 98 if (event.name == "response" && event.message.requestId == requestId)
99 { 99 {
100 responseEventTarget.removeEventListener("message", responseListener, f alse); 100 responseEventTarget.removeEventListener("message", responseListener, f alse);
101 responseCallback(event.message.payload); 101 responseCallback(event.message);
102 } 102 }
103 }; 103 };
104 responseEventTarget.addEventListener("message", responseListener, false); 104 responseEventTarget.addEventListener("message", responseListener, false);
105 } 105 }
106 106
107 var rawMessage = {requestId: requestId, payload: message}; 107 var rawMessage = {requestId: requestId, payload: message};
108 for (var k in extra) 108 for (var k in extra)
109 rawMessage[k] = extra[k]; 109 rawMessage[k] = extra[k];
110 messageDispatcher.dispatchMessage("request", rawMessage); 110 messageDispatcher.dispatchMessage("request", rawMessage);
111 }; 111 };
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 /* API */ 212 /* API */
213 213
214 ext = { 214 ext = {
215 getURL: function(path) 215 getURL: function(path)
216 { 216 {
217 return safari.extension.baseURI + path; 217 return safari.extension.baseURI + path;
218 }, 218 },
219 i18n: new I18n() 219 i18n: new I18n()
220 }; 220 };
221 })(); 221 })();
OLDNEW
« no previous file with comments | « safari/ext/background.js ('k') | safari/ext/content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld