Bug 1462470 - Part 3 - Show a "reload this page" warning in the control center when trackers are loaded while TP is on. r=paolo
Part 2 exposed an edge case that would allow the user to have TP enabled but
still have tracking content on a page, bringing our UI into a confused state.
This adds a new element that shows when TP is enabled and no exception is set,
but tracking content is still loaded, and recommends reloading the page.
MozReview-Commit-ID: EYy6xVCjNts
--- a/browser/base/content/browser-trackingprotection.js
+++ b/browser/base/content/browser-trackingprotection.js
@@ -69,16 +69,21 @@ var TrackingProtection = {
onGlobalToggleCommand() {
if (PrivateBrowsingUtils.isWindowPrivate(window)) {
Services.prefs.setBoolPref(this.PREF_ENABLED_IN_PRIVATE_WINDOWS, !this.enabledInPrivateWindows);
} else {
Services.prefs.setBoolPref(this.PREF_ENABLED_GLOBALLY, !this.enabledGlobally);
}
},
+ hideIdentityPopupAndReload() {
+ document.getElementById("identity-popup").hidePopup();
+ BrowserReload();
+ },
+
openPreferences(origin) {
openPreferences("privacy-trackingprotection", { origin });
},
updateEnabled() {
this.enabledGlobally =
Services.prefs.getBoolPref(this.PREF_ENABLED_GLOBALLY);
this.enabledInPrivateWindows =
@@ -210,20 +215,17 @@ var TrackingProtection = {
} else {
Services.perms.add(baseURI,
"trackingprotection", Services.perms.ALLOW_ACTION);
}
// Telemetry for disable protection.
this.eventsHistogramAdd(1);
- // Hide the control center.
- document.getElementById("identity-popup").hidePopup();
-
- BrowserReload();
+ this.hideIdentityPopupAndReload();
},
enableForCurrentPage() {
// If users are not clicking this link to unblock a specific exception,
// open the privacy settings to allow users to turn TP on globally. We might
// change this button to allow globally toggling the pref in the future.
if (!this.enabled) {
this.openPreferences("identityPopup-TP-action");
@@ -239,20 +241,17 @@ var TrackingProtection = {
PrivateBrowsingUtils.removeFromTrackingAllowlist(baseURI);
} else {
Services.perms.remove(baseURI, "trackingprotection");
}
// Telemetry for enable protection.
this.eventsHistogramAdd(2);
- // Hide the control center.
- document.getElementById("identity-popup").hidePopup();
-
- BrowserReload();
+ this.hideIdentityPopupAndReload();
},
dontShowIntroPanelAgain() {
// This function may be called in private windows, but it does not change
// any preference unless Tracking Protection is enabled globally.
if (this.enabledGlobally) {
Services.prefs.setIntPref("privacy.trackingprotection.introCount",
this.MAX_INTROS);
--- a/browser/components/controlcenter/content/panel.inc.xul
+++ b/browser/components/controlcenter/content/panel.inc.xul
@@ -67,17 +67,24 @@
value="&trackingProtection.off;" />
<description id="tracking-blocked"
crop="end">&trackingProtection.detectedBlocked3;</description>
<description id="tracking-loaded"
crop="end">&trackingProtection.detectedNotBlocked4;</description>
<description id="tracking-not-detected"
crop="end">&trackingProtection.notDetected4;</description>
+ <description id="tracking-reload-required"
+ crop="end">&trackingProtection.reloadRequired;</description>
+ <button id="tracking-action-reload"
+ class="tracking-protection-button"
+ label="&trackingProtection.reload.label;"
+ accesskey="&trackingProtection.reload.accesskey;"
+ oncommand="TrackingProtection.hideIdentityPopupAndReload();" />
<button id="tracking-action-unblock"
class="tracking-protection-button"
label="&trackingProtection.unblock2.label;"
accesskey="&trackingProtection.unblock2.accesskey;"
oncommand="TrackingProtection.disableForCurrentPage();" />
<button id="tracking-action-unblock-private"
class="tracking-protection-button"
label="&trackingProtection.unblockPrivate2.label;"
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -899,28 +899,31 @@ you can use these alternative items. Oth
<!ENTITY trackingProtection.on "Tracking Protection: ON">
<!ENTITY trackingProtection.off "Tracking Protection: OFF">
<!ENTITY trackingProtection.title "Tracking Protection">
<!ENTITY trackingProtection.tooltip "Open Tracking Protection Preferences">
<!ENTITY trackingProtection.detectedBlocked3 "&brandShortName; is blocking parts of the page that may track your browsing.">
<!ENTITY trackingProtection.detectedNotBlocked4 "Trackers have been detected on this webpage.">
<!ENTITY trackingProtection.notDetected4 "No trackers detected on this page.">
+<!ENTITY trackingProtection.reloadRequired "You have enabled Tracking Protection. To block all trackers please reload the current webpage.">
<!-- LOCALIZATION NOTE (trackingProtection.unblock.label, trackingProtection.unblock.accesskey):
The associated button with this label and accesskey is only shown when opening the control
center while looking at a site with trackers in NON-private browsing mode. -->
<!ENTITY trackingProtection.unblock2.label "Trust this site">
<!ENTITY trackingProtection.unblock2.accesskey "T">
<!-- LOCALIZATION NOTE (trackingProtection.unblockPrivate.label, trackingProtection.unblockPrivate.accesskey):
The associated button with this label and accesskey is only shown when opening the control
center while looking at a site with trackers in PRIVATE browsing mode. -->
<!ENTITY trackingProtection.unblockPrivate2.label "Trust this site for this session">
<!ENTITY trackingProtection.unblockPrivate2.accesskey "T">
<!ENTITY trackingProtection.block3.label "Turn Tracking Protection ON">
<!ENTITY trackingProtection.block3.accesskey "T">
+<!ENTITY trackingProtection.reload.label "Reload This Page">
+<!ENTITY trackingProtection.reload.accesskey "R">
<!ENTITY pluginNotification.showAll.label "Show All">
<!ENTITY pluginNotification.showAll.accesskey "S">
<!-- LOCALIZATION NOTE (pluginActivateNow.label, pluginActivateAlways.label, pluginBlockNow.label): These should be the same as the matching strings in browser.properties -->
<!ENTITY pluginActivateNow.label "Allow Now">
<!ENTITY pluginActivateAlways.label "Allow and Remember">
<!ENTITY pluginBlockNow.label "Block Plugin">
--- a/browser/themes/shared/controlcenter/panel.inc.css
+++ b/browser/themes/shared/controlcenter/panel.inc.css
@@ -319,16 +319,19 @@ description#identity-popup-content-verif
/* Show the right tracking descriptions and buttons for the corresponding state. */
/* Default state / Tracking not detected */
#tracking-protection-content:not([state]) > #tracking-not-detected,
/* Blocking tracking, offer buttons to unblock (depending on PBM). */
#tracking-protection-content[state="blocked-tracking-content"] > #tracking-blocked,
#main-window:not([privatebrowsingmode]) #tracking-protection-content[state="blocked-tracking-content"] > #tracking-action-unblock,
#main-window[privatebrowsingmode] #tracking-protection-content[state="blocked-tracking-content"] > #tracking-action-unblock-private,
+/* Enabled and no exception but trackers loaded, probably needs a reload */
+#tracking-protection-content[enabled="true"]:not([hasException])[state="loaded-tracking-content"] > #tracking-reload-required,
+#tracking-protection-content[enabled="true"]:not([hasException])[state="loaded-tracking-content"] > #tracking-action-reload,
/* Disabled or has an exception, offer to block the site. */
#tracking-protection-content[state="loaded-tracking-content"]:-moz-any([enabled="false"],[hasException]) > #tracking-loaded,
#tracking-protection-content[state="loaded-tracking-content"]:-moz-any([enabled="false"],[hasException]) > #tracking-action-block {
display: -moz-box;
}
/* PERMISSIONS */