| ... | 
... | 
@@ -65,6 +65,11 @@ var kVersion = 20; | 
| 
65
 | 
65
 | 
 var kVersionBaseBrowser = 2;
  | 
| 
66
 | 
66
 | 
 const NoScriptId = "_73a6fe31-595d-460b-a920-fcc0f8843232_-browser-action";
  | 
| 
67
 | 
67
 | 
 
  | 
| 
 
 | 
68
 | 
+/**
  | 
| 
 
 | 
69
 | 
+ * The current version for mullvad browser.
  | 
| 
 
 | 
70
 | 
+ */
  | 
| 
 
 | 
71
 | 
+var kVersionMullvadBrowser = 1;
  | 
| 
 
 | 
72
 | 
+
  | 
| 
68
 | 
73
 | 
 /**
  | 
| 
69
 | 
74
 | 
  * Buttons removed from built-ins by version they were removed. kVersion must be
  | 
| 
70
 | 
75
 | 
  * bumped any time a new id is added to this. Use the button id as key, and
  | 
| ... | 
... | 
@@ -228,6 +233,7 @@ var CustomizableUIInternal = { | 
| 
228
 | 
233
 | 
     this._updateForNewProtonVersion();
  | 
| 
229
 | 
234
 | 
     this._markObsoleteBuiltinButtonsSeen();
  | 
| 
230
 | 
235
 | 
     this._updateForBaseBrowser();
  | 
| 
 
 | 
236
 | 
+    this._updateForMullvadBrowser();
  | 
| 
231
 | 
237
 | 
 
  | 
| 
232
 | 
238
 | 
     this.registerArea(
  | 
| 
233
 | 
239
 | 
       CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
  | 
| ... | 
... | 
@@ -264,7 +270,11 @@ var CustomizableUIInternal = { | 
| 
264
 | 
270
 | 
       // Base-browser additions tor-browser#41736. If you want to add to, remove
  | 
| 
265
 | 
271
 | 
       // from, or rearrange this list, then bump the kVersionBaseBrowser and
  | 
| 
266
 | 
272
 | 
       // update existing saved states in _updateForBaseBrowser.
  | 
| 
267
 | 
 
 | 
-      "security-level-button",
  | 
| 
 
 | 
273
 | 
+      // Or if the change is only meant for mullvad-browser, bump
  | 
| 
 
 | 
274
 | 
+      // kVersionMullvadBrowser instead and update the existing saved states in
  | 
| 
 
 | 
275
 | 
+      // _updateForMullvadBrowser.
  | 
| 
 
 | 
276
 | 
+      // Do not show the security-level-button by default in Mullvad Browser.
  | 
| 
 
 | 
277
 | 
+      // See mullvad-browser#329
  | 
| 
268
 | 
278
 | 
       "new-identity-button",
  | 
| 
269
 | 
279
 | 
       "downloads-button",
  | 
| 
270
 | 
280
 | 
       AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
  | 
| ... | 
... | 
@@ -930,6 +940,44 @@ var CustomizableUIInternal = { | 
| 
930
 | 
940
 | 
     }
  | 
| 
931
 | 
941
 | 
   },
  | 
| 
932
 | 
942
 | 
 
  | 
| 
 
 | 
943
 | 
+  _updateForMullvadBrowser() {
 | 
| 
 
 | 
944
 | 
+    if (!gSavedState) {
 | 
| 
 
 | 
945
 | 
+      // Use the defaults.
  | 
| 
 
 | 
946
 | 
+      return;
  | 
| 
 
 | 
947
 | 
+    }
  | 
| 
 
 | 
948
 | 
+
  | 
| 
 
 | 
949
 | 
+    const currentVersion = gSavedState.currentVersionMullvadBrowser;
  | 
| 
 
 | 
950
 | 
+
  | 
| 
 
 | 
951
 | 
+    if (currentVersion < 1) {
 | 
| 
 
 | 
952
 | 
+      // Remove security-level-button if:
  | 
| 
 
 | 
953
 | 
+      // + it hasn't been moved out of the navbar by the user, and
  | 
| 
 
 | 
954
 | 
+      // + the user does not have a custom security level.
  | 
| 
 
 | 
955
 | 
+      //
  | 
| 
 
 | 
956
 | 
+      // NOTE: _updateForBaseBrowser adds this button when
  | 
| 
 
 | 
957
 | 
+      // currentVersionBaseBrowser < 1. This should only happen when
  | 
| 
 
 | 
958
 | 
+      // currentVersionMullvadBrowser < 1, and this method runs after, so should
  | 
| 
 
 | 
959
 | 
+      // reverse it.
  | 
| 
 
 | 
960
 | 
+      const navbarPlacements =
  | 
| 
 
 | 
961
 | 
+        gSavedState.placements[CustomizableUI.AREA_NAVBAR];
  | 
| 
 
 | 
962
 | 
+      if (navbarPlacements) {
 | 
| 
 
 | 
963
 | 
+        const buttonIndex = navbarPlacements.indexOf("security-level-button");
 | 
| 
 
 | 
964
 | 
+        // Test if security level icon exists in the navbar.
  | 
| 
 
 | 
965
 | 
+        // Even though a user may have moved the button within the navbar,
  | 
| 
 
 | 
966
 | 
+        // there is no simple way to know whether the button was moved, or if
  | 
| 
 
 | 
967
 | 
+        // other components were moved around it.
  | 
| 
 
 | 
968
 | 
+        if (buttonIndex >= 0) {
 | 
| 
 
 | 
969
 | 
+          // NOTE: We expect the SecurityLevel module to already be initialized.
  | 
| 
 
 | 
970
 | 
+          const { SecurityLevelPrefs } = ChromeUtils.importESModule(
 | 
| 
 
 | 
971
 | 
+            "resource://gre/modules/SecurityLevel.sys.mjs"
  | 
| 
 
 | 
972
 | 
+          );
  | 
| 
 
 | 
973
 | 
+          if (!SecurityLevelPrefs.securityCustom) {
 | 
| 
 
 | 
974
 | 
+            navbarPlacements.splice(buttonIndex, 1);
  | 
| 
 
 | 
975
 | 
+          }
  | 
| 
 
 | 
976
 | 
+        }
  | 
| 
 
 | 
977
 | 
+      }
  | 
| 
 
 | 
978
 | 
+    }
  | 
| 
 
 | 
979
 | 
+  },
  | 
| 
 
 | 
980
 | 
+
  | 
| 
933
 | 
981
 | 
   _placeNewDefaultWidgetsInArea(aArea) {
 | 
| 
934
 | 
982
 | 
     let futurePlacedWidgets = gFuturePlacements.get(aArea);
  | 
| 
935
 | 
983
 | 
     let savedPlacements =
  | 
| ... | 
... | 
@@ -2773,6 +2821,10 @@ var CustomizableUIInternal = { | 
| 
2773
 | 
2821
 | 
       gSavedState.currentVersionBaseBrowser = 0;
  | 
| 
2774
 | 
2822
 | 
     }
  | 
| 
2775
 | 
2823
 | 
 
  | 
| 
 
 | 
2824
 | 
+    if (!("currentVersionMullvadBrowser" in gSavedState)) {
 | 
| 
 
 | 
2825
 | 
+      gSavedState.currentVersionMullvadBrowser = 0;
  | 
| 
 
 | 
2826
 | 
+    }
  | 
| 
 
 | 
2827
 | 
+
  | 
| 
2776
 | 
2828
 | 
     gSeenWidgets = new Set(gSavedState.seen || []);
  | 
| 
2777
 | 
2829
 | 
     gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
  | 
| 
2778
 | 
2830
 | 
     gNewElementCount = gSavedState.newElementCount || 0;
  | 
| ... | 
... | 
@@ -2856,6 +2908,7 @@ var CustomizableUIInternal = { | 
| 
2856
 | 
2908
 | 
       dirtyAreaCache: gDirtyAreaCache,
  | 
| 
2857
 | 
2909
 | 
       currentVersion: kVersion,
  | 
| 
2858
 | 
2910
 | 
       currentVersionBaseBrowser: kVersionBaseBrowser,
  | 
| 
 
 | 
2911
 | 
+      currentVersionMullvadBrowser: kVersionMullvadBrowser,
  | 
| 
2859
 | 
2912
 | 
       newElementCount: gNewElementCount,
  | 
| 
2860
 | 
2913
 | 
     };
  | 
| 
2861
 | 
2914
 | 
 
  |