Left: | ||
Right: |
OLD | NEW |
---|---|
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 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1189 */ | 1190 */ |
1190 toggleSaveStats: function(window) | 1191 toggleSaveStats: function(window) |
1191 { | 1192 { |
1192 if (Prefs.savestats) | 1193 if (Prefs.savestats) |
1193 { | 1194 { |
1194 if (!Utils.confirm(window, Utils.getString("clearStats_warning"))) | 1195 if (!Utils.confirm(window, Utils.getString("clearStats_warning"))) |
1195 return; | 1196 return; |
1196 | 1197 |
1197 FilterStorage.resetHitCounts(); | 1198 FilterStorage.resetHitCounts(); |
1198 Prefs.savestats = false; | 1199 Prefs.savestats = false; |
1200 if (Prefs.sendstats) | |
1201 { | |
1202 this.toggleSendStats(); | |
1203 return; | |
Thomas Greiner
2015/02/23 18:43:05
The function returns here anyway so this `return`
saroyanm
2015/02/28 15:24:30
Done.
| |
1204 } | |
1199 } | 1205 } |
1200 else | 1206 else |
1201 Prefs.savestats = true; | 1207 Prefs.savestats = true; |
1202 }, | 1208 }, |
1209 | |
1210 /** | |
1211 * Toggles "Send stats" option. | |
1212 */ | |
1213 toggleSendStats: function(window) | |
1214 { | |
1215 if (Prefs.sendstats) | |
1216 { | |
1217 FilterHits.resetFilterHits(); | |
1218 Prefs.sendstats = false; | |
1219 } | |
1220 else | |
1221 Prefs.sendstats = true; | |
1222 }, | |
1203 | 1223 |
1204 /** | 1224 /** |
1205 * Sets the current filter subscription in a single-subscription scenario, | 1225 * Sets the current filter subscription in a single-subscription scenario, |
1206 * all other subscriptions will be removed. | 1226 * all other subscriptions will be removed. |
1207 */ | 1227 */ |
1208 setSubscription: function(url, title) | 1228 setSubscription: function(url, title) |
1209 { | 1229 { |
1210 let subscription = Subscription.fromURL(url); | 1230 let subscription = Subscription.fromURL(url); |
1211 let currentSubscriptions = FilterStorage.subscriptions.filter( | 1231 let currentSubscriptions = FilterStorage.subscriptions.filter( |
1212 ((subscription) => subscription instanceof DownloadableSubscription && sub scription.url != Prefs.subscriptions_exceptionsurl) | 1232 ((subscription) => subscription instanceof DownloadableSubscription && sub scription.url != Prefs.subscriptions_exceptionsurl) |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1532 generateLabel(prefix + "whitelistsite", location.spec.replace(/^mailto:/ , "")); | 1552 generateLabel(prefix + "whitelistsite", location.spec.replace(/^mailto:/ , "")); |
1533 hideElement(prefix + "whitelistsite", false); | 1553 hideElement(prefix + "whitelistsite", false); |
1534 } | 1554 } |
1535 } | 1555 } |
1536 | 1556 |
1537 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme (location) || location.scheme == "mailto"); | 1557 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme (location) || location.scheme == "mailto"); |
1538 | 1558 |
1539 setChecked(prefix + "disabled", !Prefs.enabled); | 1559 setChecked(prefix + "disabled", !Prefs.enabled); |
1540 setChecked(prefix + "frameobjects", Prefs.frameobjects); | 1560 setChecked(prefix + "frameobjects", Prefs.frameobjects); |
1541 setChecked(prefix + "savestats", Prefs.savestats); | 1561 setChecked(prefix + "savestats", Prefs.savestats); |
1562 setChecked(prefix + "sendstats", Prefs.sendstats); | |
1542 | 1563 |
1543 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); | 1564 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); |
1544 let hasToolbar = defaultToolbarPosition; | 1565 let hasToolbar = defaultToolbarPosition; |
1545 let hasStatusBar = statusbarPosition; | 1566 let hasStatusBar = statusbarPosition; |
1546 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); | 1567 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); |
1547 hideElement(prefix + "showinstatusbar", !hasStatusBar); | 1568 hideElement(prefix + "showinstatusbar", !hasStatusBar); |
1548 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); | 1569 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); |
1549 | 1570 |
1550 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); | 1571 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); |
1551 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); | 1572 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1940 * @type Array | 1961 * @type Array |
1941 */ | 1962 */ |
1942 let eventHandlers = [ | 1963 let eventHandlers = [ |
1943 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], | 1964 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], |
1944 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], | 1965 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], |
1945 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], | 1966 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], |
1946 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], | 1967 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], |
1947 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], | 1968 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], |
1948 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], | 1969 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], |
1949 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], | 1970 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], |
1971 ["abp-command-togglesendstats", "command", UI.toggleSendStats.bind(UI)], | |
1950 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], | 1972 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], |
1951 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], | 1973 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], |
1952 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], | 1974 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], |
1953 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], | 1975 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], |
1954 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1976 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
1955 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1977 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
1956 ]; | 1978 ]; |
1957 | 1979 |
1958 onShutdown.add(function() | 1980 onShutdown.add(function() |
1959 { | 1981 { |
1960 for (let window in UI.applicationWindows) | 1982 for (let window in UI.applicationWindows) |
1961 if (UI.isBottombarOpen(window)) | 1983 if (UI.isBottombarOpen(window)) |
1962 UI.toggleBottombar(window); | 1984 UI.toggleBottombar(window); |
1963 }); | 1985 }); |
OLD | NEW |