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

Side by Side Diff: lib/contentPolicy.js

Issue 29329396: Issue 3208 - Improve the approach used to detect pop-up URL (Closed)
Patch Set: Created Oct. 26, 2015, 8:11 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 | « no previous file | no next file » | 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 <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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 let uri = additional || Utils.makeURI(subject.location.href); 477 let uri = additional || Utils.makeURI(subject.location.href);
478 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false)) 478 if (!Policy.processNode(subject.opener, subject.opener.document, Policy. type.POPUP, uri, false))
479 { 479 {
480 subject.stop(); 480 subject.stop();
481 Utils.runAsync(() => subject.close()); 481 Utils.runAsync(() => subject.close());
482 } 482 }
483 else if (uri.spec == "about:blank") 483 else if (uri.spec == "about:blank")
484 { 484 {
485 // An about:blank pop-up most likely means that a load will be 485 // An about:blank pop-up most likely means that a load will be
486 // initiated synchronously. Set a flag for our "http-on-opening-reques t" 486 // initiated asynchronously. Wait for that.
487 // handler.
488 this.expectingPopupLoad = true;
489 Utils.runAsync(function() 487 Utils.runAsync(function()
490 { 488 {
491 this.expectingPopupLoad = false; 489 let channel = subject.QueryInterface(Ci.nsIInterfaceRequestor)
490 .getInterface(Ci.nsIDocShell)
491 .QueryInterface(Ci.nsIDocumentLoader)
492 .documentChannel;
493 if (channel)
494 this.observe(subject, topic, data, channel.URI.spec);
492 }); 495 });
493 } 496 }
494 break; 497 break;
495 } 498 }
496 case "http-on-opening-request": 499 case "http-on-opening-request":
497 case "http-on-modify-request": 500 case "http-on-modify-request":
498 { 501 {
499 if (!(subject instanceof Ci.nsIHttpChannel)) 502 if (!(subject instanceof Ci.nsIHttpChannel))
500 return; 503 return;
501 504
502 if (this.previousRequest && subject.URI == this.previousRequest[0] && 505 if (this.previousRequest && subject.URI == this.previousRequest[0] &&
503 subject instanceof Ci.nsIWritablePropertyBag) 506 subject instanceof Ci.nsIWritablePropertyBag)
504 { 507 {
505 // We just handled a content policy call for this request - associate 508 // We just handled a content policy call for this request - associate
506 // the data with the channel so that we can find it in case of a redir ect. 509 // the data with the channel so that we can find it in case of a redir ect.
507 subject.setProperty("abpRequestType", this.previousRequest[1]); 510 subject.setProperty("abpRequestType", this.previousRequest[1]);
508 this.previousRequest = null; 511 this.previousRequest = null;
509 } 512 }
510
511 if (this.expectingPopupLoad)
512 {
513 let wnd = Utils.getRequestWindow(subject);
514 if (wnd && wnd.opener && wnd.location.href == "about:blank")
515 {
516 this.observe(wnd, "content-document-global-created", null, subject.U RI);
517 if (subject instanceof Ci.nsIWritablePropertyBag)
518 subject.setProperty("abpRequestType", Policy.type.POPUP);
519 }
520 }
521
522 break; 513 break;
523 } 514 }
524 } 515 }
525 }, 516 },
526 517
527 // 518 //
528 // nsIChannelEventSink interface implementation 519 // nsIChannelEventSink interface implementation
529 // 520 //
530 521
531 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback) 522 asyncOnChannelRedirect: function(oldChannel, newChannel, flags, callback)
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 if (!wnd || wnd.closed) 776 if (!wnd || wnd.closed)
786 return; 777 return;
787 778
788 if (entry.type == Policy.type.OBJECT) 779 if (entry.type == Policy.type.OBJECT)
789 { 780 {
790 node.removeEventListener("mouseover", objectMouseEventHander, true); 781 node.removeEventListener("mouseover", objectMouseEventHander, true);
791 node.removeEventListener("mouseout", objectMouseEventHander, true); 782 node.removeEventListener("mouseout", objectMouseEventHander, true);
792 } 783 }
793 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ; 784 Policy.processNode(wnd, node, entry.type, Utils.makeURI(entry.location), true) ;
794 } 785 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld