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

Side by Side Diff: background.js

Issue 6174977720057856: Issue 1853 - Moved filter generation into background page (Closed)
Patch Set: Created Jan. 25, 2015, 1:21 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.postload.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 <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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 var FilterStorage = require("filterStorage").FilterStorage; 44 var FilterStorage = require("filterStorage").FilterStorage;
45 var ElemHide = require("elemHide").ElemHide; 45 var ElemHide = require("elemHide").ElemHide;
46 var defaultMatcher = require("matcher").defaultMatcher; 46 var defaultMatcher = require("matcher").defaultMatcher;
47 var Prefs = require("prefs").Prefs; 47 var Prefs = require("prefs").Prefs;
48 var Synchronizer = require("synchronizer").Synchronizer; 48 var Synchronizer = require("synchronizer").Synchronizer;
49 var Utils = require("utils").Utils; 49 var Utils = require("utils").Utils;
50 var NotificationStorage = require("notification").Notification; 50 var NotificationStorage = require("notification").Notification;
51 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti fication; 51 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti fication;
52 var parseFilters = require("filterValidation").parseFilters; 52 var parseFilters = require("filterValidation").parseFilters;
53 var composeFilters = require("filterComposer").composeFilters;
53 54
54 // Some types cannot be distinguished 55 // Some types cannot be distinguished
55 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; 56 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
56 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT HER; 57 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT HER;
57 58
58 // Chrome on Linux does not fully support chrome.notifications until version 35 59 // Chrome on Linux does not fully support chrome.notifications until version 35
59 // https://code.google.com/p/chromium/issues/detail?id=291485 60 // https://code.google.com/p/chromium/issues/detail?id=291485
60 var canUseChromeNotifications = require("info").platform == "chromium" 61 var canUseChromeNotifications = require("info").platform == "chromium"
61 && "notifications" in chrome 62 && "notifications" in chrome
62 && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").appl icationVersion, 10) > 34); 63 && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").appl icationVersion, 10) > 34);
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 page.sendMessage(msg); 556 page.sendMessage(msg);
556 }); 557 });
557 break; 558 break;
558 case "add-sitekey": 559 case "add-sitekey":
559 processKey(msg.token, sender.page, sender.frame); 560 processKey(msg.token, sender.page, sender.frame);
560 break; 561 break;
561 case "report-html-page": 562 case "report-html-page":
562 htmlPages.set(sender.page, null); 563 htmlPages.set(sender.page, null);
563 refreshIconAndContextMenu(sender.page); 564 refreshIconAndContextMenu(sender.page);
564 break; 565 break;
566 case "compose-filters":
567 sendResponse(composeFilters(
568 msg.tagName, msg.id, msg.src, msg.style,
569 msg.classes, msg.urls, new URL(msg.baseURL)
570 ));
571 break;
565 case "forward": 572 case "forward":
566 if (sender.page) 573 if (sender.page)
567 { 574 {
568 if (msg.expectsResponse) 575 if (msg.expectsResponse)
569 { 576 {
570 sender.page.sendMessage(msg.payload, sendResponse); 577 sender.page.sendMessage(msg.payload, sendResponse);
571 return true; 578 return true;
572 } 579 }
573 580
574 sender.page.sendMessage(msg.payload); 581 sender.page.sendMessage(msg.payload);
575 } 582 }
576 break; 583 break;
577 } 584 }
578 }); 585 });
579 586
580 // update icon when page changes location 587 // update icon when page changes location
581 ext.pages.onLoading.addListener(function(page) 588 ext.pages.onLoading.addListener(function(page)
582 { 589 {
583 page.sendMessage({type: "clickhide-deactivate"}); 590 page.sendMessage({type: "clickhide-deactivate"});
584 refreshIconAndContextMenu(page); 591 refreshIconAndContextMenu(page);
585 }); 592 });
586 593
587 setTimeout(function() 594 setTimeout(function()
588 { 595 {
589 var notificationToShow = NotificationStorage.getNextToShow(); 596 var notificationToShow = NotificationStorage.getNextToShow();
590 if (notificationToShow) 597 if (notificationToShow)
591 showNotification(notificationToShow); 598 showNotification(notificationToShow);
592 }, 3 * 60 * 1000); 599 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | include.postload.js » ('j') | include.postload.js » ('J')

Powered by Google App Engine
This is Rietveld