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

Side by Side Diff: background.js

Issue 5666188336037888: Issue 581 - Fixed element hiding/collapsing in anonymous frames on Chrome (Closed)
Patch Set: Fall back to parent frame's URL when processing requests from anonymous frames Created June 3, 2014, 6:59 a.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 | include.preload.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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 { 511 {
512 switch (msg.type) 512 switch (msg.type)
513 { 513 {
514 case "get-selectors": 514 case "get-selectors":
515 var selectors = []; 515 var selectors = [];
516 516
517 if (!isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT") && 517 if (!isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT") &&
518 !isFrameWhitelisted(sender.page, sender.frame, "ELEMHIDE")) 518 !isFrameWhitelisted(sender.page, sender.frame, "ELEMHIDE"))
519 { 519 {
520 var noStyleRules = false; 520 var noStyleRules = false;
521 var host = extractHostFromURL(sender.frame.url); 521 var host = extractHostFromFrame(sender.frame);
522 for (var i = 0; i < noStyleRulesHosts.length; i++) 522 for (var i = 0; i < noStyleRulesHosts.length; i++)
523 { 523 {
524 var noStyleHost = noStyleRulesHosts[i]; 524 var noStyleHost = noStyleRulesHosts[i];
525 if (host == noStyleHost || (host.length > noStyleHost.length && 525 if (host == noStyleHost || (host.length > noStyleHost.length &&
526 host.substr(host.length - noStyleHost.leng th - 1) == "." + noStyleHost)) 526 host.substr(host.length - noStyleHost.leng th - 1) == "." + noStyleHost))
527 { 527 {
528 noStyleRules = true; 528 noStyleRules = true;
529 } 529 }
530 } 530 }
531 selectors = ElemHide.getSelectorsForDomain(host, false); 531 selectors = ElemHide.getSelectorsForDomain(host, false);
532 if (noStyleRules) 532 if (noStyleRules)
533 { 533 {
534 selectors = selectors.filter(function(s) 534 selectors = selectors.filter(function(s)
535 { 535 {
536 return !/\[style[\^\$]?=/.test(s); 536 return !/\[style[\^\$]?=/.test(s);
537 }); 537 });
538 } 538 }
539 } 539 }
540 540
541 sendResponse(selectors); 541 sendResponse(selectors);
542 break; 542 break;
543 case "should-collapse": 543 case "should-collapse":
544 if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT")) 544 if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT"))
545 { 545 {
546 sendResponse(false); 546 sendResponse(false);
547 break; 547 break;
548 } 548 }
549 549
550 var requestHost = extractHostFromURL(msg.url); 550 var requestHost = extractHostFromURL(msg.url);
551 var documentHost = extractHostFromURL(sender.frame.url); 551 var documentHost = extractHostFromFrame(sender.frame);
552 var thirdParty = isThirdParty(requestHost, documentHost); 552 var thirdParty = isThirdParty(requestHost, documentHost);
553 var filter = defaultMatcher.matchesAny(msg.url, msg.mediatype, documentHos t, thirdParty); 553 var filter = defaultMatcher.matchesAny(msg.url, msg.mediatype, documentHos t, thirdParty);
554 if (filter instanceof BlockingFilter) 554 if (filter instanceof BlockingFilter)
555 { 555 {
556 var collapse = filter.collapse; 556 var collapse = filter.collapse;
557 if (collapse == null) 557 if (collapse == null)
558 collapse = Prefs.hidePlaceholders; 558 collapse = Prefs.hidePlaceholders;
559 sendResponse(collapse); 559 sendResponse(collapse);
560 } 560 }
561 else 561 else
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 page.sendMessage({type: "clickhide-deactivate"}); 607 page.sendMessage({type: "clickhide-deactivate"});
608 refreshIconAndContextMenu(page); 608 refreshIconAndContextMenu(page);
609 }); 609 });
610 610
611 setTimeout(function() 611 setTimeout(function()
612 { 612 {
613 var notificationToShow = Notification.getNextToShow(); 613 var notificationToShow = Notification.getNextToShow();
614 if (notificationToShow) 614 if (notificationToShow)
615 showNotification(notificationToShow); 615 showNotification(notificationToShow);
616 }, 3 * 60 * 1000); 616 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | include.preload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld