 Issue 29519669:
  Issue 5539 - Implement "Acceptable Ads notification"  (Closed)
    
  
    Issue 29519669:
  Issue 5539 - Implement "Acceptable Ads notification"  (Closed) 
  | Index: new-options.js | 
| =================================================================== | 
| --- a/new-options.js | 
| +++ b/new-options.js | 
| @@ -29,6 +29,7 @@ | 
| let isCustomFiltersLoaded = false; | 
| let {getMessage} = ext.i18n; | 
| let customFilters = []; | 
| + let showTrackingWarning = false; | 
| let filterErrors = new Map([ | 
| ["synchronize_invalid_url", | 
| "options_filterList_lastDownload_invalidURL"], | 
| @@ -626,7 +627,7 @@ | 
| }); | 
| break; | 
| case "switch-acceptable-ads": | 
| - let {value} = element; | 
| + let value = element.value || element.dataset.value; | 
| ext.backgroundPage.sendMessage({ | 
| type: value == "privacy" ? "subscriptions.add" : | 
| "subscriptions.remove", | 
| @@ -839,7 +840,10 @@ | 
| E("whitelisting-add-button").disabled = !e.target.value; | 
| }, false); | 
| - | 
| + getPref("ui_warn_tracking", (value) => | 
| + { | 
| + showTrackingWarning = value; | 
| + }); | 
| getDocLink("contribute", (link) => | 
| { | 
| E("contribute").href = link; | 
| @@ -1008,6 +1012,23 @@ | 
| return url == acceptableAdsUrl || url == acceptableAdsPrivacyUrl; | 
| } | 
| + function hasPrivacyConflict() | 
| + { | 
| + let acceptableAdsList = subscriptionsMap[acceptableAdsUrl]; | 
| + let privacyList = null; | 
| + for (let url in subscriptionsMap) | 
| + { | 
| + let subscription = subscriptionsMap[url]; | 
| + if (subscription.recommended == "privacy") | 
| + { | 
| + privacyList = subscription; | 
| + break; | 
| + } | 
| + } | 
| + return acceptableAdsList && acceptableAdsList.disabled == false && | 
| + privacyList && privacyList.disabled == false; | 
| + } | 
| + | 
| function populateLists() | 
| { | 
| subscriptionsMap = Object.create(null); | 
| @@ -1171,14 +1192,21 @@ | 
| updateSubscription(subscription); | 
| break; | 
| case "added": | 
| - if (subscription.url in subscriptionsMap) | 
| + let url = subscription.url; | 
| + if (url in subscriptionsMap) | 
| updateSubscription(subscription); | 
| else | 
| addSubscription(subscription); | 
| - if (isAcceptableAds(subscription.url)) | 
| + if (isAcceptableAds(url)) | 
| setAcceptableAds(); | 
| + if (url == acceptableAdsUrl || subscription.recommended == "privacy") | 
| + { | 
| + if (hasPrivacyConflict() && showTrackingWarning) | 
| 
Thomas Greiner
2017/09/20 12:44:10
`getPref("ui_warn_tracking")` may not have returne
 
saroyanm
2017/09/21 15:50:40
I tried using Promises, but noticed that it didn't
 | 
| + openDialog("tracking"); | 
| + } | 
| + | 
| collections.filterLists.addItem(subscription); | 
| break; | 
| case "removed": | 
| @@ -1254,6 +1282,10 @@ | 
| case "notifications_showui": | 
| hidePref("notifications_ignoredcategories", !value); | 
| break; | 
| + | 
| + case "ui_warn_tracking": | 
| + showTrackingWarning = value; | 
| + break; | 
| } | 
| let checkbox = document.querySelector( | 
| @@ -1328,7 +1360,8 @@ | 
| ext.backgroundPage.sendMessage({ | 
| type: "prefs.listen", | 
| filter: ["notifications_ignoredcategories", "notifications_showui", | 
| - "show_devtools_panel", "shouldShowBlockElementMenu"] | 
| + "show_devtools_panel", "shouldShowBlockElementMenu", | 
| + "ui_warn_tracking"] | 
| }); | 
| ext.backgroundPage.sendMessage({ | 
| type: "subscriptions.listen", |