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

Unified Diff: new-options.js

Issue 29519669: Issue 5539 - Implement "Acceptable Ads notification" (Closed)
Patch Set: Rebased Created Sept. 18, 2017, 10:40 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « new-options.html ('k') | skin/new-options.css » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"],
@@ -627,7 +628,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",
@@ -840,7 +841,10 @@
E("whitelisting-add-button").disabled = !e.target.value;
}, false);
-
+ getPref("ui_warn_tracking", (value) =>
+ {
+ showTrackingWarning = value;
+ });
getDocLink("contribute", (link) =>
{
E("contribute").href = link;
@@ -1009,6 +1013,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);
@@ -1172,14 +1193,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)
+ openDialog("tracking");
+ }
+
collections.filterLists.addItem(subscription);
break;
case "removed":
@@ -1255,6 +1283,10 @@
case "notifications_showui":
hidePref("notifications_ignoredcategories", !value);
break;
+
+ case "ui_warn_tracking":
+ showTrackingWarning = value;
+ break;
}
let checkbox = document.querySelector(
@@ -1329,7 +1361,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",
« no previous file with comments | « new-options.html ('k') | skin/new-options.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld