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

Side by Side Diff: new-options.js

Issue 29519669: Issue 5539 - Implement "Acceptable Ads notification" (Closed)
Patch Set: Created Sept. 14, 2017, 9:49 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
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 11 matching lines...) Expand all
22 22
23 { 23 {
24 let subscriptionsMap = Object.create(null); 24 let subscriptionsMap = Object.create(null);
25 let filtersMap = Object.create(null); 25 let filtersMap = Object.create(null);
26 let collections = Object.create(null); 26 let collections = Object.create(null);
27 let acceptableAdsUrl = null; 27 let acceptableAdsUrl = null;
28 let acceptableAdsPrivacyUrl = null; 28 let acceptableAdsPrivacyUrl = null;
29 let isCustomFiltersLoaded = false; 29 let isCustomFiltersLoaded = false;
30 let {getMessage} = ext.i18n; 30 let {getMessage} = ext.i18n;
31 let customFilters = []; 31 let customFilters = [];
32 let showTrackingWarning = true;
Thomas Greiner 2017/09/15 16:15:24 This value needs to come from the preferences. Oth
saroyanm 2017/09/15 18:37:35 Well spotted, thanks. Done.
32 let filterErrors = new Map([ 33 let filterErrors = new Map([
33 ["synchronize_invalid_url", 34 ["synchronize_invalid_url",
34 "options_filterList_lastDownload_invalidURL"], 35 "options_filterList_lastDownload_invalidURL"],
35 ["synchronize_connection_error", 36 ["synchronize_connection_error",
36 "options_filterList_lastDownload_connectionError"], 37 "options_filterList_lastDownload_connectionError"],
37 ["synchronize_invalid_data", 38 ["synchronize_invalid_data",
38 "options_filterList_lastDownload_invalidData"], 39 "options_filterList_lastDownload_invalidData"],
39 ["synchronize_checksum_mismatch", 40 ["synchronize_checksum_mismatch",
40 "options_filterList_lastDownload_checksumMismatch"] 41 "options_filterList_lastDownload_checksumMismatch"]
41 ]); 42 ]);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 type: "subscriptions.add", 573 type: "subscriptions.add",
573 url: findParentData(element, "access", false) 574 url: findParentData(element, "access", false)
574 }); 575 });
575 break; 576 break;
576 } 577 }
577 } 578 }
578 break; 579 break;
579 case "close-dialog": 580 case "close-dialog":
580 closeDialog(); 581 closeDialog();
581 break; 582 break;
583 case "disallow-tracking":
584 execAction("switch-acceptable-ads", {value: "privacy"});
585 break;
582 case "edit-custom-filters": 586 case "edit-custom-filters":
583 setCustomFiltersView("write"); 587 setCustomFiltersView("write");
584 break; 588 break;
585 case "hide-notification": 589 case "hide-notification":
586 hideNotification(); 590 hideNotification();
587 break; 591 break;
588 case "import-subscription": { 592 case "import-subscription": {
589 let url = E("blockingList-textbox").value; 593 let url = E("blockingList-textbox").value;
590 addEnableSubscription(url); 594 addEnableSubscription(url);
591 closeDialog(); 595 closeDialog();
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 document.forms["acceptable-ads"].classList.add("show-dnt-notification"); 1005 document.forms["acceptable-ads"].classList.add("show-dnt-notification");
1002 } 1006 }
1003 document.forms["acceptable-ads"]["acceptable-ads"].value = option; 1007 document.forms["acceptable-ads"]["acceptable-ads"].value = option;
1004 } 1008 }
1005 1009
1006 function isAcceptableAds(url) 1010 function isAcceptableAds(url)
1007 { 1011 {
1008 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1012 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1009 } 1013 }
1010 1014
1015 function hasPrivacyConflict()
1016 {
1017 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl];
1018 let privacyList = null;
1019 for (let url in subscriptionsMap)
1020 {
1021 let subscription = subscriptionsMap[url];
1022 if (subscription.recommended == "privacy")
1023 {
1024 privacyList = subscription;
1025 break;
1026 }
1027 }
1028 return acceptableAdsList && acceptableAdsList.disabled == false &&
1029 privacyList && privacyList.disabled == false && showTrackingWarning;
Thomas Greiner 2017/09/15 16:15:24 Based on its name, the purpose of this function is
saroyanm 2017/09/15 18:37:35 Agree, Done.
1030 }
1031
1011 function populateLists() 1032 function populateLists()
1012 { 1033 {
1013 subscriptionsMap = Object.create(null); 1034 subscriptionsMap = Object.create(null);
1014 filtersMap = Object.create(null); 1035 filtersMap = Object.create(null);
1015 1036
1016 // Empty collections and lists 1037 // Empty collections and lists
1017 for (let property in collections) 1038 for (let property in collections)
1018 collections[property].clearAll(); 1039 collections[property].clearAll();
1019 1040
1020 ext.backgroundPage.sendMessage({ 1041 ext.backgroundPage.sendMessage({
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 updateSubscription(subscription); 1185 updateSubscription(subscription);
1165 break; 1186 break;
1166 case "downloading": 1187 case "downloading":
1167 case "downloadStatus": 1188 case "downloadStatus":
1168 case "homepage": 1189 case "homepage":
1169 case "lastDownload": 1190 case "lastDownload":
1170 case "title": 1191 case "title":
1171 updateSubscription(subscription); 1192 updateSubscription(subscription);
1172 break; 1193 break;
1173 case "added": 1194 case "added":
1174 if (subscription.url in subscriptionsMap) 1195 let url = subscription.url;
1196 if (url in subscriptionsMap)
1175 updateSubscription(subscription); 1197 updateSubscription(subscription);
1176 else 1198 else
1177 addSubscription(subscription); 1199 addSubscription(subscription);
1178 1200
1179 if (isAcceptableAds(subscription.url)) 1201 if (isAcceptableAds(url))
1180 setAcceptableAds(); 1202 setAcceptableAds();
1181 1203
1204 if (url == acceptableAdsUrl || subscription.recommended == "privacy")
1205 {
1206 if (hasPrivacyConflict())
1207 openDialog("tracking");
1208 }
1209
1182 collections.filterLists.addItem(subscription); 1210 collections.filterLists.addItem(subscription);
1183 break; 1211 break;
1184 case "removed": 1212 case "removed":
1185 if (subscription.recommended) 1213 if (subscription.recommended)
1186 { 1214 {
1187 subscription.disabled = true; 1215 subscription.disabled = true;
1188 onSubscriptionMessage("disabled", subscription); 1216 onSubscriptionMessage("disabled", subscription);
1189 } 1217 }
1190 else 1218 else
1191 { 1219 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 { 1275 {
1248 switch (key) 1276 switch (key)
1249 { 1277 {
1250 case "notifications_ignoredcategories": 1278 case "notifications_ignoredcategories":
1251 value = value.indexOf("*") == -1; 1279 value = value.indexOf("*") == -1;
1252 break; 1280 break;
1253 1281
1254 case "notifications_showui": 1282 case "notifications_showui":
1255 hidePref("notifications_ignoredcategories", !value); 1283 hidePref("notifications_ignoredcategories", !value);
1256 break; 1284 break;
1285
1286 case "ui_warn_tracking":
1287 showTrackingWarning = value;
1288 break;
1257 } 1289 }
1258 1290
1259 let checkbox = document.querySelector( 1291 let checkbox = document.querySelector(
1260 "[data-pref='" + key + "'] button[role='checkbox']" 1292 "[data-pref='" + key + "'] button[role='checkbox']"
1261 ); 1293 );
1262 if (checkbox) 1294 if (checkbox)
1263 checkbox.setAttribute("aria-checked", value); 1295 checkbox.setAttribute("aria-checked", value);
1264 } 1296 }
1265 1297
1266 function updateTooltips() 1298 function updateTooltips()
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 type: "app.listen", 1353 type: "app.listen",
1322 filter: ["addSubscription", "focusSection"] 1354 filter: ["addSubscription", "focusSection"]
1323 }); 1355 });
1324 ext.backgroundPage.sendMessage({ 1356 ext.backgroundPage.sendMessage({
1325 type: "filters.listen", 1357 type: "filters.listen",
1326 filter: ["added", "loaded", "removed"] 1358 filter: ["added", "loaded", "removed"]
1327 }); 1359 });
1328 ext.backgroundPage.sendMessage({ 1360 ext.backgroundPage.sendMessage({
1329 type: "prefs.listen", 1361 type: "prefs.listen",
1330 filter: ["notifications_ignoredcategories", "notifications_showui", 1362 filter: ["notifications_ignoredcategories", "notifications_showui",
1331 "show_devtools_panel", "shouldShowBlockElementMenu"] 1363 "show_devtools_panel", "shouldShowBlockElementMenu",
1364 "ui_warn_tracking"]
1332 }); 1365 });
1333 ext.backgroundPage.sendMessage({ 1366 ext.backgroundPage.sendMessage({
1334 type: "subscriptions.listen", 1367 type: "subscriptions.listen",
1335 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1368 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1336 "title", "downloadStatus", "downloading"] 1369 "title", "downloadStatus", "downloading"]
1337 }); 1370 });
1338 1371
1339 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1372 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1340 window.addEventListener("hashchange", onHashChange, false); 1373 window.addEventListener("hashchange", onHashChange, false);
1341 } 1374 }
OLDNEW
« new-options.html ('K') | « new-options.html ('k') | skin/new-options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld