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

Delta Between Two Patch Sets: desktop-options.js

Issue 29615620: issue 6075 - Hide Acceptable Ads notification when corresponding subscription is removed (Closed)
Left Patch Set: Addressed Thomas comments Created Nov. 23, 2017, 2:03 p.m.
Right Patch Set: Fixed characters limit Created Nov. 23, 2017, 5 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 setPrivacyConflict() 1104 function hasPrivacyConflict()
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 E("acceptable-ads").classList.remove("show-warning"); 1117 return acceptableAdsList && acceptableAdsList.disabled == false &&
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 if (acceptableAdsList && acceptableAdsList.disabled == false && 1118 privacyList && privacyList.disabled == false;
1119 privacyList && privacyList.disabled == false) 1119 }
1120
1121 function setPrivacyConflict()
1122 {
1123 let acceptableAdsForm = E("acceptable-ads");
1124 if (hasPrivacyConflict())
1120 { 1125 {
1121 getPref("ui_warn_tracking", (showTrackingWarning) => 1126 getPref("ui_warn_tracking", (showTrackingWarning) =>
1122 { 1127 {
1123 if (showTrackingWarning) 1128 acceptableAdsForm.classList.toggle("show-warning", showTrackingWarning);
1124 E("acceptable-ads").classList.add("show-warning");
1125 }); 1129 });
1130 }
1131 else
1132 {
1133 acceptableAdsForm.classList.remove("show-warning");
1126 } 1134 }
1127 } 1135 }
1128 1136
1129 function populateLists() 1137 function populateLists()
1130 { 1138 {
1131 subscriptionsMap = Object.create(null); 1139 subscriptionsMap = Object.create(null);
1132 filtersMap = Object.create(null); 1140 filtersMap = Object.create(null);
1133 1141
1134 // Empty collections and lists 1142 // Empty collections and lists
1135 for (let property in collections) 1143 for (let property in collections)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 if (property == "title" && knownSubscription.recommended) 1275 if (property == "title" && knownSubscription.recommended)
1268 knownSubscription.originalTitle = subscription.title; 1276 knownSubscription.originalTitle = subscription.title;
1269 else 1277 else
1270 knownSubscription[property] = subscription[property]; 1278 knownSubscription[property] = subscription[property];
1271 } 1279 }
1272 subscription = knownSubscription; 1280 subscription = knownSubscription;
1273 } 1281 }
1274 switch (action) 1282 switch (action)
1275 { 1283 {
1276 case "disabled": 1284 case "disabled":
1285 updateSubscription(subscription);
1277 setPrivacyConflict(); 1286 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.
1278 updateSubscription(subscription);
1279 break; 1287 break;
1280 case "downloading": 1288 case "downloading":
1281 case "downloadStatus": 1289 case "downloadStatus":
1282 case "homepage": 1290 case "homepage":
1283 case "lastDownload": 1291 case "lastDownload":
1284 case "title": 1292 case "title":
1285 updateSubscription(subscription); 1293 updateSubscription(subscription);
1286 break; 1294 break;
1287 case "added": 1295 case "added":
1288 let {url, recommended} = subscription; 1296 let {url, recommended} = subscription;
1289 // Handle custom subscription 1297 // Handle custom subscription
1290 if (/^~user/.test(url)) 1298 if (/^~user/.test(url))
1291 { 1299 {
1292 loadCustomFilters(subscription.filters); 1300 loadCustomFilters(subscription.filters);
1293 return; 1301 return;
1294 } 1302 }
1295 else if (url in subscriptionsMap) 1303 else if (url in subscriptionsMap)
1296 updateSubscription(subscription); 1304 updateSubscription(subscription);
1297 else 1305 else
1298 addSubscription(subscription); 1306 addSubscription(subscription);
1299 1307
1300 if (isAcceptableAds(url)) 1308 if (isAcceptableAds(url))
1301 setAcceptableAds(); 1309 setAcceptableAds();
1302 1310
1311 collections.filterLists.addItem(subscription);
1303 setPrivacyConflict(); 1312 setPrivacyConflict();
1304 collections.filterLists.addItem(subscription);
1305 break; 1313 break;
1306 case "removed": 1314 case "removed":
1307 if (subscription.recommended) 1315 if (subscription.recommended)
1308 { 1316 {
1309 subscription.disabled = true; 1317 subscription.disabled = true;
1310 onSubscriptionMessage("disabled", subscription); 1318 onSubscriptionMessage("disabled", subscription);
1311 } 1319 }
1312 else 1320 else
1313 { 1321 {
1314 delete subscriptionsMap[subscription.url]; 1322 delete subscriptionsMap[subscription.url];
1315 if (isAcceptableAds(subscription.url)) 1323 if (isAcceptableAds(subscription.url))
1316 { 1324 {
1317 setAcceptableAds(); 1325 setAcceptableAds();
1318 } 1326 }
1319 else 1327 else
1320 { 1328 {
1321 collections.more.removeItem(subscription); 1329 collections.more.removeItem(subscription);
1322 } 1330 }
1323 } 1331 }
1324 1332
1333 collections.filterLists.removeItem(subscription);
1325 setPrivacyConflict(); 1334 setPrivacyConflict();
1326 collections.filterLists.removeItem(subscription);
1327 break; 1335 break;
1328 } 1336 }
1329 } 1337 }
1330 1338
1331 function hidePref(key, value) 1339 function hidePref(key, value)
1332 { 1340 {
1333 let element = document.querySelector("[data-pref='" + key + "']"); 1341 let element = document.querySelector("[data-pref='" + key + "']");
1334 if (element) 1342 if (element)
1335 element.setAttribute("aria-hidden", value); 1343 element.setAttribute("aria-hidden", value);
1336 } 1344 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 }); 1467 });
1460 browser.runtime.sendMessage({ 1468 browser.runtime.sendMessage({
1461 type: "subscriptions.listen", 1469 type: "subscriptions.listen",
1462 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1470 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1463 "title", "downloadStatus", "downloading"] 1471 "title", "downloadStatus", "downloading"]
1464 }); 1472 });
1465 1473
1466 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1474 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1467 window.addEventListener("hashchange", onHashChange, false); 1475 window.addEventListener("hashchange", onHashChange, false);
1468 } 1476 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld