commit 221ebfd9d6cea8ab13af82e1709964fab681ea75
parent 4083a78ab5313b17512d3086c6e1eacdf524d995
Author: Henry Wilkes <henry@torproject.org>
Date: Wed, 19 Apr 2023 14:34:32 +0100
TB 41736: Customize toolbar for tor-browser.
Diffstat:
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/browser/components/customizableui/CustomizableUI.sys.mjs b/browser/components/customizableui/CustomizableUI.sys.mjs
@@ -77,6 +77,11 @@ var kVersionBaseBrowser = 2;
const NoScriptId = "_73a6fe31-595d-460b-a920-fcc0f8843232_-browser-action";
/**
+ * The current version for tor browser.
+ */
+var kVersionTorBrowser = 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
* version the button is removed in as the value. e.g. "pocket-button": 5
@@ -317,6 +322,7 @@ var CustomizableUIInternal = {
this.updateForNewProtonVersion();
this.markObsoleteBuiltinButtonsSeen();
this.updateForBaseBrowser();
+ this.updateForTorBrowser();
this.registerArea(
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
@@ -352,6 +358,8 @@ 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.
+ // Or if the change is only meant for tor-browser, bump kVersionTorBrowser
+ // instead and update the existing saved states in _updateForTorBrowser.
"security-level-button",
"new-identity-button",
"downloads-button",
@@ -1081,6 +1089,25 @@ var CustomizableUIInternal = {
}
},
+ updateForTorBrowser() {
+ if (!gSavedState) {
+ // Use the defaults.
+ return;
+ }
+
+ const currentVersion = gSavedState.currentVersionTorBrowser;
+
+ if (currentVersion < 1) {
+ // Remove torbutton-button, which no longer exists.
+ for (const placements of Object.values(gSavedState.placements)) {
+ let buttonIndex = placements.indexOf("torbutton-button");
+ if (buttonIndex != -1) {
+ placements.splice(buttonIndex, 1);
+ }
+ }
+ }
+ },
+
/**
* If a new area was defined, or new default widgets for an area are defined,
* this reconciles the placements of those new default widgets with the
@@ -3632,6 +3659,10 @@ var CustomizableUIInternal = {
gSavedState.currentVersionBaseBrowser = 0;
}
+ if (!("currentVersionTorBrowser" in gSavedState)) {
+ gSavedState.currentVersionTorBrowser = 0;
+ }
+
gSeenWidgets = new Set(gSavedState.seen || []);
gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
gNewElementCount = gSavedState.newElementCount || 0;
@@ -3929,6 +3960,7 @@ var CustomizableUIInternal = {
dirtyAreaCache: gDirtyAreaCache,
currentVersion: kVersion,
currentVersionBaseBrowser: kVersionBaseBrowser,
+ currentVersionTorBrowser: kVersionTorBrowser,
newElementCount: gNewElementCount,
};