[tor-commits] [Git][tpo/applications/mullvad-browser][mullvad-browser-128.2.0esr-14.0-1] Bug 41736: Customize toolbar for mullvad-browser.

morgan (@morgan) git at gitlab.torproject.org
Wed Aug 28 20:32:29 UTC 2024



morgan pushed to branch mullvad-browser-128.2.0esr-14.0-1 at The Tor Project / Applications / Mullvad Browser


Commits:
07162010 by Henry Wilkes at 2024-08-28T20:30:43+00:00
Bug 41736: Customize toolbar for mullvad-browser.

- - - - -


1 changed file:

- browser/components/customizableui/CustomizableUI.sys.mjs


Changes:

=====================================
browser/components/customizableui/CustomizableUI.sys.mjs
=====================================
@@ -65,6 +65,11 @@ var kVersion = 20;
 var kVersionBaseBrowser = 2;
 const NoScriptId = "_73a6fe31-595d-460b-a920-fcc0f8843232_-browser-action";
 
+/**
+ * The current version for mullvad browser.
+ */
+var kVersionMullvadBrowser = 1;
+
 /**
  * Buttons removed from built-ins by version they were removed. kVersion must be
  * bumped any time a new id is added to this. Use the button id as key, and
@@ -228,6 +233,7 @@ var CustomizableUIInternal = {
     this._updateForNewProtonVersion();
     this._markObsoleteBuiltinButtonsSeen();
     this._updateForBaseBrowser();
+    this._updateForMullvadBrowser();
 
     this.registerArea(
       CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
@@ -264,7 +270,11 @@ var CustomizableUIInternal = {
       // Base-browser additions tor-browser#41736. If you want to add to, remove
       // from, or rearrange this list, then bump the kVersionBaseBrowser and
       // update existing saved states in _updateForBaseBrowser.
-      "security-level-button",
+      // Or if the change is only meant for mullvad-browser, bump
+      // kVersionMullvadBrowser instead and update the existing saved states in
+      // _updateForMullvadBrowser.
+      // Do not show the security-level-button by default in Mullvad Browser.
+      // See mullvad-browser#329
       "new-identity-button",
       "downloads-button",
       AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
@@ -930,6 +940,44 @@ var CustomizableUIInternal = {
     }
   },
 
+  _updateForMullvadBrowser() {
+    if (!gSavedState) {
+      // Use the defaults.
+      return;
+    }
+
+    const currentVersion = gSavedState.currentVersionMullvadBrowser;
+
+    if (currentVersion < 1) {
+      // Remove security-level-button if:
+      // + it hasn't been moved out of the navbar by the user, and
+      // + the user does not have a custom security level.
+      //
+      // NOTE: _updateForBaseBrowser adds this button when
+      // currentVersionBaseBrowser < 1. This should only happen when
+      // currentVersionMullvadBrowser < 1, and this method runs after, so should
+      // reverse it.
+      const navbarPlacements =
+        gSavedState.placements[CustomizableUI.AREA_NAVBAR];
+      if (navbarPlacements) {
+        const buttonIndex = navbarPlacements.indexOf("security-level-button");
+        // Test if security level icon exists in the navbar.
+        // Even though a user may have moved the button within the navbar,
+        // there is no simple way to know whether the button was moved, or if
+        // other components were moved around it.
+        if (buttonIndex >= 0) {
+          // NOTE: We expect the SecurityLevel module to already be initialized.
+          const { SecurityLevelPrefs } = ChromeUtils.importESModule(
+            "resource://gre/modules/SecurityLevel.sys.mjs"
+          );
+          if (!SecurityLevelPrefs.securityCustom) {
+            navbarPlacements.splice(buttonIndex, 1);
+          }
+        }
+      }
+    }
+  },
+
   _placeNewDefaultWidgetsInArea(aArea) {
     let futurePlacedWidgets = gFuturePlacements.get(aArea);
     let savedPlacements =
@@ -2773,6 +2821,10 @@ var CustomizableUIInternal = {
       gSavedState.currentVersionBaseBrowser = 0;
     }
 
+    if (!("currentVersionMullvadBrowser" in gSavedState)) {
+      gSavedState.currentVersionMullvadBrowser = 0;
+    }
+
     gSeenWidgets = new Set(gSavedState.seen || []);
     gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
     gNewElementCount = gSavedState.newElementCount || 0;
@@ -2856,6 +2908,7 @@ var CustomizableUIInternal = {
       dirtyAreaCache: gDirtyAreaCache,
       currentVersion: kVersion,
       currentVersionBaseBrowser: kVersionBaseBrowser,
+      currentVersionMullvadBrowser: kVersionMullvadBrowser,
       newElementCount: gNewElementCount,
     };
 



View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/0716201098ebd250423b3b72469c2a8e2ff94b68

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/commit/0716201098ebd250423b3b72469c2a8e2ff94b68
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20240828/5b05075d/attachment-0001.htm>


More information about the tor-commits mailing list