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

Side by Side Diff: background.js

Issue 5788069215076352: Issue 1282 - Show error message when user tries to block whitelisted elements (Closed)
Patch Set: Created Dec. 13, 2014, 1:42 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 | « _locales/en_US/messages.json ('k') | include.postload.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 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 "can-block":
523 var documentHost = extractHostFromFrame(sender.frame);
524
525 if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT"))
526 {
527 sendResponse({canBlock: false, reason: ext.i18n.getMessage("cannot_block _because_domain_whitelisted", documentHost)});
528 break;
529 }
530
531 var sitekey = getKey(sender.page, sender.frame);
532 var exception = null;
533
534 for (var i = 0; !exception && i < msg.urls.length; i++)
535 {
536 var requestHost = extractHostFromURL(msg.url);
537 var thirdParty = isThirdParty(requestHost, documentHost);
538
539 var filter = defaultMatcher.matchesAny(msg.urls[i], msg.mediatype, docum entHost, thirdParty, sitekey);
540 if (filter instanceof WhitelistFilter)
541 exception = filter;
542 }
543
544 for (var i = 0; !exception && i < msg.elemHideFilters.length; i++)
545 exception = ElemHide.getException(Filter.fromText(msg.elemHideFilters[i] ), documentHost);
546
547 if (exception)
548 {
549 var reason = ext.i18n.getMessage("cannot_block_because_exception_rule", exception.text);
550
551 for (var i = 0; i < exception.subscriptions.length; i++)
552 {
553 var subscription = exception.subscriptions[i];
554 if (!subscription.disabled)
555 {
556 if (subscription.url == Prefs.subscriptions_exceptionsurl)
557 reason = ext.i18n.getMessage("cannot_block_because_acceptable_ads" );
558 else if (subscription.title)
559 reason = ext.i18n.getMessage("cannot_block_because_exception_rule_ with_origin", [exception.text, '"' + subscription.title + '"']);
560
561 break;
562 }
563 }
564
565 sendResponse({canBlock: false, reason: reason});
566 break;
567 }
568
569 sendResponse({canBlock: true});
570 break;
522 case "get-domain-enabled-state": 571 case "get-domain-enabled-state":
523 // Returns whether this domain is in the exclusion list. 572 // Returns whether this domain is in the exclusion list.
524 // The browser action popup asks us this. 573 // The browser action popup asks us this.
525 if(sender.page) 574 if(sender.page)
526 { 575 {
527 sendResponse({enabled: !isWhitelisted(sender.page.url)}); 576 sendResponse({enabled: !isWhitelisted(sender.page.url)});
528 return; 577 return;
529 } 578 }
530 break; 579 break;
531 case "add-filters": 580 case "add-filters":
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 page.sendMessage({type: "clickhide-deactivate"}); 628 page.sendMessage({type: "clickhide-deactivate"});
580 refreshIconAndContextMenu(page); 629 refreshIconAndContextMenu(page);
581 }); 630 });
582 631
583 setTimeout(function() 632 setTimeout(function()
584 { 633 {
585 var notificationToShow = Notification.getNextToShow(); 634 var notificationToShow = Notification.getNextToShow();
586 if (notificationToShow) 635 if (notificationToShow)
587 showNotification(notificationToShow); 636 showNotification(notificationToShow);
588 }, 3 * 60 * 1000); 637 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « _locales/en_US/messages.json ('k') | include.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld