OLD | NEW |
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 |
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 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 18 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
19 Cu.import("resource://gre/modules/Services.jsm"); | 19 Cu.import("resource://gre/modules/Services.jsm"); |
20 | 20 |
21 let {Utils} = require("utils"); | 21 let {Utils} = require("utils"); |
22 let {Prefs} = require("prefs"); | 22 let {Prefs} = require("prefs"); |
23 let {Policy} = require("contentPolicy"); | 23 let {Policy} = require("contentPolicy"); |
24 let {FilterStorage} = require("filterStorage"); | 24 let {FilterStorage} = require("filterStorage"); |
25 let {FilterNotifier} = require("filterNotifier"); | 25 let {FilterNotifier} = require("filterNotifier"); |
| 26 let {FilterHits} = require("filterHits"); |
26 let {RequestNotifier} = require("requestNotifier"); | 27 let {RequestNotifier} = require("requestNotifier"); |
27 let {Filter} = require("filterClasses"); | 28 let {Filter} = require("filterClasses"); |
28 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); | 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); |
29 let {Synchronizer} = require("synchronizer"); | 30 let {Synchronizer} = require("synchronizer"); |
30 let {KeySelector} = require("keySelector"); | 31 let {KeySelector} = require("keySelector"); |
31 let {Notification} = require("notification"); | 32 let {Notification} = require("notification"); |
32 let {initAntiAdblockNotification} = require("antiadblockInit"); | 33 let {initAntiAdblockNotification} = require("antiadblockInit"); |
33 | 34 |
34 let CustomizableUI = null; | 35 let CustomizableUI = null; |
35 | 36 |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 */ | 1184 */ |
1184 toggleSaveStats: function(window) | 1185 toggleSaveStats: function(window) |
1185 { | 1186 { |
1186 if (Prefs.savestats) | 1187 if (Prefs.savestats) |
1187 { | 1188 { |
1188 if (!Utils.confirm(window, Utils.getString("clearStats_warning"))) | 1189 if (!Utils.confirm(window, Utils.getString("clearStats_warning"))) |
1189 return; | 1190 return; |
1190 | 1191 |
1191 FilterStorage.resetHitCounts(); | 1192 FilterStorage.resetHitCounts(); |
1192 Prefs.savestats = false; | 1193 Prefs.savestats = false; |
| 1194 if (Prefs.sendstats) |
| 1195 { |
| 1196 this.toggleSendStats(); |
| 1197 return; |
| 1198 } |
1193 } | 1199 } |
1194 else | 1200 else |
1195 Prefs.savestats = true; | 1201 Prefs.savestats = true; |
1196 }, | 1202 }, |
| 1203 |
| 1204 /** |
| 1205 * Toggles "Send stats" option. |
| 1206 */ |
| 1207 toggleSendStats: function(window) |
| 1208 { |
| 1209 if (Prefs.sendstats) |
| 1210 { |
| 1211 FilterHits.resetFilterHits(); |
| 1212 Prefs.sendstats = false; |
| 1213 } |
| 1214 else |
| 1215 Prefs.sendstats = true; |
| 1216 }, |
1197 | 1217 |
1198 /** | 1218 /** |
1199 * Sets the current filter subscription in a single-subscription scenario, | 1219 * Sets the current filter subscription in a single-subscription scenario, |
1200 * all other subscriptions will be removed. | 1220 * all other subscriptions will be removed. |
1201 */ | 1221 */ |
1202 setSubscription: function(url, title) | 1222 setSubscription: function(url, title) |
1203 { | 1223 { |
1204 let subscription = Subscription.fromURL(url); | 1224 let subscription = Subscription.fromURL(url); |
1205 let currentSubscriptions = FilterStorage.subscriptions.filter( | 1225 let currentSubscriptions = FilterStorage.subscriptions.filter( |
1206 ((subscription) => subscription instanceof DownloadableSubscription && sub
scription.url != Prefs.subscriptions_exceptionsurl) | 1226 ((subscription) => subscription instanceof DownloadableSubscription && sub
scription.url != Prefs.subscriptions_exceptionsurl) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 hideElement(prefix + "whitelistsite", false); | 1547 hideElement(prefix + "whitelistsite", false); |
1528 } | 1548 } |
1529 } | 1549 } |
1530 | 1550 |
1531 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme
(location) || location.scheme == "mailto"); | 1551 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme
(location) || location.scheme == "mailto"); |
1532 | 1552 |
1533 setChecked(prefix + "disabled", !Prefs.enabled); | 1553 setChecked(prefix + "disabled", !Prefs.enabled); |
1534 setChecked(prefix + "frameobjects", Prefs.frameobjects); | 1554 setChecked(prefix + "frameobjects", Prefs.frameobjects); |
1535 setChecked(prefix + "slowcollapse", !Prefs.fastcollapse); | 1555 setChecked(prefix + "slowcollapse", !Prefs.fastcollapse); |
1536 setChecked(prefix + "savestats", Prefs.savestats); | 1556 setChecked(prefix + "savestats", Prefs.savestats); |
| 1557 setChecked(prefix + "sendstats", Prefs.sendstats); |
1537 | 1558 |
1538 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); | 1559 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); |
1539 let hasToolbar = defaultToolbarPosition; | 1560 let hasToolbar = defaultToolbarPosition; |
1540 let hasStatusBar = statusbarPosition; | 1561 let hasStatusBar = statusbarPosition; |
1541 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar-
"); | 1562 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar-
"); |
1542 hideElement(prefix + "showinstatusbar", !hasStatusBar); | 1563 hideElement(prefix + "showinstatusbar", !hasStatusBar); |
1543 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || !
hasToolbar) && !hasStatusBar); | 1564 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || !
hasToolbar) && !hasStatusBar); |
1544 | 1565 |
1545 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); | 1566 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); |
1546 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); | 1567 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1936 */ | 1957 */ |
1937 let eventHandlers = [ | 1958 let eventHandlers = [ |
1938 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], | 1959 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], |
1939 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], | 1960 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], |
1940 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], | 1961 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], |
1941 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si
teWhitelist); }], | 1962 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si
teWhitelist); }], |
1942 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa
geWhitelist); }], | 1963 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa
geWhitelist); }], |
1943 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects"
)], | 1964 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects"
)], |
1944 ["abp-command-togglecollapse", "command", UI.togglePref.bind(UI, "fastcollapse
")], | 1965 ["abp-command-togglecollapse", "command", UI.togglePref.bind(UI, "fastcollapse
")], |
1945 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], | 1966 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], |
| 1967 ["abp-command-togglesendstats", "command", UI.toggleSendStats.bind(UI)], |
1946 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], | 1968 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], |
1947 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], | 1969 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], |
1948 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi
nstatusbar")], | 1970 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi
nstatusbar")], |
1949 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], | 1971 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], |
1950 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1972 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1951 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1973 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1952 ]; | 1974 ]; |
1953 | 1975 |
1954 onShutdown.add(function() | 1976 onShutdown.add(function() |
1955 { | 1977 { |
1956 for (let window in UI.applicationWindows) | 1978 for (let window in UI.applicationWindows) |
1957 if (UI.isBottombarOpen(window)) | 1979 if (UI.isBottombarOpen(window)) |
1958 UI.toggleBottombar(window); | 1980 UI.toggleBottombar(window); |
1959 }); | 1981 }); |
OLD | NEW |