| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 (function() | 18 (function() |
| 19 { | 19 { |
| 20 if (window == window.top) | 20 if (window == window.top) |
| 21 safari.self.tab.dispatchMessage("loading"); | 21 safari.self.tab.dispatchMessage("loading"); |
| 22 | 22 |
| 23 | 23 |
| 24 /* Events */ | |
| 25 | |
| 26 var ContentMessageEventTarget = function() | |
| 27 { | |
| 28 MessageEventTarget.call(this, safari.self); | |
| 29 }; | |
| 30 ContentMessageEventTarget.prototype = { | |
| 31 __proto__: MessageEventTarget.prototype, | |
| 32 _getResponseDispatcher: function(event) | |
| 33 { | |
| 34 return event.target.tab; | |
| 35 }, | |
| 36 _getSenderDetails: function(event) | |
| 37 { | |
| 38 return {}; | |
| 39 } | |
| 40 }; | |
| 41 | |
| 42 | |
| 24 /* Background page proxy */ | 43 /* Background page proxy */ |
| 25 var proxy = { | 44 var proxy = { |
| 26 objects: [], | 45 objects: [], |
| 27 callbacks: [], | 46 callbacks: [], |
| 28 | 47 |
| 29 send: function(message) | 48 send: function(message) |
| 30 { | 49 { |
| 31 var evt = document.createEvent("Event"); | 50 var evt = document.createEvent("Event"); |
| 32 evt.initEvent("beforeload"); | 51 evt.initEvent("beforeload"); |
| 33 return safari.self.tab.canLoad(evt, {type: "proxy", payload: message}); | 52 return safari.self.tab.canLoad(evt, {type: "proxy", payload: message}); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 case "link": | 302 case "link": |
| 284 if (/\bstylesheet\b/i.test(event.target.rel)) | 303 if (/\bstylesheet\b/i.test(event.target.rel)) |
| 285 { | 304 { |
| 286 type = "stylesheet"; | 305 type = "stylesheet"; |
| 287 break; | 306 break; |
| 288 } | 307 } |
| 289 default: | 308 default: |
| 290 type = "other"; | 309 type = "other"; |
| 291 } | 310 } |
| 292 | 311 |
| 293 if (!safari.self.tab.canLoad(event, {type: "webRequest", payload: {url: even t.url, type: type}})) | 312 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.
| |
| 313 type: "webRequest", | |
| 314 payload: { | |
| 315 url: event.url, | |
| 316 type: type, | |
| 317 documentUrl: document.location.href, | |
| 318 isTopLevel: window == window.top | |
| 319 } | |
| 320 })) | |
| 294 event.preventDefault(); | 321 event.preventDefault(); |
| 295 }, true); | 322 }, true); |
| 296 | 323 |
| 297 | 324 |
| 298 /* API */ | 325 /* API */ |
| 299 | 326 |
| 300 ext.backgroundPage = { | 327 ext.backgroundPage = { |
| 301 _eventTarget: safari.self, | 328 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.
| |
| 302 _messageDispatcher: safari.self.tab, | 329 _sendMessage( |
| 303 | 330 message, responseCallback, |
| 304 sendMessage: sendMessage, | 331 safari.self.tab, safari.self, |
| 305 getWindow: function() { return proxy.getObject(0); } | 332 { |
| 333 documentUrl: document.location.href, | |
| 334 isTopLevel: window == window.top | |
| 335 } | |
| 336 ); | |
| 337 }, | |
| 338 getWindow: function() | |
| 339 { | |
| 340 return proxy.getObject(0); | |
| 341 } | |
| 306 }; | 342 }; |
| 307 | 343 |
| 308 ext.onMessage = new MessageEventTarget(safari.self); | 344 ext.onMessage = new ContentMessageEventTarget(); |
| 309 })(); | 345 })(); |
| OLD | NEW |