LEFT | RIGHT |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 var ElemHide = require("elemHide").ElemHide; | 51 var ElemHide = require("elemHide").ElemHide; |
52 var defaultMatcher = require("matcher").defaultMatcher; | 52 var defaultMatcher = require("matcher").defaultMatcher; |
53 var Prefs = require("prefs").Prefs; | 53 var Prefs = require("prefs").Prefs; |
54 var Synchronizer = require("synchronizer").Synchronizer; | 54 var Synchronizer = require("synchronizer").Synchronizer; |
55 var Utils = require("utils").Utils; | 55 var Utils = require("utils").Utils; |
56 var NotificationStorage = require("notification").Notification; | 56 var NotificationStorage = require("notification").Notification; |
57 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti
fication; | 57 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti
fication; |
58 var parseFilters = require("filterValidation").parseFilters; | 58 var parseFilters = require("filterValidation").parseFilters; |
59 var composeFilters = require("filterComposer").composeFilters; | 59 var composeFilters = require("filterComposer").composeFilters; |
60 | 60 |
| 61 // Chrome on Linux does not fully support chrome.notifications until version 35 |
| 62 // https://code.google.com/p/chromium/issues/detail?id=291485 |
| 63 var canUseChromeNotifications = (function() |
| 64 { |
| 65 var info = require("info"); |
| 66 if (info.platform == "chromium" && "notifications" in chrome) |
| 67 { |
| 68 if (navigator.platform.indexOf("Linux") == -1) |
| 69 return true; |
| 70 if (Services.vc.compare(info.applicationVersion, "35") >= 0) |
| 71 return true; |
| 72 } |
| 73 return false; |
| 74 })(); |
| 75 |
61 var seenDataCorruption = false; | 76 var seenDataCorruption = false; |
62 var filterlistsReinitialized = false; | 77 var filterlistsReinitialized = false; |
63 | 78 |
64 function init() | 79 function init() |
65 { | 80 { |
66 var filtersLoaded = false; | 81 var filtersLoaded = false; |
67 var prefsLoaded = false; | 82 var prefsLoaded = false; |
68 | 83 |
69 var checkLoaded = function() | 84 var checkLoaded = function() |
70 { | 85 { |
(...skipping 15 matching lines...) Expand all Loading... |
86 seenDataCorruption = previousVersion && FilterStorage.firstRun; | 101 seenDataCorruption = previousVersion && FilterStorage.firstRun; |
87 Prefs.currentVersion = info.addonVersion; | 102 Prefs.currentVersion = info.addonVersion; |
88 addSubscription(previousVersion); | 103 addSubscription(previousVersion); |
89 } | 104 } |
90 | 105 |
91 // The "Hide placeholders" option has been removed from the UI in 1.8.8.1285 | 106 // The "Hide placeholders" option has been removed from the UI in 1.8.8.1285 |
92 // So we reset the option for users updating from older versions. | 107 // So we reset the option for users updating from older versions. |
93 if (previousVersion && Services.vc.compare(previousVersion, "1.8.8.1285") <
0) | 108 if (previousVersion && Services.vc.compare(previousVersion, "1.8.8.1285") <
0) |
94 Prefs.hidePlaceholders = true; | 109 Prefs.hidePlaceholders = true; |
95 | 110 |
96 // Chrome on Linux does not fully support chrome.notifications until version
35 | 111 if (canUseChromeNotifications) |
97 // https://code.google.com/p/chromium/issues/detail?id=291485 | |
98 if (info.platform == "chromium" && "notifications" in chrome && | |
99 (navigator.platform.indexOf("Linux") == -1 || | |
100 Services.vc.compare(info.applicationVersion, "35") >= 0)) | |
101 initChromeNotifications(); | 112 initChromeNotifications(); |
102 initAntiAdblockNotification(); | 113 initAntiAdblockNotification(); |
103 | 114 |
104 // Update browser actions and context menus when whitelisting might have | 115 // Update browser actions and context menus when whitelisting might have |
105 // changed. That is now when initally loading the filters and later when | 116 // changed. That is now when initally loading the filters and later when |
106 // importing backups or saving filter changes. | 117 // importing backups or saving filter changes. |
107 FilterNotifier.addListener(function(action) | 118 FilterNotifier.addListener(function(action) |
108 { | 119 { |
109 if (action == "load" || action == "save") | 120 if (action == "load" || action == "save") |
110 refreshIconAndContextMenuForAllPages(); | 121 refreshIconAndContextMenuForAllPages(); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 page.sendMessage({type: "clickhide-deactivate"}); | 616 page.sendMessage({type: "clickhide-deactivate"}); |
606 refreshIconAndContextMenu(page); | 617 refreshIconAndContextMenu(page); |
607 }); | 618 }); |
608 | 619 |
609 setTimeout(function() | 620 setTimeout(function() |
610 { | 621 { |
611 var notificationToShow = NotificationStorage.getNextToShow(); | 622 var notificationToShow = NotificationStorage.getNextToShow(); |
612 if (notificationToShow) | 623 if (notificationToShow) |
613 showNotification(notificationToShow); | 624 showNotification(notificationToShow); |
614 }, 3 * 60 * 1000); | 625 }, 3 * 60 * 1000); |
LEFT | RIGHT |