diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index c91a5d4db29a9691e9b43ef4d5d5e9a4db945ac8..00107b54e09137ee1af1c56b8c9e853a4ffe7264 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -13,6 +13,15 @@ ChromeUtils.importESModule("resource://gre/modules/NotificationDB.sys.mjs"); // lazy module getters +const ZEN_WELCOME_PATH = "zen-welcome"; +const ZEN_WELCOME_ELEMENT_ATTR = "zen-dialog-welcome-element"; +XPCOMUtils.defineLazyServiceGetter( + this, + "ProfileService", + "@mozilla.org/toolkit/profile-service;1", + "nsIToolkitProfileService" +); + ChromeUtils.defineESModuleGetters(this, { AMTelemetry: "resource://gre/modules/AddonManager.sys.mjs", AboutNewTab: "resource:///modules/AboutNewTab.sys.mjs", @@ -1664,6 +1673,7 @@ var gBrowserInit = { }); updateFxaToolbarMenu(gFxaToolbarEnabled, true); + Services.scriptloader.loadSubScript("chrome://browser/content/zenThemeModifier.js", this); updatePrintCommands(gPrintEnabled); @@ -1727,6 +1737,11 @@ var gBrowserInit = { } // Misc. inits. + + // ZEN: Propagate the current profile used to the browser UI, such as + // showing the avatar and profile info to the side bar + zenUpdateBrowserProfiles(); + gUIDensity.init(); TabletModeUpdater.init(); CombinedStopReload.ensureInitialized(); @@ -6669,7 +6684,7 @@ function setToolbarVisibility( ); } - const overlapAttr = "BookmarksToolbarOverlapsBrowser"; + const overlapAttr = "BookmarksToolbarOverlapsBrowser__ignore"; // Original string was "BookmarksToolbarOverlapsBrowser" but it's not used and it only bugs the UI. switch (isVisible) { case true: case "always": @@ -9789,6 +9804,13 @@ var gDialogBox = { parentElement.style.removeProperty("width"); parentElement.style.removeProperty("height"); document.documentElement.setAttribute("window-modal-open", true); + + if (uri.includes(ZEN_WELCOME_PATH)) { + parentElement.setAttribute(ZEN_WELCOME_ELEMENT_ATTR, true); + } else if (parentElement.hasAttribute(ZEN_WELCOME_ELEMENT_ATTR)) { + parentElement.removeAttribute(ZEN_WELCOME_ELEMENT_ATTR); + } + // Call this first so the contents show up and get layout, which is // required for SubDialog to work. parentElement.showModal(); @@ -10166,3 +10188,15 @@ var FirefoxViewHandler = { this.button?.toggleAttribute("attention", shouldShow); }, }; + +function zenUpdateBrowserProfiles() { + const mainWindowEl = document.documentElement; + // Dont override the sync avatar if it's already set + if (mainWindowEl.style.hasOwnProperty("--avatar-image-url")) { + return; + } + let profile = ProfileService.currentProfile; + if (!profile || profile.zenAvatarPath == "") return; + // TODO: actually use profile data to generate the avatar, instead of just using the name + mainWindowEl.style.setProperty("--avatar-image-url", `url(${profile.zenAvatarPath})`); +}