diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..01ebb483e6d9632588578b8b05195250ca26968a 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", @@ -1735,6 +1744,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(); @@ -6660,7 +6674,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": @@ -9780,6 +9794,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(); @@ -10157,3 +10178,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})`); +}