[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-102.10.0esr-12.5-1] 6 commits: Bug 41736 - Customize toolbar for base-browser.
Richard Pospesel (@richard)
git at gitlab.torproject.org
Thu Apr 20 20:04:13 UTC 2023
Richard Pospesel pushed to branch tor-browser-102.10.0esr-12.5-1 at The Tor Project / Applications / Tor Browser
Commits:
1ce930e3 by Henry Wilkes at 2023-04-20T20:03:08+00:00
Bug 41736 - Customize toolbar for base-browser.
- - - - -
d354800c by Henry Wilkes at 2023-04-20T20:03:08+00:00
fixup! Bug 40926: Implemented the New Identity feature
Bug 41736 - Stop setting the browser.uiCustomization.state preference.
- - - - -
adacb2c3 by Henry Wilkes at 2023-04-20T20:03:08+00:00
fixup! Bug 40925: Implemented the Security Level component
Bug 41736 - Stop setting the browser.uiCustomization.state preference.
- - - - -
491718d1 by Henry Wilkes at 2023-04-20T20:03:08+00:00
fixup! Firefox preference overrides.
Bug 41736 - Stop setting the browser.uiCustomization.state preference.
- - - - -
352acb10 by Henry Wilkes at 2023-04-20T20:03:08+00:00
Bug 41736 - Customize toolbar for tor-browser.
- - - - -
96796fa5 by Henry Wilkes at 2023-04-20T20:03:08+00:00
fixup! Bug 40562: Added Tor Browser preferences to 000-tor-browser.js
Bug 41736 - Stop setting the browser.uiCustomization.state preference.
- - - - -
4 changed files:
- browser/app/profile/000-tor-browser.js
- browser/app/profile/001-base-profile.js
- browser/components/customizableui/CustomizableUI.jsm
- browser/components/extensions/parent/ext-browserAction.js
Changes:
=====================================
browser/app/profile/000-tor-browser.js
=====================================
@@ -30,8 +30,6 @@ pref("network.security.ports.banned", "", locked);
pref("network.dns.disabled", true); // This should cover the #5741 patch for DNS leaks
pref("network.http.max-persistent-connections-per-proxy", 256);
-pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"PersonalToolbar\":[\"personal-bookmarks\"],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"torbutton-button\",\"security-level-button\",\"new-identity-button\",\"downloads-button\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"new-tab-button\",\"alltabs-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"PanelUI-contents\":[\"home-button\",\"edit-controls\",\"zoom-controls\",\"new-window-button\",\"save-page-button\",\"print-button\",\"bookmarks-menu-button\",\"history-panelmenu\",\"find-button\",\"preferences-button\",\"add-ons-button\",\"developer-button\"],\"addon-bar\":[\"addonbar-closebutton\",\"status-bar\"]},\"seen\":[\"developer-button\",\"_73a6fe31-595d-460b-a920-fcc0f8843232_-browser-action\"],\"dirtyAreaCache\":[\"PersonalToolbar\",\"nav-bar\",\"TabsToolbar\",\"toolbar-menubar\"],\"currentVersion\":14,\"newElementCount\":1}");
-
// Treat .onions as secure
pref("dom.securecontext.allowlist_onions", true);
=====================================
browser/app/profile/001-base-profile.js
=====================================
@@ -464,9 +464,6 @@ pref("intl.multilingual.downloadEnabled", false);
// Disk activity: Disable storage.sync (tor-browser#41424)
pref("webextensions.storage.sync.enabled", false);
-// Toolbar layout
-pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"PersonalToolbar\":[\"personal-bookmarks\"],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"security-level-button\",\"new-identity-button\",\"downloads-button\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"new-tab-button\",\"alltabs-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"PanelUI-contents\":[\"home-button\",\"edit-controls\",\"zoom-controls\",\"new-window-button\",\"save-page-button\",\"print-button\",\"bookmarks-menu-button\",\"history-panelmenu\",\"find-button\",\"preferences-button\",\"add-ons-button\",\"developer-button\"],\"addon-bar\":[\"addonbar-closebutton\",\"status-bar\"]},\"seen\":[\"developer-button\"],\"dirtyAreaCache\":[\"PersonalToolbar\",\"nav-bar\",\"TabsToolbar\",\"toolbar-menubar\"],\"currentVersion\":14,\"newElementCount\":1}");
-
// Enforce certificate pinning, see: https://bugs.torproject.org/16206
pref("security.cert_pinning.enforcement_level", 2);
=====================================
browser/components/customizableui/CustomizableUI.jsm
=====================================
@@ -65,6 +65,16 @@ const kSubviewEvents = ["ViewShowing", "ViewHiding"];
*/
var kVersion = 17;
+/**
+ * The current version for base browser.
+ */
+var kVersionBaseBrowser = 1;
+
+/**
+ * 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
@@ -218,6 +228,8 @@ var CustomizableUIInternal = {
this._updateForNewVersion();
this._updateForNewProtonVersion();
this._markObsoleteBuiltinButtonsSeen();
+ this._updateForBaseBrowser();
+ this._updateForTorBrowser();
this.registerArea(
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
@@ -236,10 +248,17 @@ var CustomizableUIInternal = {
Services.policies.isAllowed("removeHomeButtonByDefault")
? null
: "home-button",
- "spring",
+ // Don't want springs either side of the urlbar. tor-browser#41736
"urlbar-container",
- "spring",
- "save-to-pocket-button",
+ // save-to-pocket-button is entirely disabled. See tor-browser#18886 and
+ // tor-browser#31602.
+ // 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",
AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
"fxa-toolbar-menu-button",
@@ -255,6 +274,10 @@ var CustomizableUIInternal = {
},
true
);
+ // navbarPlacements does not match the initial default XHTML layout.
+ // Therefore we always need to rebuild the navbar area when
+ // registerToolbarNode is called. tor-browser#41736
+ gDirtyAreaCache.add(CustomizableUI.AREA_NAVBAR);
if (AppConstants.MENUBAR_CAN_AUTOHIDE) {
this.registerArea(
@@ -687,6 +710,123 @@ var CustomizableUIInternal = {
}
},
+ _updateForBaseBrowser() {
+ if (!gSavedState) {
+ // Use the defaults.
+ return;
+ }
+
+ const currentVersion = gSavedState.currentVersionBaseBrowser;
+
+ if (currentVersion < 1) {
+ // NOTE: In base-browser/tor-browser version 12.5a5, and earlier, the
+ // toolbar was configured by setting the full JSON string for the default
+ // "browser.uiCustomization.state" preference value. The disadvantage is
+ // that we could not update this value in a way that existing users (who
+ // would have non-default preference values) would also get the desired
+ // change (e.g. for adding or removing a button).
+ //
+ // With tor-browser#41736 we want to switch to changing the toolbar
+ // dynamically like firefox. Therefore, this first version transfer simply
+ // gets the toolbar into the same state we wanted before, away from the
+ // default firefox state.
+ //
+ // If an existing user state aligned with the previous default
+ // "browser.uiCustomization.state" then this shouldn't visibly change
+ // anything.
+ // If a user explicitly customized the toolbar to go back to the firefox
+ // default, then this may undo those changes.
+ const navbarPlacements =
+ gSavedState.placements[CustomizableUI.AREA_NAVBAR];
+ if (navbarPlacements) {
+ const getBeforeAfterUrlbar = () => {
+ // NOTE: The urlbar is non-removable from the navbar, so should have
+ // an index.
+ const index = navbarPlacements.indexOf("urlbar-container");
+ let after = index + 1;
+ if (
+ after < navbarPlacements.length &&
+ navbarPlacements[after] === "search-container"
+ ) {
+ // Skip past the search-container.
+ after++;
+ }
+ return { before: index - 1, after };
+ };
+
+ // Remove the urlbar springs either side of the urlbar.
+ const { before, after } = getBeforeAfterUrlbar();
+ if (
+ after < navbarPlacements.length &&
+ this.matchingSpecials(navbarPlacements[after], "spring")
+ ) {
+ // Remove the spring after.
+ navbarPlacements.splice(after, 1);
+ // NOTE: The `before` index does not change.
+ }
+ if (
+ before >= 0 &&
+ this.matchingSpecials(navbarPlacements[before], "spring")
+ ) {
+ // Remove the spring before.
+ navbarPlacements.splice(before, 1);
+ }
+
+ // Make sure the security-level-button and new-identity-button appears
+ // in the toolbar.
+ for (const id of ["new-identity-button", "security-level-button"]) {
+ let alreadyAdded = false;
+ for (const placements of Object.values(gSavedState.placements)) {
+ if (placements.includes(id)) {
+ alreadyAdded = true;
+ break;
+ }
+ }
+ if (alreadyAdded) {
+ continue;
+ }
+
+ // Add to the nav-bar, after the urlbar-container.
+ // NOTE: We have already removed the spring after the urlbar.
+ navbarPlacements.splice(getBeforeAfterUrlbar().after, 0, id);
+ }
+ }
+
+ // Remove save-to-pocket-button. See tor-browser#18886 and
+ // tor-browser#31602.
+ for (const placements of Object.values(gSavedState.placements)) {
+ let buttonIndex = placements.indexOf("save-to-pocket-button");
+ if (buttonIndex != -1) {
+ placements.splice(buttonIndex, 1);
+ }
+ }
+
+ // Remove unused fields that used to be part of
+ // "browser.uiCustomization.state".
+ delete gSavedState.placements["PanelUI-contents"];
+ delete gSavedState.placements["addon-bar"];
+ }
+ },
+
+ _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);
+ }
+ }
+ }
+ },
+
_placeNewDefaultWidgetsInArea(aArea) {
let futurePlacedWidgets = gFuturePlacements.get(aArea);
let savedPlacements =
@@ -2501,6 +2641,14 @@ var CustomizableUIInternal = {
gSavedState.currentVersion = 0;
}
+ if (!("currentVersionBaseBrowser" in gSavedState)) {
+ gSavedState.currentVersionBaseBrowser = 0;
+ }
+
+ if (!("currentVersionTorBrowser" in gSavedState)) {
+ gSavedState.currentVersionTorBrowser = 0;
+ }
+
gSeenWidgets = new Set(gSavedState.seen || []);
gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
gNewElementCount = gSavedState.newElementCount || 0;
@@ -2579,6 +2727,8 @@ var CustomizableUIInternal = {
seen: gSeenWidgets,
dirtyAreaCache: gDirtyAreaCache,
currentVersion: kVersion,
+ currentVersionBaseBrowser: kVersionBaseBrowser,
+ currentVersionTorBrowser: kVersionTorBrowser,
newElementCount: gNewElementCount,
};
=====================================
browser/components/extensions/parent/ext-browserAction.js
=====================================
@@ -193,6 +193,10 @@ this.browserAction = class extends ExtensionAPIPersistent {
}
build() {
+ // The extension ID for NoScript (WebExtension)
+ const isNoScript =
+ this.extension.id === "{73a6fe31-595d-460b-a920-fcc0f8843232}";
+
let widget = CustomizableUI.createWidget({
id: this.id,
viewId: this.viewId,
@@ -200,7 +204,11 @@ this.browserAction = class extends ExtensionAPIPersistent {
removable: true,
label: this.action.getProperty(null, "title"),
tooltiptext: this.action.getProperty(null, "title"),
- defaultArea: browserAreas[this.action.getDefaultArea()],
+ // Do not want to add the NoScript extension to the toolbar by default.
+ // tor-browser#41736
+ defaultArea: isNoScript
+ ? null
+ : browserAreas[this.action.getDefaultArea()],
showInPrivateBrowsing: this.extension.privateBrowsingAllowed,
// Don't attempt to load properties from the built-in widget string
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4ae8853092bda294b037881f1940b6bdaa7f41a3...96796fa58d2f7c484195d2a497eeff05586711e4
--
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/4ae8853092bda294b037881f1940b6bdaa7f41a3...96796fa58d2f7c484195d2a497eeff05586711e4
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/20230420/9018a177/attachment-0001.htm>
More information about the tor-commits
mailing list