Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 let uri = additional || Utils.makeURI(subject.location.href); | 458 let uri = additional || Utils.makeURI(subject.location.href); |
459 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false)) | 459 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false)) |
460 { | 460 { |
461 subject.stop(); | 461 subject.stop(); |
462 Utils.runAsync(() => subject.close()); | 462 Utils.runAsync(() => subject.close()); |
463 } | 463 } |
464 else if (uri.spec == "about:blank") | 464 else if (uri.spec == "about:blank") |
465 { | 465 { |
466 // An about:blank pop-up most likely means that a load will be | 466 // An about:blank pop-up most likely means that a load will be |
467 // initiated asynchronously. Wait for that. | 467 // initiated asynchronously. Wait for that. |
468 Utils.runAsync(function() | 468 Utils.runAsync(() => |
469 { | 469 { |
470 let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor) | 470 let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor) |
471 .getInterface(Ci.nsIDocShell) | 471 .getInterface(Ci.nsIDocShell) |
472 .QueryInterface(Ci.nsIDocumentLoader) | 472 .QueryInterface(Ci.nsIDocumentLoader) |
473 .documentChannel; | 473 .documentChannel; |
474 if (channel) | 474 if (channel) |
475 this.observe(subject, topic, data, channel.URI); | 475 this.observe(subject, topic, data, channel.URI); |
476 }); | 476 }); |
477 } | 477 } |
478 break; | 478 break; |
479 } | 479 } |
480 } | 480 } |
481 }, | 481 }, |
482 | 482 |
483 // | 483 // |
484 // nsIChannelEventSink interface implementation | 484 // nsIChannelEventSink interface implementation |
485 // | 485 // |
486 | 486 |
487 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) | 487 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) |
488 { | 488 { |
489 let result = Cr.NS_OK; | 489 let result = Cr.NS_OK; |
490 try | 490 try |
491 { | 491 { |
492 // nsILoadInfo.contentPolicyType was introduced in Gecko 35, then | 492 // nsILoadInfo.contentPolicyType was introduced in Gecko 35, then |
493 // renamed to nsILoadInfo.externalContentPolicyType in Gecko 44. | 493 // renamed to nsILoadInfo.externalContentPolicyType in Gecko 44. |
494 let loadInfo = oldChannel.loadInfo; | 494 let loadInfo = oldChannel.loadInfo; |
495 let contentType = loadInfo.externalContentPolicyType || loadInfo.contentPo licyType; | 495 let contentType = ("externalContentPolicyType" in loadInfo ? |
tschuster
2015/10/29 14:02:03
I would prefer an explicit `"externalContentPolicy
Wladimir Palant
2015/10/29 18:22:47
Done.
| |
496 loadInfo.externalContentPolicyType : loadInfo.contentPolicyType); | |
496 if (!contentType) | 497 if (!contentType) |
497 return; | 498 return; |
498 | 499 |
499 let newLocation = null; | 500 let newLocation = null; |
500 try | 501 try |
501 { | 502 { |
502 newLocation = newChannel.URI; | 503 newLocation = newChannel.URI; |
503 } catch(e2) {} | 504 } catch(e2) {} |
504 if (!newLocation) | 505 if (!newLocation) |
505 return; | 506 return; |
506 | 507 |
507 let wnd = Utils.getRequestWindow(newChannel); | 508 let wnd = Utils.getRequestWindow(newChannel); |
508 if (!wnd) | 509 if (!wnd) |
509 return; | 510 return; |
510 | 511 |
511 if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT) | 512 if (contentType == Policy.type.POPUP && wnd.opener) |
512 { | 513 { |
513 if (wnd.history.length <= 1 && wnd.opener) | 514 // Popups are initiated by their opener, not their own window. |
514 { | 515 wnd = wnd.opener; |
515 // Special treatment for pop-up windows | |
516 this.observe(wnd, "content-document-global-created", null, newLocation ); | |
517 } | |
518 return; | |
519 } | 516 } |
520 | 517 |
521 if (!Policy.processNode(wnd, wnd.document, contentType, newLocation, false )) | 518 if (!Policy.processNode(wnd, wnd.document, contentType, newLocation, false )) |
522 result = Cr.NS_BINDING_ABORTED; | 519 result = Cr.NS_BINDING_ABORTED; |
523 } | 520 } |
524 catch (e) | 521 catch (e) |
525 { | 522 { |
526 // We shouldn't throw exceptions here - this will prevent the redirect. | 523 // We shouldn't throw exceptions here - this will prevent the redirect. |
527 Cu.reportError(e); | 524 Cu.reportError(e); |
528 } | 525 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 if (!wnd || wnd.closed) | 727 if (!wnd || wnd.closed) |
731 return; | 728 return; |
732 | 729 |
733 if (entry.type == Policy.type.OBJECT) | 730 if (entry.type == Policy.type.OBJECT) |
734 { | 731 { |
735 node.removeEventListener("mouseover", objectMouseEventHander, true); | 732 node.removeEventListener("mouseover", objectMouseEventHander, true); |
736 node.removeEventListener("mouseout", objectMouseEventHander, true); | 733 node.removeEventListener("mouseout", objectMouseEventHander, true); |
737 } | 734 } |
738 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; | 735 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; |
739 } | 736 } |
LEFT | RIGHT |