commit 07d4cb82dbf8e95ee0fafb4bc372f5b285526c2e
parent e67f734a6f9e3783d259733069c7301765e9075f
Author: Henry Wilkes <henry@torproject.org>
Date: Mon, 18 Aug 2025 12:34:28 +0100
BB 43902: Modify the new sidebar for Base Browser.
Diffstat:
4 files changed, 67 insertions(+), 4 deletions(-)
diff --git a/browser/components/places/content/historySidebar.js b/browser/components/places/content/historySidebar.js
@@ -91,6 +91,33 @@ window.addEventListener("load", () => {
bhTooltip.removeAttribute("position")
);
+ // Add a button to close the history sidebar. This should only be visible when
+ // this document is used for the revamped sidebar. See tor-browser#44108.
+ document
+ .getElementById("sidebar-panel-close")
+ .addEventListener("click", () => {
+ window.browsingContext.embedderWindowGlobal.browsingContext.window.SidebarController.toggle(
+ "viewHistorySidebar"
+ );
+ });
+ // Hack to convert the sidebar-menu-history Fluent string's label attribute
+ // into text content.
+ const headingEl = document.getElementById("sidebar-panel-header-history");
+ const updateHeadingText = () => {
+ const label = headingEl.getAttribute("label");
+ if (!label) {
+ return;
+ }
+ headingEl.textContent = label;
+ headingEl.removeAttribute("label");
+ };
+ const headingElObserver = new MutationObserver(updateHeadingText);
+ headingElObserver.observe(headingEl, {
+ attributes: true,
+ attributeFilter: ["label"],
+ });
+ updateHeadingText();
+
searchHistory("");
});
diff --git a/browser/components/places/content/historySidebar.xhtml b/browser/components/places/content/historySidebar.xhtml
@@ -42,6 +42,9 @@
<html:link rel="localization" href="toolkit/global/textActions.ftl"/>
<html:link rel="localization" href="browser/places.ftl"/>
+ <!-- Need sidebar-menu-history and sidebar-close-button.
+ - tor-browser#44108 -->
+ <html:link rel="localization" href="browser/sidebarMenu.ftl"/>
</linkset>
#include placesCommands.inc.xhtml
@@ -55,6 +58,26 @@
#include placesContextMenu.inc.xhtml
#include bookmarksHistoryTooltip.inc.xhtml
+ <!-- For ESR 140, we want to use this old history sidebar for the revamped
+ - sidebar as well because it does not require the "firefoxview" component.
+ - So we need an internal heading element for this page to be used with the
+ - new sidebar only. We copy this from bookmarksSidebar.xhtml.
+ - See tor-browser#44108. -->
+ <box id="sidebar-panel-header" align="center">
+ <!-- (Mis)use the sidebar-menu-history string, which will set a "label"
+ - attribute, which we will convert to text content in javascript. -->
+ <html:h4
+ id="sidebar-panel-header-history"
+ data-l10n-id="sidebar-menu-history"
+ data-l10n-attrs="label"
+ ></html:h4>
+ <html:moz-button
+ id="sidebar-panel-close"
+ type="icon ghost"
+ iconsrc="chrome://global/skin/icons/close.svg"
+ data-l10n-id="sidebar-close-button">
+ </html:moz-button>
+ </box>
<hbox id="sidebar-search-container">
<html:moz-input-search id="search-box"
diff --git a/browser/components/preferences/main.inc.xhtml b/browser/components/preferences/main.inc.xhtml
@@ -60,7 +60,7 @@
</radiogroup>
<checkbox id="browserLayoutShowSidebar" data-l10n-id="browser-layout-show-sidebar"
preference="sidebar.revamp"/>
- <description class="indent" data-l10n-id="browser-layout-show-sidebar-desc"></description>
+ <description class="indent" data-l10n-id="browser-layout-show-sidebar-desc-limited"></description>
</groupbox>
<!-- Letterboxing -->
diff --git a/browser/components/sidebar/browser-sidebar.js b/browser/components/sidebar/browser-sidebar.js
@@ -118,9 +118,10 @@ var SidebarController = {
this.makeSidebar({
name: "history",
elementId: "sidebar-switcher-history",
- url: this.sidebarRevampEnabled
- ? "chrome://browser/content/sidebar/sidebar-history.html"
- : "chrome://browser/content/places/historySidebar.xhtml",
+ // sidebar-history.html requires the "firefoxview" component and
+ // requires more work. Stick to historySidebar.xhtml for ESR 140.
+ // See tor-browser#44108.
+ url: "chrome://browser/content/places/historySidebar.xhtml",
menuId: "menu_historySidebar",
triggerButtonId: "appMenuViewHistorySidebar",
keyId: "key_gotoHistory",
@@ -133,6 +134,9 @@ var SidebarController = {
gleanEvent: Glean.history.sidebarToggle,
gleanClickEvent: Glean.sidebar.historyIconClick,
recordSidebarVersion: true,
+ // In permanent private browsing, the history panel can be opened, but
+ // we hide the sidebar button to control this. tor-browser#43902.
+ visible: !PrivateBrowsingUtils.permanentPrivateBrowsing,
}),
],
[
@@ -152,6 +156,15 @@ var SidebarController = {
? "sidebar-synced-tabs-context-menu"
: undefined,
gleanClickEvent: Glean.sidebar.syncedTabsIconClick,
+ // firefoxview is disabled. tor-browser#42037 and tor-browser#43902.
+ // See bugzilla bug 1983505.
+ // NOTE: The menuId and elementId menu items (sidebar switchers)
+ // should be hidden via the `sync-ui-item` class, which will *one*
+ // time hide the menu items via gSync.init.
+ // #sidebar-switcher-tabs is already in the initial browser DOM,
+ // and #menu_tabsSidebar is created during SidebarController.init,
+ // which seems to run prior to gSync.init.
+ visible: false,
}),
],
[