| 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 {FilterListener} = require("filterListener"); | 24 let {FilterListener} = require("filterListener"); |
| 25 let {FilterStorage} = require("filterStorage"); | 25 let {FilterStorage} = require("filterStorage"); |
| 26 let {FilterNotifier} = require("filterNotifier"); | 26 let {FilterNotifier} = require("filterNotifier"); |
| 27 let {FilterHits} = require("filterHits"); |
| 27 let {RequestNotifier} = require("requestNotifier"); | 28 let {RequestNotifier} = require("requestNotifier"); |
| 28 let {Filter} = require("filterClasses"); | 29 let {Filter} = require("filterClasses"); |
| 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); | 30 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); |
| 30 let {Synchronizer} = require("synchronizer"); | 31 let {Synchronizer} = require("synchronizer"); |
| 31 let {KeySelector} = require("keySelector"); | 32 let {KeySelector} = require("keySelector"); |
| 32 let {Notification} = require("notification"); | 33 let {Notification} = require("notification"); |
| 33 let {initAntiAdblockNotification} = require("antiadblockInit"); | 34 let {initAntiAdblockNotification} = require("antiadblockInit"); |
| 34 | 35 |
| 35 let CustomizableUI = null; | 36 let CustomizableUI = null; |
| 36 | 37 |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 * Toggles "Count filter hits" option. | 1151 * Toggles "Count filter hits" option. |
| 1151 */ | 1152 */ |
| 1152 toggleSaveStats: function(window) | 1153 toggleSaveStats: function(window) |
| 1153 { | 1154 { |
| 1154 if (Prefs.savestats) | 1155 if (Prefs.savestats) |
| 1155 { | 1156 { |
| 1156 if (!Utils.confirm(window, Utils.getString("clearStats_warning"))) | 1157 if (!Utils.confirm(window, Utils.getString("clearStats_warning"))) |
| 1157 return; | 1158 return; |
| 1158 | 1159 |
| 1159 FilterStorage.resetHitCounts(); | 1160 FilterStorage.resetHitCounts(); |
| 1161 Prefs.savestats = false; |
| 1162 if (Prefs.sendstats) |
| 1163 { |
| 1164 this.toggleSendStats(); |
| 1165 return; |
| 1166 } |
| 1167 |
| 1160 FilterListener.setDirty(0); // Force saving to disk | 1168 FilterListener.setDirty(0); // Force saving to disk |
| 1161 Prefs.savestats = false; | |
| 1162 } | 1169 } |
| 1163 else | 1170 else |
| 1164 Prefs.savestats = true; | 1171 Prefs.savestats = true; |
| 1165 }, | 1172 }, |
| 1173 |
| 1174 /** |
| 1175 * Toggles "Send stats" option. |
| 1176 */ |
| 1177 toggleSendStats: function(window) |
| 1178 { |
| 1179 if (Prefs.sendstats) |
| 1180 { |
| 1181 FilterHits.resetFilterHits(); |
| 1182 FilterListener.setDirty(0); // Force saving to disk |
| 1183 Prefs.sendstats = false; |
| 1184 } |
| 1185 else |
| 1186 Prefs.sendstats = true; |
| 1187 }, |
| 1166 | 1188 |
| 1167 /** | 1189 /** |
| 1168 * Sets the current filter subscription in a single-subscription scenario, | 1190 * Sets the current filter subscription in a single-subscription scenario, |
| 1169 * all other subscriptions will be removed. | 1191 * all other subscriptions will be removed. |
| 1170 */ | 1192 */ |
| 1171 setSubscription: function(url, title) | 1193 setSubscription: function(url, title) |
| 1172 { | 1194 { |
| 1173 let subscription = Subscription.fromURL(url); | 1195 let subscription = Subscription.fromURL(url); |
| 1174 let currentSubscriptions = FilterStorage.subscriptions.filter( | 1196 let currentSubscriptions = FilterStorage.subscriptions.filter( |
| 1175 function(subscription) subscription instanceof DownloadableSubscription &&
subscription.url != Prefs.subscriptions_exceptionsurl | 1197 function(subscription) subscription instanceof DownloadableSubscription &&
subscription.url != Prefs.subscriptions_exceptionsurl |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 hideElement(prefix + "whitelistsite", false); | 1518 hideElement(prefix + "whitelistsite", false); |
| 1497 } | 1519 } |
| 1498 } | 1520 } |
| 1499 | 1521 |
| 1500 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme
(location) || location.scheme == "mailto"); | 1522 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme
(location) || location.scheme == "mailto"); |
| 1501 | 1523 |
| 1502 setChecked(prefix + "disabled", !Prefs.enabled); | 1524 setChecked(prefix + "disabled", !Prefs.enabled); |
| 1503 setChecked(prefix + "frameobjects", Prefs.frameobjects); | 1525 setChecked(prefix + "frameobjects", Prefs.frameobjects); |
| 1504 setChecked(prefix + "slowcollapse", !Prefs.fastcollapse); | 1526 setChecked(prefix + "slowcollapse", !Prefs.fastcollapse); |
| 1505 setChecked(prefix + "savestats", Prefs.savestats); | 1527 setChecked(prefix + "savestats", Prefs.savestats); |
| 1528 setChecked(prefix + "sendstats", Prefs.sendstats); |
| 1506 | 1529 |
| 1507 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); | 1530 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); |
| 1508 let hasToolbar = defaultToolbarPosition; | 1531 let hasToolbar = defaultToolbarPosition; |
| 1509 let hasStatusBar = statusbarPosition; | 1532 let hasStatusBar = statusbarPosition; |
| 1510 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar-
"); | 1533 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar-
"); |
| 1511 hideElement(prefix + "showinstatusbar", !hasStatusBar); | 1534 hideElement(prefix + "showinstatusbar", !hasStatusBar); |
| 1512 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || !
hasToolbar) && !hasStatusBar); | 1535 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || !
hasToolbar) && !hasStatusBar); |
| 1513 | 1536 |
| 1514 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); | 1537 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); |
| 1515 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); | 1538 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1903 */ | 1926 */ |
| 1904 let eventHandlers = [ | 1927 let eventHandlers = [ |
| 1905 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], | 1928 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], |
| 1906 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], | 1929 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], |
| 1907 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], | 1930 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], |
| 1908 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si
teWhitelist); }], | 1931 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si
teWhitelist); }], |
| 1909 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa
geWhitelist); }], | 1932 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa
geWhitelist); }], |
| 1910 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects"
)], | 1933 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects"
)], |
| 1911 ["abp-command-togglecollapse", "command", UI.togglePref.bind(UI, "fastcollapse
")], | 1934 ["abp-command-togglecollapse", "command", UI.togglePref.bind(UI, "fastcollapse
")], |
| 1912 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], | 1935 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], |
| 1936 ["abp-command-togglesendstats", "command", UI.toggleSendStats.bind(UI)], |
| 1913 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], | 1937 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], |
| 1914 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], | 1938 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], |
| 1915 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi
nstatusbar")], | 1939 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi
nstatusbar")], |
| 1916 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], | 1940 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], |
| 1917 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1941 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1918 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1942 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1919 ]; | 1943 ]; |
| 1920 | 1944 |
| 1921 onShutdown.add(function() | 1945 onShutdown.add(function() |
| 1922 { | 1946 { |
| 1923 for (let window in UI.applicationWindows) | 1947 for (let window in UI.applicationWindows) |
| 1924 if (UI.isBottombarOpen(window)) | 1948 if (UI.isBottombarOpen(window)) |
| 1925 UI.toggleBottombar(window); | 1949 UI.toggleBottombar(window); |
| 1926 }); | 1950 }); |
| OLD | NEW |