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

Side by Side Diff: desktop-options.js

Issue 29609587: Issue 6031 - Implement Acceptable Ads notification (Closed)
Patch Set: Addressed Thomas comments Created Nov. 17, 2017, 4:03 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 10 matching lines...) Expand all
21 "use strict"; 21 "use strict";
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} = browser.i18n; 30 let {getMessage} = browser.i18n;
31 let {setElementText} = ext.i18n;
saroyanm 2017/11/17 16:10:39 Didin't we convert all ext. to browser. ? I'm not
Thomas Greiner 2017/11/20 18:36:05 No, we merely got rid of the abstraction layer for
saroyanm 2017/11/21 14:58:32 I like, import here, as it's somehow consistent wi
31 let customFilters = []; 32 let customFilters = [];
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"]
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 901
901 // General tab 902 // General tab
902 getDocLink("contribute", (link) => 903 getDocLink("contribute", (link) =>
903 { 904 {
904 E("contribute").href = link; 905 E("contribute").href = link;
905 }); 906 });
906 getDocLink("acceptable_ads_criteria", (link) => 907 getDocLink("acceptable_ads_criteria", (link) =>
907 { 908 {
908 setLinks("enable-acceptable-ads-description", link); 909 setLinks("enable-acceptable-ads-description", link);
909 }); 910 });
911 setElementText(E("tracking-warning-1"), "options_tracking_warning_1",
saroyanm 2017/11/17 16:10:39 Ideally I think we should be able to specify "tran
Thomas Greiner 2017/11/20 18:36:05 Let's wait for further cases where we'd need that.
saroyanm 2017/11/21 14:58:32 Agree.
912 [getMessage("common_feature_privacy_title"),
913 getMessage("options_acceptableAds_ads_label")]);
914 setElementText(E("tracking-warning-3"), "options_tracking_warning_3",
915 [getMessage("options_acceptableAds_privacy_label")]);
916
910 getDocLink("privacy_friendly_ads", (link) => 917 getDocLink("privacy_friendly_ads", (link) =>
911 { 918 {
912 E("enable-acceptable-ads-privacy-description").href = link; 919 E("enable-acceptable-ads-privacy-description").href = link;
913 }); 920 });
914 getDocLink("adblock_plus_{browser}_dnt", url => 921 getDocLink("adblock_plus_{browser}_dnt", url =>
915 { 922 {
916 setLinks("dnt", url); 923 setLinks("dnt", url);
917 }); 924 });
918 925
919 // Whitelisted tab 926 // Whitelisted tab
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 acceptableAdsPrivacy.setAttribute("aria-disabled", true); 1094 acceptableAdsPrivacy.setAttribute("aria-disabled", true);
1088 acceptableAdsPrivacy.setAttribute("tabindex", -1); 1095 acceptableAdsPrivacy.setAttribute("tabindex", -1);
1089 } 1096 }
1090 } 1097 }
1091 1098
1092 function isAcceptableAds(url) 1099 function isAcceptableAds(url)
1093 { 1100 {
1094 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1101 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1095 } 1102 }
1096 1103
1104 function hasPrivacyConflict()
1105 {
1106 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl];
1107 let privacyList = null;
1108 for (let url in subscriptionsMap)
1109 {
1110 let subscription = subscriptionsMap[url];
1111 if (subscription.recommended == "privacy")
1112 {
1113 privacyList = subscription;
1114 break;
1115 }
1116 }
1117 return acceptableAdsList && acceptableAdsList.disabled == false &&
1118 privacyList && privacyList.disabled == false;
1119 }
1120
1097 function populateLists() 1121 function populateLists()
1098 { 1122 {
1099 subscriptionsMap = Object.create(null); 1123 subscriptionsMap = Object.create(null);
1100 filtersMap = Object.create(null); 1124 filtersMap = Object.create(null);
1101 1125
1102 // Empty collections and lists 1126 // Empty collections and lists
1103 for (let property in collections) 1127 for (let property in collections)
1104 collections[property].clearAll(); 1128 collections[property].clearAll();
1105 1129
1106 setCustomFiltersView("empty"); 1130 setCustomFiltersView("empty");
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 return; 1284 return;
1261 } 1285 }
1262 else if (url in subscriptionsMap) 1286 else if (url in subscriptionsMap)
1263 updateSubscription(subscription); 1287 updateSubscription(subscription);
1264 else 1288 else
1265 addSubscription(subscription); 1289 addSubscription(subscription);
1266 1290
1267 if (isAcceptableAds(url)) 1291 if (isAcceptableAds(url))
1268 setAcceptableAds(); 1292 setAcceptableAds();
1269 1293
1294 if ((url == acceptableAdsUrl || recommended == "privacy") &&
1295 hasPrivacyConflict())
1296 {
1297 getPref("ui_warn_tracking", (showTrackingWarning) =>
1298 {
1299 if (showTrackingWarning)
1300 E("acceptable-ads").classList.add("show-warning");
1301 });
1302 }
1303
1270 collections.filterLists.addItem(subscription); 1304 collections.filterLists.addItem(subscription);
1271 break; 1305 break;
1272 case "removed": 1306 case "removed":
1273 if (subscription.recommended) 1307 if (subscription.recommended)
1274 { 1308 {
1275 subscription.disabled = true; 1309 subscription.disabled = true;
1276 onSubscriptionMessage("disabled", subscription); 1310 onSubscriptionMessage("disabled", subscription);
1277 } 1311 }
1278 else 1312 else
1279 { 1313 {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 { 1368 {
1335 switch (key) 1369 switch (key)
1336 { 1370 {
1337 case "notifications_ignoredcategories": 1371 case "notifications_ignoredcategories":
1338 value = value.indexOf("*") == -1; 1372 value = value.indexOf("*") == -1;
1339 break; 1373 break;
1340 1374
1341 case "notifications_showui": 1375 case "notifications_showui":
1342 hidePref("notifications_ignoredcategories", !value); 1376 hidePref("notifications_ignoredcategories", !value);
1343 break; 1377 break;
1378 case "ui_warn_tracking":
1379 if (!value)
saroyanm 2017/11/17 16:45:14 Does it make sense to check against value == false
Thomas Greiner 2017/11/20 18:36:05 I'd assume not. If we cannot load the setting, we
saroyanm 2017/11/21 14:58:32 I see an issue with strict equation(not sure if th
Thomas Greiner 2017/11/21 17:17:29 I don't understand what you mean but I'm fine with
1380 E("acceptable-ads").classList.remove("show-warning");
Thomas Greiner 2017/11/20 18:36:05 What if the value changes to `true`? We'd probably
saroyanm 2017/11/21 14:58:32 Agree. Done.
1381 break;
1344 } 1382 }
1345 1383
1346 let checkbox = document.querySelector( 1384 let checkbox = document.querySelector(
1347 "[data-pref='" + key + "'] button[role='checkbox']" 1385 "[data-pref='" + key + "'] button[role='checkbox']"
1348 ); 1386 );
1349 if (checkbox) 1387 if (checkbox)
1350 checkbox.setAttribute("aria-checked", value); 1388 checkbox.setAttribute("aria-checked", value);
1351 } 1389 }
1352 1390
1353 function updateTooltips() 1391 function updateTooltips()
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 type: "app.listen", 1446 type: "app.listen",
1409 filter: ["addSubscription", "focusSection"] 1447 filter: ["addSubscription", "focusSection"]
1410 }); 1448 });
1411 browser.runtime.sendMessage({ 1449 browser.runtime.sendMessage({
1412 type: "filters.listen", 1450 type: "filters.listen",
1413 filter: ["added", "loaded", "removed"] 1451 filter: ["added", "loaded", "removed"]
1414 }); 1452 });
1415 browser.runtime.sendMessage({ 1453 browser.runtime.sendMessage({
1416 type: "prefs.listen", 1454 type: "prefs.listen",
1417 filter: ["notifications_ignoredcategories", "notifications_showui", 1455 filter: ["notifications_ignoredcategories", "notifications_showui",
1418 "show_devtools_panel", "shouldShowBlockElementMenu"] 1456 "show_devtools_panel", "shouldShowBlockElementMenu",
1457 "ui_warn_tracking"]
1419 }); 1458 });
1420 browser.runtime.sendMessage({ 1459 browser.runtime.sendMessage({
1421 type: "subscriptions.listen", 1460 type: "subscriptions.listen",
1422 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1461 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1423 "title", "downloadStatus", "downloading"] 1462 "title", "downloadStatus", "downloading"]
1424 }); 1463 });
1425 1464
1426 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1465 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1427 window.addEventListener("hashchange", onHashChange, false); 1466 window.addEventListener("hashchange", onHashChange, false);
1428 } 1467 }
OLDNEW

Powered by Google App Engine
This is Rietveld