Left: | ||
Right: |
OLD | NEW |
---|---|
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 hasPrivacyConflict() | 1104 function setPrivacyConflict() |
1105 { | 1105 { |
1106 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; | 1106 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; |
1107 let privacyList = null; | 1107 let privacyList = null; |
1108 for (let url in subscriptionsMap) | 1108 for (let url in subscriptionsMap) |
1109 { | 1109 { |
1110 let subscription = subscriptionsMap[url]; | 1110 let subscription = subscriptionsMap[url]; |
1111 if (subscription.recommended == "privacy") | 1111 if (subscription.recommended == "privacy") |
1112 { | 1112 { |
1113 privacyList = subscription; | 1113 privacyList = subscription; |
1114 break; | 1114 break; |
1115 } | 1115 } |
1116 } | 1116 } |
1117 return acceptableAdsList && acceptableAdsList.disabled == false && | 1117 E("acceptable-ads").classList.remove("show-warning"); |
Thomas Greiner
2017/11/23 14:46:12
Detail: We can avoid this unnecessary call by movi
saroyanm
2017/11/23 16:41:38
I agree, well spotted, done.
| |
1118 privacyList && privacyList.disabled == false; | 1118 if (acceptableAdsList && acceptableAdsList.disabled == false && |
1119 privacyList && privacyList.disabled == false) | |
1120 { | |
1121 getPref("ui_warn_tracking", (showTrackingWarning) => | |
1122 { | |
1123 if (showTrackingWarning) | |
1124 E("acceptable-ads").classList.add("show-warning"); | |
1125 }); | |
1126 } | |
1119 } | 1127 } |
1120 | 1128 |
1121 function populateLists() | 1129 function populateLists() |
1122 { | 1130 { |
1123 subscriptionsMap = Object.create(null); | 1131 subscriptionsMap = Object.create(null); |
1124 filtersMap = Object.create(null); | 1132 filtersMap = Object.create(null); |
1125 | 1133 |
1126 // Empty collections and lists | 1134 // Empty collections and lists |
1127 for (let property in collections) | 1135 for (let property in collections) |
1128 collections[property].clearAll(); | 1136 collections[property].clearAll(); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1259 if (property == "title" && knownSubscription.recommended) | 1267 if (property == "title" && knownSubscription.recommended) |
1260 knownSubscription.originalTitle = subscription.title; | 1268 knownSubscription.originalTitle = subscription.title; |
1261 else | 1269 else |
1262 knownSubscription[property] = subscription[property]; | 1270 knownSubscription[property] = subscription[property]; |
1263 } | 1271 } |
1264 subscription = knownSubscription; | 1272 subscription = knownSubscription; |
1265 } | 1273 } |
1266 switch (action) | 1274 switch (action) |
1267 { | 1275 { |
1268 case "disabled": | 1276 case "disabled": |
1277 setPrivacyConflict(); | |
Thomas Greiner
2017/11/23 14:46:12
Detail: Let's do this after we've updated the UI.
saroyanm
2017/11/23 16:41:38
DOne.
| |
1269 updateSubscription(subscription); | 1278 updateSubscription(subscription); |
1270 break; | 1279 break; |
1271 case "downloading": | 1280 case "downloading": |
1272 case "downloadStatus": | 1281 case "downloadStatus": |
1273 case "homepage": | 1282 case "homepage": |
1274 case "lastDownload": | 1283 case "lastDownload": |
1275 case "title": | 1284 case "title": |
1276 updateSubscription(subscription); | 1285 updateSubscription(subscription); |
1277 break; | 1286 break; |
1278 case "added": | 1287 case "added": |
1279 let {url, recommended} = subscription; | 1288 let {url, recommended} = subscription; |
1280 // Handle custom subscription | 1289 // Handle custom subscription |
1281 if (/^~user/.test(url)) | 1290 if (/^~user/.test(url)) |
1282 { | 1291 { |
1283 loadCustomFilters(subscription.filters); | 1292 loadCustomFilters(subscription.filters); |
1284 return; | 1293 return; |
1285 } | 1294 } |
1286 else if (url in subscriptionsMap) | 1295 else if (url in subscriptionsMap) |
1287 updateSubscription(subscription); | 1296 updateSubscription(subscription); |
1288 else | 1297 else |
1289 addSubscription(subscription); | 1298 addSubscription(subscription); |
1290 | 1299 |
1291 if (isAcceptableAds(url)) | 1300 if (isAcceptableAds(url)) |
1292 setAcceptableAds(); | 1301 setAcceptableAds(); |
1293 | 1302 |
1294 if ((url == acceptableAdsUrl || recommended == "privacy") && | 1303 setPrivacyConflict(); |
1295 hasPrivacyConflict()) | |
1296 { | |
1297 getPref("ui_warn_tracking", (showTrackingWarning) => | |
1298 { | |
1299 if (showTrackingWarning) | |
1300 E("acceptable-ads").classList.add("show-warning"); | |
1301 }); | |
1302 } | |
1303 | |
1304 collections.filterLists.addItem(subscription); | 1304 collections.filterLists.addItem(subscription); |
1305 break; | 1305 break; |
1306 case "removed": | 1306 case "removed": |
1307 if (subscription.recommended) | 1307 if (subscription.recommended) |
1308 { | 1308 { |
1309 subscription.disabled = true; | 1309 subscription.disabled = true; |
1310 onSubscriptionMessage("disabled", subscription); | 1310 onSubscriptionMessage("disabled", subscription); |
1311 } | 1311 } |
1312 else | 1312 else |
1313 { | 1313 { |
1314 delete subscriptionsMap[subscription.url]; | 1314 delete subscriptionsMap[subscription.url]; |
1315 if (isAcceptableAds(subscription.url)) | 1315 if (isAcceptableAds(subscription.url)) |
1316 { | 1316 { |
1317 setAcceptableAds(); | 1317 setAcceptableAds(); |
1318 } | 1318 } |
1319 else | 1319 else |
1320 { | 1320 { |
1321 collections.more.removeItem(subscription); | 1321 collections.more.removeItem(subscription); |
1322 } | 1322 } |
1323 } | 1323 } |
1324 | |
1325 setPrivacyConflict(); | |
1324 collections.filterLists.removeItem(subscription); | 1326 collections.filterLists.removeItem(subscription); |
1325 break; | 1327 break; |
1326 } | 1328 } |
1327 } | 1329 } |
1328 | 1330 |
1329 function hidePref(key, value) | 1331 function hidePref(key, value) |
1330 { | 1332 { |
1331 let element = document.querySelector("[data-pref='" + key + "']"); | 1333 let element = document.querySelector("[data-pref='" + key + "']"); |
1332 if (element) | 1334 if (element) |
1333 element.setAttribute("aria-hidden", value); | 1335 element.setAttribute("aria-hidden", value); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1369 switch (key) | 1371 switch (key) |
1370 { | 1372 { |
1371 case "notifications_ignoredcategories": | 1373 case "notifications_ignoredcategories": |
1372 value = value.indexOf("*") == -1; | 1374 value = value.indexOf("*") == -1; |
1373 break; | 1375 break; |
1374 | 1376 |
1375 case "notifications_showui": | 1377 case "notifications_showui": |
1376 hidePref("notifications_ignoredcategories", !value); | 1378 hidePref("notifications_ignoredcategories", !value); |
1377 break; | 1379 break; |
1378 case "ui_warn_tracking": | 1380 case "ui_warn_tracking": |
1379 let showWarning = (value && hasPrivacyConflict()); | 1381 setPrivacyConflict(); |
1380 E("acceptable-ads").classList.toggle("show-warning", showWarning); | |
1381 break; | 1382 break; |
1382 } | 1383 } |
1383 | 1384 |
1384 let checkbox = document.querySelector( | 1385 let checkbox = document.querySelector( |
1385 "[data-pref='" + key + "'] button[role='checkbox']" | 1386 "[data-pref='" + key + "'] button[role='checkbox']" |
1386 ); | 1387 ); |
1387 if (checkbox) | 1388 if (checkbox) |
1388 checkbox.setAttribute("aria-checked", value); | 1389 checkbox.setAttribute("aria-checked", value); |
1389 } | 1390 } |
1390 | 1391 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1458 }); | 1459 }); |
1459 browser.runtime.sendMessage({ | 1460 browser.runtime.sendMessage({ |
1460 type: "subscriptions.listen", | 1461 type: "subscriptions.listen", |
1461 filter: ["added", "disabled", "homepage", "lastDownload", "removed", | 1462 filter: ["added", "disabled", "homepage", "lastDownload", "removed", |
1462 "title", "downloadStatus", "downloading"] | 1463 "title", "downloadStatus", "downloading"] |
1463 }); | 1464 }); |
1464 | 1465 |
1465 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); | 1466 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); |
1466 window.addEventListener("hashchange", onHashChange, false); | 1467 window.addEventListener("hashchange", onHashChange, false); |
1467 } | 1468 } |
OLD | NEW |