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: Created Nov. 15, 2017, 5:01 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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 break; 600 break;
601 case "edit-custom-filters": 601 case "edit-custom-filters":
602 setCustomFiltersView("write"); 602 setCustomFiltersView("write");
603 break; 603 break;
604 case "hide-more-filters-section": 604 case "hide-more-filters-section":
605 E("more-filters").setAttribute("aria-hidden", true); 605 E("more-filters").setAttribute("aria-hidden", true);
606 break; 606 break;
607 case "hide-notification": 607 case "hide-notification":
608 hideNotification(); 608 hideNotification();
609 break; 609 break;
610 case "hide-tracking-notification":
611 E("acceptable-ads").classList.remove("show-notification");
Thomas Greiner 2017/11/16 19:25:05 Let's remove this action and instead react to chan
saroyanm 2017/11/17 16:10:38 I agree, done.
612 break;
610 case "import-subscription": { 613 case "import-subscription": {
611 let url = E("blockingList-textbox").value; 614 let url = E("blockingList-textbox").value;
612 addEnableSubscription(url); 615 addEnableSubscription(url);
613 closeDialog(); 616 closeDialog();
614 break; 617 break;
615 } 618 }
616 case "open-context-menu": { 619 case "open-context-menu": {
617 let listItem = findParentData(element, "access", true); 620 let listItem = findParentData(element, "access", true);
618 if (listItem && !listItem.classList.contains("show-context-menu")) 621 if (listItem && !listItem.classList.contains("show-context-menu"))
619 listItem.classList.add("show-context-menu"); 622 listItem.classList.add("show-context-menu");
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 acceptableAdsPrivacy.setAttribute("aria-disabled", true); 1090 acceptableAdsPrivacy.setAttribute("aria-disabled", true);
1088 acceptableAdsPrivacy.setAttribute("tabindex", -1); 1091 acceptableAdsPrivacy.setAttribute("tabindex", -1);
1089 } 1092 }
1090 } 1093 }
1091 1094
1092 function isAcceptableAds(url) 1095 function isAcceptableAds(url)
1093 { 1096 {
1094 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; 1097 return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl;
1095 } 1098 }
1096 1099
1100 function hasPrivacyConflict()
1101 {
1102 let acceptableAdsList = subscriptionsMap[acceptableAdsUrl];
1103 let privacyList = null;
1104 for (let url in subscriptionsMap)
1105 {
1106 let subscription = subscriptionsMap[url];
1107 if (subscription.recommended == "privacy")
1108 {
1109 privacyList = subscription;
1110 break;
1111 }
1112 }
1113 return acceptableAdsList && acceptableAdsList.disabled == false &&
1114 privacyList && privacyList.disabled == false;
1115 }
1116
1097 function populateLists() 1117 function populateLists()
1098 { 1118 {
1099 subscriptionsMap = Object.create(null); 1119 subscriptionsMap = Object.create(null);
1100 filtersMap = Object.create(null); 1120 filtersMap = Object.create(null);
1101 1121
1102 // Empty collections and lists 1122 // Empty collections and lists
1103 for (let property in collections) 1123 for (let property in collections)
1104 collections[property].clearAll(); 1124 collections[property].clearAll();
1105 1125
1106 setCustomFiltersView("empty"); 1126 setCustomFiltersView("empty");
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 return; 1280 return;
1261 } 1281 }
1262 else if (url in subscriptionsMap) 1282 else if (url in subscriptionsMap)
1263 updateSubscription(subscription); 1283 updateSubscription(subscription);
1264 else 1284 else
1265 addSubscription(subscription); 1285 addSubscription(subscription);
1266 1286
1267 if (isAcceptableAds(url)) 1287 if (isAcceptableAds(url))
1268 setAcceptableAds(); 1288 setAcceptableAds();
1269 1289
1290 if ((url == acceptableAdsUrl || recommended == "privacy") &&
1291 hasPrivacyConflict())
1292 {
1293 getPref("ui_warn_tracking", (showTrackingWarning) =>
1294 {
1295 if (showTrackingWarning)
1296 E("acceptable-ads").classList.add("show-notification");
1297 });
1298 }
1299
1270 collections.filterLists.addItem(subscription); 1300 collections.filterLists.addItem(subscription);
1271 break; 1301 break;
1272 case "removed": 1302 case "removed":
1273 if (subscription.recommended) 1303 if (subscription.recommended)
1274 { 1304 {
1275 subscription.disabled = true; 1305 subscription.disabled = true;
1276 onSubscriptionMessage("disabled", subscription); 1306 onSubscriptionMessage("disabled", subscription);
1277 } 1307 }
1278 else 1308 else
1279 { 1309 {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 type: "app.listen", 1438 type: "app.listen",
1409 filter: ["addSubscription", "focusSection"] 1439 filter: ["addSubscription", "focusSection"]
1410 }); 1440 });
1411 browser.runtime.sendMessage({ 1441 browser.runtime.sendMessage({
1412 type: "filters.listen", 1442 type: "filters.listen",
1413 filter: ["added", "loaded", "removed"] 1443 filter: ["added", "loaded", "removed"]
1414 }); 1444 });
1415 browser.runtime.sendMessage({ 1445 browser.runtime.sendMessage({
1416 type: "prefs.listen", 1446 type: "prefs.listen",
1417 filter: ["notifications_ignoredcategories", "notifications_showui", 1447 filter: ["notifications_ignoredcategories", "notifications_showui",
1418 "show_devtools_panel", "shouldShowBlockElementMenu"] 1448 "show_devtools_panel", "shouldShowBlockElementMenu",
1449 "ui_warn_tracking"]
1419 }); 1450 });
1420 browser.runtime.sendMessage({ 1451 browser.runtime.sendMessage({
1421 type: "subscriptions.listen", 1452 type: "subscriptions.listen",
1422 filter: ["added", "disabled", "homepage", "lastDownload", "removed", 1453 filter: ["added", "disabled", "homepage", "lastDownload", "removed",
1423 "title", "downloadStatus", "downloading"] 1454 "title", "downloadStatus", "downloading"]
1424 }); 1455 });
1425 1456
1426 window.addEventListener("DOMContentLoaded", onDOMLoaded, false); 1457 window.addEventListener("DOMContentLoaded", onDOMLoaded, false);
1427 window.addEventListener("hashchange", onHashChange, false); 1458 window.addEventListener("hashchange", onHashChange, false);
1428 } 1459 }
OLDNEW

Powered by Google App Engine
This is Rietveld