Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 acceptableAdsPrivacy.setAttribute("aria-disabled", true); | 1094 acceptableAdsPrivacy.setAttribute("aria-disabled", true); |
1095 acceptableAdsPrivacy.setAttribute("tabindex", -1); | 1095 acceptableAdsPrivacy.setAttribute("tabindex", -1); |
1096 } | 1096 } |
1097 } | 1097 } |
1098 | 1098 |
1099 function isAcceptableAds(url) | 1099 function isAcceptableAds(url) |
1100 { | 1100 { |
1101 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 1101 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; |
1102 } | 1102 } |
1103 | 1103 |
1104 function isConflictingSubscription(subscription) | |
1105 { | |
1106 return subscription.url == acceptableAdsUrl || | |
Thomas Greiner
2017/11/23 14:46:12
Suggestion: If you want you can pass an optional `
saroyanm
2017/11/23 16:41:37
Not sure if it will help much and it might complic
| |
1107 subscription.recommended == "privacy" | |
1108 } | |
1109 | |
1110 function hasPrivacyConflict() | 1104 function hasPrivacyConflict() |
Thomas Greiner
2017/11/23 14:46:12
I wouldn't mind keeping the privacy conflict check
saroyanm
2017/11/23 16:41:37
Agree, done.
| |
1111 { | 1105 { |
1112 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; | 1106 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; |
1113 let privacyList = null; | 1107 let privacyList = null; |
1114 for (let url in subscriptionsMap) | 1108 for (let url in subscriptionsMap) |
1115 { | 1109 { |
1116 let subscription = subscriptionsMap[url]; | 1110 let subscription = subscriptionsMap[url]; |
1117 if (subscription.recommended == "privacy") | 1111 if (subscription.recommended == "privacy") |
1118 { | 1112 { |
1119 privacyList = subscription; | 1113 privacyList = subscription; |
1120 break; | 1114 break; |
1121 } | 1115 } |
1122 } | 1116 } |
1123 return acceptableAdsList && acceptableAdsList.disabled == false && | 1117 return acceptableAdsList && acceptableAdsList.disabled == false && |
1124 privacyList && privacyList.disabled == false; | 1118 privacyList && privacyList.disabled == false; |
1119 } | |
1120 | |
1121 function setPrivacyConflict() | |
1122 { | |
1123 let acceptableAdsForm = E("acceptable-ads"); | |
1124 if (hasPrivacyConflict()) | |
1125 { | |
1126 getPref("ui_warn_tracking", (showTrackingWarning) => | |
1127 { | |
1128 acceptableAdsForm.classList.toggle("show-warning", showTrackingWarning); | |
1129 }); | |
1130 } | |
1131 else | |
1132 { | |
1133 acceptableAdsForm.classList.remove("show-warning"); | |
1134 } | |
1125 } | 1135 } |
1126 | 1136 |
1127 function populateLists() | 1137 function populateLists() |
1128 { | 1138 { |
1129 subscriptionsMap = Object.create(null); | 1139 subscriptionsMap = Object.create(null); |
1130 filtersMap = Object.create(null); | 1140 filtersMap = Object.create(null); |
1131 | 1141 |
1132 // Empty collections and lists | 1142 // Empty collections and lists |
1133 for (let property in collections) | 1143 for (let property in collections) |
1134 collections[property].clearAll(); | 1144 collections[property].clearAll(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1266 knownSubscription.originalTitle = subscription.title; | 1276 knownSubscription.originalTitle = subscription.title; |
1267 else | 1277 else |
1268 knownSubscription[property] = subscription[property]; | 1278 knownSubscription[property] = subscription[property]; |
1269 } | 1279 } |
1270 subscription = knownSubscription; | 1280 subscription = knownSubscription; |
1271 } | 1281 } |
1272 switch (action) | 1282 switch (action) |
1273 { | 1283 { |
1274 case "disabled": | 1284 case "disabled": |
1275 updateSubscription(subscription); | 1285 updateSubscription(subscription); |
1286 setPrivacyConflict(); | |
1276 break; | 1287 break; |
1277 case "downloading": | 1288 case "downloading": |
1278 case "downloadStatus": | 1289 case "downloadStatus": |
1279 case "homepage": | 1290 case "homepage": |
1280 case "lastDownload": | 1291 case "lastDownload": |
1281 case "title": | 1292 case "title": |
1282 updateSubscription(subscription); | 1293 updateSubscription(subscription); |
1283 break; | 1294 break; |
1284 case "added": | 1295 case "added": |
1285 let {url, recommended} = subscription; | 1296 let {url, recommended} = subscription; |
1286 // Handle custom subscription | 1297 // Handle custom subscription |
1287 if (/^~user/.test(url)) | 1298 if (/^~user/.test(url)) |
1288 { | 1299 { |
1289 loadCustomFilters(subscription.filters); | 1300 loadCustomFilters(subscription.filters); |
1290 return; | 1301 return; |
1291 } | 1302 } |
1292 else if (url in subscriptionsMap) | 1303 else if (url in subscriptionsMap) |
1293 updateSubscription(subscription); | 1304 updateSubscription(subscription); |
1294 else | 1305 else |
1295 addSubscription(subscription); | 1306 addSubscription(subscription); |
1296 | 1307 |
1297 if (isAcceptableAds(url)) | 1308 if (isAcceptableAds(url)) |
1298 setAcceptableAds(); | 1309 setAcceptableAds(); |
1299 | 1310 |
1300 if (isConflictingSubscription(subscription) && hasPrivacyConflict()) | |
1301 { | |
1302 getPref("ui_warn_tracking", (showTrackingWarning) => | |
1303 { | |
1304 if (showTrackingWarning) | |
1305 E("acceptable-ads").classList.add("show-warning"); | |
1306 }); | |
1307 } | |
1308 | |
1309 collections.filterLists.addItem(subscription); | 1311 collections.filterLists.addItem(subscription); |
1312 setPrivacyConflict(); | |
1310 break; | 1313 break; |
1311 case "removed": | 1314 case "removed": |
Thomas Greiner
2017/11/23 12:53:39
It's a shame we missed that in our last review so
saroyanm
2017/11/23 14:06:51
Right.
| |
1312 if (subscription.recommended) | 1315 if (subscription.recommended) |
1313 { | 1316 { |
1314 subscription.disabled = true; | 1317 subscription.disabled = true; |
1315 onSubscriptionMessage("disabled", subscription); | 1318 onSubscriptionMessage("disabled", subscription); |
1316 } | 1319 } |
1317 else | 1320 else |
1318 { | 1321 { |
1319 delete subscriptionsMap[subscription.url]; | 1322 delete subscriptionsMap[subscription.url]; |
1320 if (isAcceptableAds(subscription.url)) | 1323 if (isAcceptableAds(subscription.url)) |
1321 { | 1324 { |
1322 setAcceptableAds(); | 1325 setAcceptableAds(); |
1323 } | 1326 } |
1324 else | 1327 else |
1325 { | 1328 { |
1326 collections.more.removeItem(subscription); | 1329 collections.more.removeItem(subscription); |
1327 } | 1330 } |
1328 } | 1331 } |
1329 if (isConflictingSubscription(subscription)) | |
1330 { | |
1331 E("acceptable-ads").classList.remove("show-warning"); | |
1332 } | |
Thomas Greiner
2017/11/23 12:53:39
Why not instead introduce a function similar to `s
saroyanm
2017/11/23 14:06:51
Good point, done.
| |
1333 | 1332 |
1334 collections.filterLists.removeItem(subscription); | 1333 collections.filterLists.removeItem(subscription); |
1334 setPrivacyConflict(); | |
1335 break; | 1335 break; |
1336 } | 1336 } |
1337 } | 1337 } |
1338 | 1338 |
1339 function hidePref(key, value) | 1339 function hidePref(key, value) |
1340 { | 1340 { |
1341 let element = document.querySelector("[data-pref='" + key + "']"); | 1341 let element = document.querySelector("[data-pref='" + key + "']"); |
1342 if (element) | 1342 if (element) |
1343 element.setAttribute("aria-hidden", value); | 1343 element.setAttribute("aria-hidden", value); |
1344 } | 1344 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1379 switch (key) | 1379 switch (key) |
1380 { | 1380 { |
1381 case "notifications_ignoredcategories": | 1381 case "notifications_ignoredcategories": |
1382 value = value.indexOf("*") == -1; | 1382 value = value.indexOf("*") == -1; |
1383 break; | 1383 break; |
1384 | 1384 |
1385 case "notifications_showui": | 1385 case "notifications_showui": |
1386 hidePref("notifications_ignoredcategories", !value); | 1386 hidePref("notifications_ignoredcategories", !value); |
1387 break; | 1387 break; |
1388 case "ui_warn_tracking": | 1388 case "ui_warn_tracking": |
1389 let showWarning = (value && hasPrivacyConflict()); | 1389 setPrivacyConflict(); |
1390 E("acceptable-ads").classList.toggle("show-warning", showWarning); | |
1391 break; | 1390 break; |
1392 } | 1391 } |
1393 | 1392 |
1394 let checkbox = document.querySelector( | 1393 let checkbox = document.querySelector( |
1395 "[data-pref='" + key + "'] button[role='checkbox']" | 1394 "[data-pref='" + key + "'] button[role='checkbox']" |
1396 ); | 1395 ); |
1397 if (checkbox) | 1396 if (checkbox) |
1398 checkbox.setAttribute("aria-checked", value); | 1397 checkbox.setAttribute("aria-checked", value); |
1399 } | 1398 } |
1400 | 1399 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1468 }); | 1467 }); |
1469 browser.runtime.sendMessage({ | 1468 browser.runtime.sendMessage({ |
1470 type: "subscriptions.listen", | 1469 type: "subscriptions.listen", |
1471 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1470 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1472 "title", "downloadStatus", "downloading"] | 1471 "title", "downloadStatus", "downloading"] |
1473 }); | 1472 }); |
1474 | 1473 |
1475 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1474 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1476 window.addEventListener("hashchange", onHashChange, false); | 1475 window.addEventListener("hashchange", onHashChange, false); |
1477 } | 1476 } |
LEFT | RIGHT |