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

Side by Side Diff: lib/ui.js

Issue 6337686776315904: Issue 394 - hit statistics tool data collection (Closed)
Patch Set: Created Feb. 28, 2015, 3:01 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
« lib/filterHits.js ('K') | « lib/filterStorage.js ('k') | no next file » | no next file with comments »
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
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
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 this.toggleSendStats();
1199 } 1202 }
1200 else 1203 else
1201 Prefs.savestats = true; 1204 Prefs.savestats = true;
1202 }, 1205 },
1206
1207 /**
1208 * Toggles "Send stats" option.
1209 */
1210 toggleSendStats: function(window)
1211 {
1212 if (Prefs.sendstats)
1213 {
1214 FilterHits.resetFilterHits();
1215 Prefs.sendstats = false;
1216 }
1217 else
1218 Prefs.sendstats = true;
1219 },
1203 1220
1204 /** 1221 /**
1205 * Sets the current filter subscription in a single-subscription scenario, 1222 * Sets the current filter subscription in a single-subscription scenario,
1206 * all other subscriptions will be removed. 1223 * all other subscriptions will be removed.
1207 */ 1224 */
1208 setSubscription: function(url, title) 1225 setSubscription: function(url, title)
1209 { 1226 {
1210 let subscription = Subscription.fromURL(url); 1227 let subscription = Subscription.fromURL(url);
1211 let currentSubscriptions = FilterStorage.subscriptions.filter( 1228 let currentSubscriptions = FilterStorage.subscriptions.filter(
1212 ((subscription) => subscription instanceof DownloadableSubscription && sub scription.url != Prefs.subscriptions_exceptionsurl) 1229 ((subscription) => subscription instanceof DownloadableSubscription && sub scription.url != Prefs.subscriptions_exceptionsurl)
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 generateLabel(prefix + "whitelistsite", location.spec.replace(/^mailto:/ , "")); 1549 generateLabel(prefix + "whitelistsite", location.spec.replace(/^mailto:/ , ""));
1533 hideElement(prefix + "whitelistsite", false); 1550 hideElement(prefix + "whitelistsite", false);
1534 } 1551 }
1535 } 1552 }
1536 1553
1537 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme (location) || location.scheme == "mailto"); 1554 setDisabled("abp-command-sendReport", !location || !Policy.isBlockableScheme (location) || location.scheme == "mailto");
1538 1555
1539 setChecked(prefix + "disabled", !Prefs.enabled); 1556 setChecked(prefix + "disabled", !Prefs.enabled);
1540 setChecked(prefix + "frameobjects", Prefs.frameobjects); 1557 setChecked(prefix + "frameobjects", Prefs.frameobjects);
1541 setChecked(prefix + "savestats", Prefs.savestats); 1558 setChecked(prefix + "savestats", Prefs.savestats);
1559 setChecked(prefix + "sendstats", Prefs.sendstats);
1542 1560
1543 let {defaultToolbarPosition, statusbarPosition} = require("appSupport"); 1561 let {defaultToolbarPosition, statusbarPosition} = require("appSupport");
1544 let hasToolbar = defaultToolbarPosition; 1562 let hasToolbar = defaultToolbarPosition;
1545 let hasStatusBar = statusbarPosition; 1563 let hasStatusBar = statusbarPosition;
1546 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- "); 1564 hideElement(prefix + "showintoolbar", !hasToolbar || prefix == "abp-toolbar- ");
1547 hideElement(prefix + "showinstatusbar", !hasStatusBar); 1565 hideElement(prefix + "showinstatusbar", !hasStatusBar);
1548 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar); 1566 hideElement(prefix + "iconSettingsSeparator", (prefix == "abp-toolbar-" || ! hasToolbar) && !hasStatusBar);
1549 1567
1550 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible()); 1568 setChecked(prefix + "showintoolbar", this.isToolbarIconVisible());
1551 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar); 1569 setChecked(prefix + "showinstatusbar", Prefs.showinstatusbar);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 * @type Array 1958 * @type Array
1941 */ 1959 */
1942 let eventHandlers = [ 1960 let eventHandlers = [
1943 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)], 1961 ["abp-command-sendReport", "command", UI.openReportDialog.bind(UI)],
1944 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)], 1962 ["abp-command-filters", "command", UI.openFiltersDialog.bind(UI)],
1945 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)], 1963 ["abp-command-sidebar", "command", UI.toggleBottombar.bind(UI)],
1946 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }], 1964 ["abp-command-togglesitewhitelist", "command", function() { UI.toggleFilter(si teWhitelist); }],
1947 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }], 1965 ["abp-command-togglepagewhitelist", "command", function() { UI.toggleFilter(pa geWhitelist); }],
1948 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )], 1966 ["abp-command-toggleobjtabs", "command", UI.togglePref.bind(UI, "frameobjects" )],
1949 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)], 1967 ["abp-command-togglesavestats", "command", UI.toggleSaveStats.bind(UI)],
1968 ["abp-command-togglesendstats", "command", UI.toggleSendStats.bind(UI)],
1950 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)], 1969 ["abp-command-togglesync", "command", UI.toggleSync.bind(UI)],
1951 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)], 1970 ["abp-command-toggleshowintoolbar", "command", UI.toggleToolbarIcon.bind(UI)],
1952 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")], 1971 ["abp-command-toggleshowinstatusbar", "command", UI.togglePref.bind(UI, "showi nstatusbar")],
1953 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")], 1972 ["abp-command-enable", "command", UI.togglePref.bind(UI, "enabled")],
1954 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], 1973 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
1955 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] 1974 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)]
1956 ]; 1975 ];
1957 1976
1958 onShutdown.add(function() 1977 onShutdown.add(function()
1959 { 1978 {
1960 for (let window in UI.applicationWindows) 1979 for (let window in UI.applicationWindows)
1961 if (UI.isBottombarOpen(window)) 1980 if (UI.isBottombarOpen(window))
1962 UI.toggleBottombar(window); 1981 UI.toggleBottombar(window);
1963 }); 1982 });
OLDNEW
« lib/filterHits.js ('K') | « lib/filterStorage.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld