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

Side by Side Diff: desktop-options.js

Issue 29615620: issue 6075 - Hide Acceptable Ads notification when corresponding subscription is removed (Closed)
Patch Set: Addressed Thomas comments Created Nov. 23, 2017, 4:36 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 return acceptableAdsList && acceptableAdsList.disabled == false &&
1118 privacyList && privacyList.disabled == false; 1118 privacyList && privacyList.disabled == false;
1119 } 1119 }
1120 1120
1121 function setPrivacyConflict()
1122 {
1123 if (hasPrivacyConflict())
1124 {
1125 getPref("ui_warn_tracking", (showTrackingWarning) =>
1126 {
1127 E("acceptable-ads").classList.toggle("show-warning", showTrackingWarning );
Thomas Greiner 2017/11/23 16:51:30 Coding style: "Line length: 80 characters or less"
saroyanm 2017/11/23 17:01:38 Agree, we used "acceptableAdsForm" below so I'll u
1128 });
1129 }
1130 else
1131 {
1132 E("acceptable-ads").classList.remove("show-warning");
1133 }
1134 }
1135
1121 function populateLists() 1136 function populateLists()
1122 { 1137 {
1123 subscriptionsMap = Object.create(null); 1138 subscriptionsMap = Object.create(null);
1124 filtersMap = Object.create(null); 1139 filtersMap = Object.create(null);
1125 1140
1126 // Empty collections and lists 1141 // Empty collections and lists
1127 for (let property in collections) 1142 for (let property in collections)
1128 collections[property].clearAll(); 1143 collections[property].clearAll();
1129 1144
1130 setCustomFiltersView("empty"); 1145 setCustomFiltersView("empty");
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 knownSubscription.originalTitle = subscription.title; 1275 knownSubscription.originalTitle = subscription.title;
1261 else 1276 else
1262 knownSubscription[property] = subscription[property]; 1277 knownSubscription[property] = subscription[property];
1263 } 1278 }
1264 subscription = knownSubscription; 1279 subscription = knownSubscription;
1265 } 1280 }
1266 switch (action) 1281 switch (action)
1267 { 1282 {
1268 case "disabled": 1283 case "disabled":
1269 updateSubscription(subscription); 1284 updateSubscription(subscription);
1285 setPrivacyConflict();
1270 break; 1286 break;
1271 case "downloading": 1287 case "downloading":
1272 case "downloadStatus": 1288 case "downloadStatus":
1273 case "homepage": 1289 case "homepage":
1274 case "lastDownload": 1290 case "lastDownload":
1275 case "title": 1291 case "title":
1276 updateSubscription(subscription); 1292 updateSubscription(subscription);
1277 break; 1293 break;
1278 case "added": 1294 case "added":
1279 let {url, recommended} = subscription; 1295 let {url, recommended} = subscription;
1280 // Handle custom subscription 1296 // Handle custom subscription
1281 if (/^~user/.test(url)) 1297 if (/^~user/.test(url))
1282 { 1298 {
1283 loadCustomFilters(subscription.filters); 1299 loadCustomFilters(subscription.filters);
1284 return; 1300 return;
1285 } 1301 }
1286 else if (url in subscriptionsMap) 1302 else if (url in subscriptionsMap)
1287 updateSubscription(subscription); 1303 updateSubscription(subscription);
1288 else 1304 else
1289 addSubscription(subscription); 1305 addSubscription(subscription);
1290 1306
1291 if (isAcceptableAds(url)) 1307 if (isAcceptableAds(url))
1292 setAcceptableAds(); 1308 setAcceptableAds();
1293 1309
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
1304 collections.filterLists.addItem(subscription); 1310 collections.filterLists.addItem(subscription);
1311 setPrivacyConflict();
1305 break; 1312 break;
1306 case "removed": 1313 case "removed":
1307 if (subscription.recommended) 1314 if (subscription.recommended)
1308 { 1315 {
1309 subscription.disabled = true; 1316 subscription.disabled = true;
1310 onSubscriptionMessage("disabled", subscription); 1317 onSubscriptionMessage("disabled", subscription);
1311 } 1318 }
1312 else 1319 else
1313 { 1320 {
1314 delete subscriptionsMap[subscription.url]; 1321 delete subscriptionsMap[subscription.url];
1315 if (isAcceptableAds(subscription.url)) 1322 if (isAcceptableAds(subscription.url))
1316 { 1323 {
1317 setAcceptableAds(); 1324 setAcceptableAds();
1318 } 1325 }
1319 else 1326 else
1320 { 1327 {
1321 collections.more.removeItem(subscription); 1328 collections.more.removeItem(subscription);
1322 } 1329 }
1323 } 1330 }
1331
1324 collections.filterLists.removeItem(subscription); 1332 collections.filterLists.removeItem(subscription);
1333 setPrivacyConflict();
1325 break; 1334 break;
1326 } 1335 }
1327 } 1336 }
1328 1337
1329 function hidePref(key, value) 1338 function hidePref(key, value)
1330 { 1339 {
1331 let element = document.querySelector("[data-pref='" + key + "']"); 1340 let element = document.querySelector("[data-pref='" + key + "']");
1332 if (element) 1341 if (element)
1333 element.setAttribute("aria-hidden", value); 1342 element.setAttribute("aria-hidden", value);
1334 } 1343 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 switch (key) 1378 switch (key)
1370 { 1379 {
1371 case "notifications_ignoredcategories": 1380 case "notifications_ignoredcategories":
1372 value = value.indexOf("*") == -1; 1381 value = value.indexOf("*") == -1;
1373 break; 1382 break;
1374 1383
1375 case "notifications_showui": 1384 case "notifications_showui":
1376 hidePref("notifications_ignoredcategories", !value); 1385 hidePref("notifications_ignoredcategories", !value);
1377 break; 1386 break;
1378 case "ui_warn_tracking": 1387 case "ui_warn_tracking":
1379 let showWarning = (value && hasPrivacyConflict()); 1388 setPrivacyConflict();
1380 E("acceptable-ads").classList.toggle("show-warning", showWarning);
1381 break; 1389 break;
1382 } 1390 }
1383 1391
1384 let checkbox = document.querySelector( 1392 let checkbox = document.querySelector(
1385 "[data-pref='" + key + "'] button[role='checkbox']" 1393 "[data-pref='" + key + "'] button[role='checkbox']"
1386 ); 1394 );
1387 if (checkbox) 1395 if (checkbox)
1388 checkbox.setAttribute("aria-checked", value); 1396 checkbox.setAttribute("aria-checked", value);
1389 } 1397 }
1390 1398
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 }); 1466 });
1459 browser.runtime.sendMessage({ 1467 browser.runtime.sendMessage({
1460 type: "subscriptions.listen", 1468 type: "subscriptions.listen",
1461 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1469 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1462 "title", "downloadStatus", "downloading"] 1470 "title", "downloadStatus", "downloading"]
1463 }); 1471 });
1464 1472
1465 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1473 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1466 window.addEventListener("hashchange", onHashChange, false); 1474 window.addEventListener("hashchange", onHashChange, false);
1467 } 1475 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld