Bug 1501977 - Remove global Content Blocking toggle in the main menu. r=Ehsan
authorJohann Hofmann <jhofmann@mozilla.com>
Fri, 26 Oct 2018 18:09:06 +0000
changeset 443211 e1404c73b666d9b79bc7b103128f59c095d743b4
parent 443210 74a560ef3b51f2054faaf99182f7e4ef3978ab26
child 443212 8b72cee028cdd72074cc78870c21d145d954fac1
push id34944
push userncsoregi@mozilla.com
push dateSat, 27 Oct 2018 09:49:55 +0000
treeherdermozilla-central@49d47a692ca4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1501977
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1501977 - Remove global Content Blocking toggle in the main menu. r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D9916
browser/app/profile/firefox.js
browser/base/content/browser-contentblocking.js
browser/base/content/test/trackingUI/browser.ini
browser/base/content/test/trackingUI/browser_trackingUI_appMenu_toggle.js
browser/components/customizableui/content/panelUI.inc.xul
browser/locales/en-US/chrome/browser/browser.properties
browser/themes/shared/customizableui/panelUI.inc.css
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1511,22 +1511,16 @@ pref("media.gmp-provider.enabled", true)
 // Nightly and Beta
 #ifdef EARLY_BETA_OR_EARLIER
 pref("network.cookie.cookieBehavior", 4 /* BEHAVIOR_REJECT_TRACKER */);
 #endif
 
 pref("browser.contentblocking.allowlist.storage.enabled", true);
 
 #ifdef NIGHTLY_BUILD
-pref("browser.contentblocking.global-toggle.enabled", true);
-#else
-pref("browser.contentblocking.global-toggle.enabled", false);
-#endif
-
-#ifdef NIGHTLY_BUILD
 // Enable the Storage Access API in Nightly
 pref("dom.storage_access.enabled", true);
 #endif
 
 // Define a set of default features for the Content Blocking UI.
 pref("browser.contentblocking.trackingprotection.ui.enabled", true);
 pref("browser.contentblocking.trackingprotection.control-center.ui.enabled", true);
 pref("browser.contentblocking.rejecttrackers.ui.enabled", true);
--- a/browser/base/content/browser-contentblocking.js
+++ b/browser/base/content/browser-contentblocking.js
@@ -129,54 +129,31 @@ var ThirdPartyCookies = {
 var ContentBlocking = {
   // If the user ignores the doorhanger, we stop showing it after some time.
   MAX_INTROS: 20,
   PREF_ENABLED: "browser.contentblocking.enabled",
   PREF_ANIMATIONS_ENABLED: "toolkit.cosmeticAnimations.enabled",
   PREF_REPORT_BREAKAGE_ENABLED: "browser.contentblocking.reportBreakage.enabled",
   PREF_REPORT_BREAKAGE_URL: "browser.contentblocking.reportBreakage.url",
   PREF_INTRO_COUNT_CB: "browser.contentblocking.introCount",
-  PREF_GLOBAL_TOGGLE: "browser.contentblocking.global-toggle.enabled",
   content: null,
   icon: null,
   activeTooltipText: null,
   disabledTooltipText: null,
 
   get prefIntroCount() {
     return this.PREF_INTRO_COUNT_CB;
   },
 
   get appMenuLabel() {
     delete this.appMenuLabel;
     return this.appMenuLabel = document.getElementById("appMenu-tp-label");
   },
 
-  get appMenuButton() {
-    delete this.appMenuButton;
-    return this.appMenuButton = document.getElementById("appMenu-tp-toggle");
-  },
-
-  get appMenuVerticalSeparator() {
-    delete this.appMenuVerticalSeparator;
-    return this.appMenuVerticalSeparator = document.getElementById("appMenu-tp-vertical-separator");
-  },
-
   strings: {
-    get enableTooltip() {
-      delete this.enableTooltip;
-      return this.enableTooltip =
-        gNavigatorBundle.getString("contentBlocking.toggle.enable.tooltip");
-    },
-
-    get disableTooltip() {
-      delete this.disableTooltip;
-      return this.disableTooltip =
-        gNavigatorBundle.getString("contentBlocking.toggle.disable.tooltip");
-    },
-
     get appMenuTitle() {
       delete this.appMenuTitle;
       return this.appMenuTitle =
         gNavigatorBundle.getString("contentBlocking.title");
     },
 
     get appMenuTooltip() {
       delete this.appMenuTooltip;
@@ -219,30 +196,16 @@ var ContentBlocking = {
     this.identityPopupMultiView = $("#identity-popup-multiView");
     this.reportBreakageButton = $("#identity-popup-content-blocking-report-breakage");
     this.reportBreakageURL = $("#identity-popup-breakageReportView-collection-url");
     this.reportBreakageLearnMore = $("#identity-popup-breakageReportView-learn-more");
 
     let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
     this.reportBreakageLearnMore.href = baseURL + "blocking-breakage";
 
-    this.updateGlobalToggleVisibility = () => {
-      if (Services.prefs.getBoolPref(this.PREF_GLOBAL_TOGGLE, true)) {
-        this.appMenuButton.removeAttribute("hidden");
-        this.appMenuVerticalSeparator.removeAttribute("hidden");
-      } else {
-        this.appMenuButton.setAttribute("hidden", "true");
-        this.appMenuVerticalSeparator.setAttribute("hidden", "true");
-      }
-    };
-
-    this.updateGlobalToggleVisibility();
-
-    Services.prefs.addObserver(this.PREF_GLOBAL_TOGGLE, this.updateGlobalToggleVisibility);
-
     this.updateAnimationsEnabled = () => {
       this.iconBox.toggleAttribute("animationsenabled",
         Services.prefs.getBoolPref(this.PREF_ANIMATIONS_ENABLED, false));
     };
 
     for (let blocker of this.blockers) {
       if (blocker.init) {
         blocker.init();
@@ -272,41 +235,31 @@ var ContentBlocking = {
   uninit() {
     for (let blocker of this.blockers) {
       if (blocker.uninit) {
         blocker.uninit();
       }
     }
 
     Services.prefs.removeObserver(this.PREF_ANIMATIONS_ENABLED, this.updateAnimationsEnabled);
-    Services.prefs.removeObserver(this.PREF_GLOBAL_TOGGLE, this.updateGlobalToggleVisibility);
   },
 
   get enabled() {
     return this.contentBlockingEnabled;
   },
 
   updateEnabled() {
     this.content.toggleAttribute("enabled", this.enabled);
 
-    this.appMenuButton.setAttribute("tooltiptext", this.enabled ?
-      this.strings.disableTooltip : this.strings.enableTooltip);
-    this.appMenuButton.setAttribute("enabled", this.enabled);
-    this.appMenuButton.setAttribute("aria-pressed", this.enabled);
-
     // The enabled state of blockers may also change since it depends on this.enabled.
     for (let blocker of this.blockers) {
       blocker.categoryItem.classList.toggle("blocked", this.enabled && blocker.enabled);
     }
   },
 
-  onGlobalToggleCommand() {
-    Services.prefs.setBoolPref(this.PREF_ENABLED, !this.enabled);
-  },
-
   hideIdentityPopupAndReload() {
     document.getElementById("identity-popup").hidePopup();
     BrowserReload();
   },
 
   openPreferences(origin) {
     openPreferences("privacy-trackingprotection", { origin });
   },
--- a/browser/base/content/test/trackingUI/browser.ini
+++ b/browser/base/content/test/trackingUI/browser.ini
@@ -6,17 +6,16 @@ support-files =
   cookiePage.html
   cookieServer.sjs
   trackingPage.html
 
 [browser_trackingUI_3.js]
 [browser_trackingUI_animation.js]
 [browser_trackingUI_animation_2.js]
 [browser_trackingUI_appMenu.js]
-[browser_trackingUI_appMenu_toggle.js]
 [browser_trackingUI_fetch.js]
 support-files =
   file_trackingUI_fetch.html
   file_trackingUI_fetch.js
   file_trackingUI_fetch.js^headers^
 [browser_trackingUI_open_preferences.js]
 [browser_trackingUI_pbmode_exceptions.js]
 [browser_trackingUI_report_breakage.js]
deleted file mode 100644
--- a/browser/base/content/test/trackingUI/browser_trackingUI_appMenu_toggle.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-const CB_PREF = "browser.contentblocking.enabled";
-const TOGGLE_PREF = "browser.contentblocking.global-toggle.enabled";
-
-ChromeUtils.import("resource://testing-common/CustomizableUITestUtils.jsm", this);
-
-// Test that the app menu toggle correctly flips the TP pref in
-// normal windows and private windows.
-add_task(async function testGlobalToggle() {
-  await SpecialPowers.pushPrefEnv({set: [
-    [TOGGLE_PREF, true],
-  ]});
-
-  let panelUIButton = await TestUtils.waitForCondition(() => document.getElementById("PanelUI-menu-button"));
-
-  info("Opening main menu");
-
-  let promiseShown = BrowserTestUtils.waitForEvent(PanelUI.mainView, "ViewShown");
-  panelUIButton.click();
-  await promiseShown;
-
-  info("Opened main menu");
-
-  let toggle = document.getElementById("appMenu-tp-toggle");
-
-  Services.prefs.setBoolPref(CB_PREF, false);
-  await TestUtils.waitForCondition(() => toggle.getAttribute("enabled") == "false");
-
-  Services.prefs.setBoolPref(CB_PREF, true);
-  await TestUtils.waitForCondition(() => toggle.getAttribute("enabled") == "true");
-
-  toggle.click();
-  is(Services.prefs.getBoolPref(CB_PREF), false);
-
-  toggle.click();
-  is(Services.prefs.getBoolPref(CB_PREF), true);
-
-  Services.prefs.clearUserPref(CB_PREF);
-});
--- a/browser/components/customizableui/content/panelUI.inc.xul
+++ b/browser/components/customizableui/content/panelUI.inc.xul
@@ -219,24 +219,20 @@
           <toolbarseparator orient="vertical"/>
           <toolbarbutton id="appMenu-fxa-icon"
                          class="subviewbutton subviewbutton-iconic"
                          onmouseover="gSync.refreshSyncButtonsTooltip();"
                          oncommand="gSync.doSync();"
                          closemenu="none"/>
         </toolbaritem>
         <toolbarseparator class="sync-ui-item"/>
-        <toolbaritem closemenu="none">
+        <toolbaritem>
           <toolbarbutton id="appMenu-tp-label"
                          class="subviewbutton subviewbutton-iconic"
-                         oncommand="ContentBlocking.openPreferences('appMenu-trackingprotection'); PanelUI.hide();"/>
-          <toolbarseparator id="appMenu-tp-vertical-separator" orient="vertical"/>
-          <toolbarbutton id="appMenu-tp-toggle"
-                         enabled="false"
-                         oncommand="ContentBlocking.onGlobalToggleCommand();" />
+                         oncommand="ContentBlocking.openPreferences('appMenu-trackingprotection');"/>
         </toolbaritem>
         <toolbarseparator id="appMenu-tp-separator"/>
         <toolbarbutton id="appMenu-new-window-button"
                        class="subviewbutton subviewbutton-iconic"
                        label="&newNavigatorCmd.label;"
                        key="key_newNavigator"
                        command="cmd_newNavigator"/>
         <toolbarbutton id="appMenu-private-window-button"
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -504,18 +504,16 @@ identity.notSecure.label=Not Secure
 
 identity.icon.tooltip=Show site information
 identity.extension.label=Extension (%S)
 identity.extension.tooltip=Loaded by extension: %S
 identity.showDetails.tooltip=Show connection details
 
 contentBlocking.title=Content Blocking
 contentBlocking.tooltip=Open Content Blocking Preferences
-contentBlocking.toggle.enable.tooltip=Enable Content Blocking
-contentBlocking.toggle.disable.tooltip=Disable Content Blocking
 
 # LOCALIZATION NOTE (contentBlocking.intro.title): %S is brandShortName.
 contentBlocking.intro.title=New in %S: Content Blocking
 # LOCALIZATION NOTE (contentBlocking.v1.intro.description): %S is brandShortName.
 contentBlocking.intro.v1.description=When you see the shield, %S is blocking parts of the page that can slow your browsing or track you online.
 contentBlocking.intro.v2.description=The privacy benefits of Tracking Protection are now just one part of content blocking. When you see the shield, content blocking is on.
 # LOCALIZATION NOTE (trackingProtection.intro.step1of3): Indicates that the intro panel is step one of three in a tour.
 trackingProtection.intro.step1of3=1 of 3
--- a/browser/themes/shared/customizableui/panelUI.inc.css
+++ b/browser/themes/shared/customizableui/panelUI.inc.css
@@ -595,65 +595,16 @@ toolbarbutton[constrain-size="true"][cui
 
 #appMenu-tp-label {
   -moz-context-properties: fill;
   fill: currentColor;
   list-style-image: url(chrome://browser/skin/tracking-protection.svg);
   -moz-box-flex: 1;
 }
 
-#appMenu-tp-toggle {
-  -moz-appearance: none;
-  box-sizing: border-box;
-  min-width: 26px;
-  height: 10px;
-  border-radius: 10px;
-  background-color: var(--arrowpanel-dimmed-even-further);
-  border: 1px solid transparent;
-  margin-top: 4px;
-  margin-bottom: 4px;
-  margin-inline-start: 1px;
-  margin-inline-end: 7px;
-  padding: 2px;
-  transition: padding .2s ease;
-}
-
-/* Don't resize the toggle in touch mode. */
-#appMenu-popup[touchmode] #appMenu-tp-toggle {
-  margin-top: 12px;
-  margin-bottom: 12px;
-}
-
-#appMenu-tp-toggle::before {
-  position: relative;
-  display: block;
-  content: "";
-  width: 10px;
-  height: 10px;
-  border-radius: 10px;
-  background: white;
-}
-
-#appMenu-tp-toggle[enabled=true] {
-  background-color: #0a84ff;
-  border: 1px solid #0a84ff;
-  /* Push the toggle to the right. */
-  padding-inline-start: 12px;
-}
-
-#appMenu-tp-toggle:hover,
-#appMenu-tp-toggle:-moz-focusring {
-  border: 1px solid var(--panel-separator-color);
-}
-
-#appMenu-tp-toggle[enabled=true]:hover,
-#appMenu-tp-toggle[enabled=true]:-moz-focusring {
-  background-color: #45a1ff;
-}
-
 .addon-banner-item > .toolbarbutton-text,
 .panel-banner-item > .toolbarbutton-text {
   margin: 0;
   padding: 0 6px;
   text-align: start;
 }
 
 .addon-banner-item > .toolbarbutton-icon,