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

Side by Side Diff: background.js

Issue 5225119261655040: Issue 1282 - Don't generate filters conflicting with existing exception rules (Closed)
Patch Set: Created Dec. 15, 2014, 2:47 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 | include.postload.js » ('j') | include.preload.js » ('J')
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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 if (filter instanceof BlockingFilter) 512 if (filter instanceof BlockingFilter)
513 { 513 {
514 var collapse = filter.collapse; 514 var collapse = filter.collapse;
515 if (collapse == null) 515 if (collapse == null)
516 collapse = Prefs.hidePlaceholders; 516 collapse = Prefs.hidePlaceholders;
517 sendResponse(collapse); 517 sendResponse(collapse);
518 } 518 }
519 else 519 else
520 sendResponse(false); 520 sendResponse(false);
521 break; 521 break;
522 case "check-whitelisted-urls":
523 var documentHost = extractHostFromFrame(sender.frame);
524 var sitekey = getKey(sender.page, sender.frame);
525
526 var result = Object.create(null);
527 for (var i = 0; i < msg.urls.length; i++)
528 {
529 var requestUrl = msg.urls[i];
530 var requestHost = extractHostFromURL(requestUrl);
531
532 var filter = defaultMatcher.matchesAny(
533 requestUrl, msg.mediatype, documentHost,
534 isThirdParty(requestHost, documentHost),
535 sitekey
536 );
537
538 result[requestUrl] = filter instanceof WhitelistFilter;
539 }
540
541 sendResponse(result);
542 break;
543 case "get-filters-from-selectors":
544 var filters = [];
545 var selectors = [];
546
547 if (!isFrameWhitelisted(sender.page, sender.frame, "ELEMHIDE"))
548 {
549 var documentHost = extractHostFromFrame(sender.frame);
550
551 for (var i = 0; i < msg.selectors.length; i++)
552 {
553 var selector = msg.selectors[i];
554 var filter = documentHost + "##" + selector;
555
556 if (!ElemHide.getException(Filter.fromText(filter), documentHost))
557 {
558 filters.push(filter);
559 selectors.push(selector);
560 }
561 }
562 }
563
564 sendResponse({filters: filters, selectors: selectors});
565 break;
522 case "get-domain-enabled-state": 566 case "get-domain-enabled-state":
523 // Returns whether this domain is in the exclusion list. 567 // Returns whether this domain is in the exclusion list.
524 // The browser action popup asks us this. 568 // The browser action popup asks us this.
525 if(sender.page) 569 if(sender.page)
526 { 570 {
527 sendResponse({enabled: !isWhitelisted(sender.page.url)}); 571 sendResponse({enabled: !isWhitelisted(sender.page.url)});
528 return; 572 return;
529 } 573 }
530 break; 574 break;
531 case "add-filters": 575 case "add-filters":
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 page.sendMessage({type: "clickhide-deactivate"}); 623 page.sendMessage({type: "clickhide-deactivate"});
580 refreshIconAndContextMenu(page); 624 refreshIconAndContextMenu(page);
581 }); 625 });
582 626
583 setTimeout(function() 627 setTimeout(function()
584 { 628 {
585 var notificationToShow = Notification.getNextToShow(); 629 var notificationToShow = Notification.getNextToShow();
586 if (notificationToShow) 630 if (notificationToShow)
587 showNotification(notificationToShow); 631 showNotification(notificationToShow);
588 }, 3 * 60 * 1000); 632 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | include.postload.js » ('j') | include.preload.js » ('J')

Powered by Google App Engine
This is Rietveld