From f398701fb63adca72a9dae974e3b0b6f503c991d Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 25 Oct 2018 16:52:26 +0000 Subject: [PATCH] Bug 1501286 - Part 1: Remove support for the tracking protection UI from Preferences r=flod,johannh Differential Revision: https://phabricator.services.mozilla.com/D9519 --HG-- extra : moz-landing-system : lando --- .../in-content/extensionControlled.js | 15 +-- .../preferences/in-content/privacy.js | 125 ++++-------------- .../preferences/in-content/privacy.xul | 46 +------ .../tests/browser_contentblocking.js | 22 --- .../tests/browser_extension_controlled.js | 72 ++-------- ..._search_subdialogs_within_preferences_6.js | 9 -- ...subdialogs_within_preferences_site_data.js | 37 ------ .../in-content/tests/browser_spotlight.js | 1 - .../en-US/browser/preferences/preferences.ftl | 26 ---- .../shared/incontentprefs/preferences.inc.css | 8 -- 10 files changed, 45 insertions(+), 316 deletions(-) diff --git a/browser/components/preferences/in-content/extensionControlled.js b/browser/components/preferences/in-content/extensionControlled.js index 8e1ab433a414..0d484454e765 100644 --- a/browser/components/preferences/in-content/extensionControlled.js +++ b/browser/components/preferences/in-content/extensionControlled.js @@ -17,9 +17,6 @@ ChromeUtils.defineModuleGetter(this, "DeferredTask", ChromeUtils.defineModuleGetter(this, "ExtensionSettingsStore", "resource://gre/modules/ExtensionSettingsStore.jsm"); -XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingUiEnabled", - "browser.contentblocking.ui.enabled"); - const PREF_SETTING_TYPE = "prefs"; const PROXY_KEY = "proxy.settings"; const API_PROXY_PREFS = [ @@ -49,12 +46,8 @@ let extensionControlledContentIds = { "proxy.settings": "proxyExtensionContent", get "websites.trackingProtectionMode"() { return { - button: contentBlockingUiEnabled ? - "contentBlockingDisableTrackingProtectionExtension" : - "trackingProtectionExtensionContentButton", - section: contentBlockingUiEnabled ? - "contentBlockingTrackingProtectionExtensionContentLabel" : - "trackingProtectionExtensionContentLabel", + button: "contentBlockingDisableTrackingProtectionExtension", + section: "contentBlockingTrackingProtectionExtensionContentLabel", }; }, }; @@ -65,9 +58,7 @@ const extensionControlledL10nKeys = { "webNotificationsDisabled": "web-notifications", "defaultSearch": "default-search", "privacy.containers": "privacy-containers", - "websites.trackingProtectionMode": contentBlockingUiEnabled ? - "websites-content-blocking-all-trackers" : - "websites-tracking-protection-mode", + "websites.trackingProtectionMode": "websites-content-blocking-all-trackers", "proxy.settings": "proxy-config", }; diff --git a/browser/components/preferences/in-content/privacy.js b/browser/components/preferences/in-content/privacy.js index ea34eb236ae8..c6bdf04cb8b4 100644 --- a/browser/components/preferences/in-content/privacy.js +++ b/browser/components/preferences/in-content/privacy.js @@ -20,9 +20,6 @@ ChromeUtils.defineModuleGetter(this, "SiteDataManager", ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); -XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingUiEnabled", - "browser.contentblocking.ui.enabled"); - XPCOMUtils.defineLazyPreferenceGetter(this, "contentBlockingCookiesAndSiteDataRejectTrackersRecommended", "browser.contentblocking.cookies-site-data.ui.reject-trackers.recommended"); @@ -184,19 +181,6 @@ var gPrivacyPane = { */ _shouldPromptForRestart: true, - /** - * Initialize the tracking protection prefs and linkify its Learn More link. - */ - _initTrackingProtection() { - setEventListener("trackingProtectionRadioGroup", "command", - this.trackingProtectionWritePrefs); - setEventListener("changeBlockList", "command", this.showBlockLists); - - let link = document.getElementById("trackingProtectionLearnMore"); - let url = Services.urlFormatter.formatURLPref("app.support.baseURL") + "tracking-protection"; - link.setAttribute("href", url); - }, - /** * Update the tracking protection UI to deal with extension control. */ @@ -206,24 +190,15 @@ var gPrivacyPane = { function setInputsDisabledState(isControlled) { let disabled = isLocked || isControlled; - if (contentBlockingUiEnabled) { - let tpCheckbox = - document.getElementById("contentBlockingTrackingProtectionCheckbox"); - // Only enable the TP menu if content blocking and Detect All Trackers - // are enabled. - document.getElementById("trackingProtectionMenu").disabled = disabled || - !tpCheckbox.checked || - !contentBlockingEnabled; - // Only enable the TP category checkbox if content blocking is enabled. - tpCheckbox.disabled = disabled || !contentBlockingEnabled; - } else { - document.querySelectorAll("#trackingProtectionRadioGroup > radio") - .forEach((element) => { - element.disabled = disabled; - }); - document.querySelector("#trackingProtectionDesc > label") - .disabled = disabled; - } + let tpCheckbox = + document.getElementById("contentBlockingTrackingProtectionCheckbox"); + // Only enable the TP menu if content blocking and Detect All Trackers + // are enabled. + document.getElementById("trackingProtectionMenu").disabled = disabled || + !tpCheckbox.checked || + !contentBlockingEnabled; + // Only enable the TP category checkbox if content blocking is enabled. + tpCheckbox.disabled = disabled || !contentBlockingEnabled; // Notify observers that the TP UI has been updated. // This is needed since our tests need to be notified about the @@ -248,9 +223,7 @@ var gPrivacyPane = { * for tracking protection. */ _initTrackingProtectionExtensionControl() { - let disableButton = contentBlockingUiEnabled ? - "contentBlockingDisableTrackingProtectionExtension" : "disableTrackingProtectionExtension"; - setEventListener(disableButton, "command", + setEventListener("contentBlockingDisableTrackingProtectionExtension", "command", makeDisableControllingExtension( PREF_SETTING_TYPE, TRACKING_PROTECTION_KEY)); @@ -292,13 +265,8 @@ var gPrivacyPane = { this.initAutoStartPrivateBrowsingReverter(); this._initAutocomplete(); - /* Initialize Content Blocking / Tracking Protection */ - - if (contentBlockingUiEnabled) { - this.initContentBlocking(); - } else { - this._initTrackingProtection(); - } + /* Initialize Content Blocking */ + this.initContentBlocking(); this.trackingProtectionReadPrefs(); this.networkCookieBehaviorReadPrefs(); @@ -567,38 +535,13 @@ var gPrivacyPane = { }, /** - * Changes the visibility of elements in the TP/CB section depending on the - * content blocking UI pref. + * Changes the visibility of elements in the CB section depending on the + * content blocking UI prefs. */ updateContentBlockingVisibility() { - // First, update the content blocking UI. - let visibleState = { - "contentBlockingHeader": true, - "contentBlockingDescription": true, - "contentBlockingLearnMore": true, - "contentBlockingRestoreDefaults": true, - "contentBlockingCheckboxContainer": true, - "contentBlockingCategories": true, - - "trackingProtectionHeader": false, - "trackingProtectionDescription": false, - "trackingProtectionBox": false, - }; - for (let id in visibleState) { - document.getElementById(id).hidden = contentBlockingUiEnabled != visibleState[id]; - } - - if (contentBlockingUiEnabled) { - // Update the Do Not Track section to not mention "Tracking Protection". - let dntDefaultRadioItem = - document.querySelector("#doNotTrackRadioGroup > radio[value=false]"); - document.l10n.setAttributes( - dntDefaultRadioItem, "do-not-track-option-default-content-blocking"); - - // Potentially hide the global toggle. - document.getElementById("contentBlockingCheckboxContainer").hidden = - !Services.prefs.getBoolPref("browser.contentblocking.global-toggle.enabled", true); - } + // Potentially hide the global toggle. + document.getElementById("contentBlockingCheckboxContainer").hidden = + !Services.prefs.getBoolPref("browser.contentblocking.global-toggle.enabled", true); // Allow turning off the "(recommended)" label using a pref let blockCookiesFromTrackers = document.getElementById("blockCookiesFromTrackers"); @@ -688,23 +631,15 @@ var gPrivacyPane = { let enabledPref = Preferences.get("privacy.trackingprotection.enabled"); let pbmPref = Preferences.get("privacy.trackingprotection.pbmode.enabled"); let btpmPref = Preferences.get("browser.privacy.trackingprotection.menu"); - let tpControl, - tpCheckbox; - if (contentBlockingUiEnabled) { - tpControl = document.getElementById("trackingProtectionMenu"); - tpCheckbox = document.getElementById("contentBlockingTrackingProtectionCheckbox"); - } else { - tpControl = document.getElementById("trackingProtectionRadioGroup"); - } + let tpControl = document.getElementById("trackingProtectionMenu"); + let tpCheckbox = document.getElementById("contentBlockingTrackingProtectionCheckbox"); let savedMenuValue; - if (contentBlockingUiEnabled) { - // Only look at the backup pref when restoring the checkbox next to - // "All Detected Trackers". - if (["always", "private"].includes(btpmPref.value) && - tpCheckbox.checked) { - savedMenuValue = btpmPref.value; - } + // Only look at the backup pref when restoring the checkbox next to + // "All Detected Trackers". + if (["always", "private"].includes(btpmPref.value) && + tpCheckbox.checked) { + savedMenuValue = btpmPref.value; } this._updateTrackingProtectionUI(); @@ -741,7 +676,7 @@ var gPrivacyPane = { let keepUntilLabel = document.getElementById("keepUntil"); let keepUntilMenu = document.getElementById("keepCookiesUntil"); - let disabledByCB = contentBlockingUiEnabled ? !contentBlockingEnabled : false; + let disabledByCB = !contentBlockingEnabled; let blockCookies = (behavior != 0); let cookieBehaviorLocked = Services.prefs.prefIsLocked("network.cookie.cookieBehavior"); let blockCookiesControlsDisabled = !blockCookies || cookieBehaviorLocked || disabledByCB; @@ -784,14 +719,8 @@ var gPrivacyPane = { let enabledPref = Preferences.get("privacy.trackingprotection.enabled"); let pbmPref = Preferences.get("privacy.trackingprotection.pbmode.enabled"); let btpmPref = Preferences.get("browser.privacy.trackingprotection.menu"); - let tpControl, - tpCheckbox; - if (contentBlockingUiEnabled) { - tpControl = document.getElementById("trackingProtectionMenu"); - tpCheckbox = document.getElementById("contentBlockingTrackingProtectionCheckbox"); - } else { - tpControl = document.getElementById("trackingProtectionRadioGroup"); - } + let tpControl = document.getElementById("trackingProtectionMenu"); + let tpCheckbox = document.getElementById("contentBlockingTrackingProtectionCheckbox"); let value; if (tpCheckbox) { diff --git a/browser/components/preferences/in-content/privacy.xul b/browser/components/preferences/in-content/privacy.xul index f14f192c3fe7..8828969a3903 100644 --- a/browser/components/preferences/in-content/privacy.xul +++ b/browser/components/preferences/in-content/privacy.xul @@ -19,15 +19,11 @@