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

Delta Between Two Patch Sets: background.js

Issue 5225119261655040: Issue 1282 - Don't generate filters conflicting with existing exception rules (Closed)
Left Patch Set: Rebased Created Feb. 13, 2015, 4:13 p.m.
Right Patch Set: Addressed comment Created March 3, 2015, 2:59 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | include.postload.js » ('j') | lib/filterComposer.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 with(require("filterClasses")) 18 with(require("filterClasses"))
19 { 19 {
20 this.Filter = Filter; 20 this.Filter = Filter;
21 this.RegExpFilter = RegExpFilter;
22 this.BlockingFilter = BlockingFilter; 21 this.BlockingFilter = BlockingFilter;
23 this.WhitelistFilter = WhitelistFilter; 22 this.WhitelistFilter = WhitelistFilter;
24 } 23 }
25 with(require("subscriptionClasses")) 24 with(require("subscriptionClasses"))
26 { 25 {
27 this.Subscription = Subscription; 26 this.Subscription = Subscription;
28 this.DownloadableSubscription = DownloadableSubscription; 27 this.DownloadableSubscription = DownloadableSubscription;
29 this.SpecialSubscription = SpecialSubscription; 28 this.SpecialSubscription = SpecialSubscription;
30 } 29 }
31 with(require("whitelisting")) 30 with(require("whitelisting"))
(...skipping 19 matching lines...) Expand all
51 var ElemHide = require("elemHide").ElemHide; 50 var ElemHide = require("elemHide").ElemHide;
52 var defaultMatcher = require("matcher").defaultMatcher; 51 var defaultMatcher = require("matcher").defaultMatcher;
53 var Prefs = require("prefs").Prefs; 52 var Prefs = require("prefs").Prefs;
54 var Synchronizer = require("synchronizer").Synchronizer; 53 var Synchronizer = require("synchronizer").Synchronizer;
55 var Utils = require("utils").Utils; 54 var Utils = require("utils").Utils;
56 var NotificationStorage = require("notification").Notification; 55 var NotificationStorage = require("notification").Notification;
57 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti fication; 56 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti fication;
58 var parseFilters = require("filterValidation").parseFilters; 57 var parseFilters = require("filterValidation").parseFilters;
59 var composeFilters = require("filterComposer").composeFilters; 58 var composeFilters = require("filterComposer").composeFilters;
60 59
61 // Some types cannot be distinguished
62 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
63 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT HER;
64
65 // Chrome on Linux does not fully support chrome.notifications until version 35 60 // Chrome on Linux does not fully support chrome.notifications until version 35
66 // https://code.google.com/p/chromium/issues/detail?id=291485 61 // https://code.google.com/p/chromium/issues/detail?id=291485
67 var canUseChromeNotifications = require("info").platform == "chromium" 62 var canUseChromeNotifications = require("info").platform == "chromium"
68 && "notifications" in chrome 63 && "notifications" in chrome
69 && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").appl icationVersion, 10) > 34); 64 && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").appl icationVersion, 10) > 34);
70 65
71 var seenDataCorruption = false; 66 var seenDataCorruption = false;
72 var filterlistsReinitialized = false; 67 var filterlistsReinitialized = false;
73 require("filterNotifier").FilterNotifier.addListener(function(action) 68 require("filterNotifier").FilterNotifier.addListener(function(action)
74 { 69 {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 { 353 {
359 if (activeNotification && activeNotification.id === notification.id) 354 if (activeNotification && activeNotification.id === notification.id)
360 return; 355 return;
361 356
362 activeNotification = notification; 357 activeNotification = notification;
363 if (activeNotification.type === "critical" || activeNotification.type === "que stion") 358 if (activeNotification.type === "critical" || activeNotification.type === "que stion")
364 { 359 {
365 var texts = NotificationStorage.getLocalizedTexts(notification); 360 var texts = NotificationStorage.getLocalizedTexts(notification);
366 var title = texts.title || ""; 361 var title = texts.title || "";
367 var message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : ""; 362 var message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : "";
368 var iconUrl = ext.getURL("icons/abp-128.png"); 363 var iconUrl = ext.getURL("icons/detailed/abp-128.png");
369 var hasLinks = activeNotification.links && activeNotification.links.length > 0; 364 var hasLinks = activeNotification.links && activeNotification.links.length > 0;
370 365
371 if (canUseChromeNotifications) 366 if (canUseChromeNotifications)
372 { 367 {
373 var opts = { 368 var opts = {
374 type: "basic", 369 type: "basic",
375 title: title, 370 title: title,
376 message: message, 371 message: message,
377 buttons: [], 372 buttons: [],
378 priority: 2 // We use the highest priority to prevent the notification f rom closing automatically 373 priority: 2 // We use the highest priority to prevent the notification f rom closing automatically
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 }); 546 });
552 break; 547 break;
553 case "add-sitekey": 548 case "add-sitekey":
554 processKey(msg.token, sender.page, sender.frame); 549 processKey(msg.token, sender.page, sender.frame);
555 break; 550 break;
556 case "report-html-page": 551 case "report-html-page":
557 htmlPages.set(sender.page, null); 552 htmlPages.set(sender.page, null);
558 refreshIconAndContextMenu(sender.page); 553 refreshIconAndContextMenu(sender.page);
559 break; 554 break;
560 case "compose-filters": 555 case "compose-filters":
561 sendResponse(composeFilters( 556 sendResponse(composeFilters({
562 msg.tagName, msg.id, msg.src, msg.style, 557 tagName: msg.tagName,
563 msg.classes, msg.urls, msg.mediatype, 558 id: msg.id,
564 msg.baseURL, sender.page, sender.frame 559 src: msg.src,
565 )); 560 style: msg.style,
561 classes: msg.classes,
562 urls: msg.urls,
563 type: msg.mediatype,
564 baseURL: msg.baseURL,
565 page: sender.page,
566 frame: sender.frame
567 }));
566 break; 568 break;
567 case "forward": 569 case "forward":
568 if (sender.page) 570 if (sender.page)
569 { 571 {
570 if (msg.expectsResponse) 572 if (msg.expectsResponse)
571 { 573 {
572 sender.page.sendMessage(msg.payload, sendResponse); 574 sender.page.sendMessage(msg.payload, sendResponse);
573 return true; 575 return true;
574 } 576 }
575 577
576 sender.page.sendMessage(msg.payload); 578 sender.page.sendMessage(msg.payload);
577 } 579 }
578 break; 580 break;
579 } 581 }
580 }); 582 });
581 583
582 // update icon when page changes location 584 // update icon when page changes location
583 ext.pages.onLoading.addListener(function(page) 585 ext.pages.onLoading.addListener(function(page)
584 { 586 {
585 page.sendMessage({type: "clickhide-deactivate"}); 587 page.sendMessage({type: "clickhide-deactivate"});
586 refreshIconAndContextMenu(page); 588 refreshIconAndContextMenu(page);
587 }); 589 });
588 590
589 setTimeout(function() 591 setTimeout(function()
590 { 592 {
591 var notificationToShow = NotificationStorage.getNextToShow(); 593 var notificationToShow = NotificationStorage.getNextToShow();
592 if (notificationToShow) 594 if (notificationToShow)
593 showNotification(notificationToShow); 595 showNotification(notificationToShow);
594 }, 3 * 60 * 1000); 596 }, 3 * 60 * 1000);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld