mirror of
https://github.com/zen-browser/desktop.git
synced 2025-07-08 16:30:00 +02:00
117 lines
4 KiB
Diff
117 lines
4 KiB
Diff
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
|
|
index 4f145c494973374e87f3a3ed5eb6b33a43c518c8..3b588199c8ab98157cc423e47fa209d7899d8656 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",
|
|
@@ -1610,6 +1619,7 @@ var gBrowserInit = {
|
|
// Update the chromemargin attribute so the window can be sized correctly.
|
|
window.TabBarVisibility.update();
|
|
TabsInTitlebar.init();
|
|
+ ZenThemeHandler.init();
|
|
|
|
new LightweightThemeConsumer(document);
|
|
|
|
@@ -1735,6 +1745,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();
|
|
@@ -2489,6 +2504,7 @@ var gBrowserInit = {
|
|
TabsInTitlebar.uninit();
|
|
|
|
ToolbarIconColor.uninit();
|
|
+ ZenThemeHandler.uninit();
|
|
|
|
// In certain scenarios it's possible for unload to be fired before onload,
|
|
// (e.g. if the window is being closed after browser.js loads but before the
|
|
@@ -6660,7 +6676,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 +9796,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 +10180,45 @@ 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})`);
|
|
+}
|
|
+
|
|
+var ZenThemeHandler = {
|
|
+ init() {
|
|
+ window.addEventListener("windowlwthemeupdate", this);
|
|
+ window.addEventListener("nativethemechange", this);
|
|
+ this.executeAllUpdates();
|
|
+ },
|
|
+
|
|
+ uninit() {
|
|
+ window.removeEventListener("windowlwthemeupdate", this);
|
|
+ window.removeEventListener("nativethemechange", this);
|
|
+ },
|
|
+
|
|
+ handleEvent(event) {
|
|
+ this.executeAllUpdates();
|
|
+ },
|
|
+
|
|
+ executeAllUpdates() {
|
|
+ this.updateAccentColorPref();
|
|
+ },
|
|
+
|
|
+ updateAccentColorPref() {
|
|
+ let root = document.documentElement;
|
|
+ const themeAccent = Services.prefs.getStringPref(
|
|
+ "zen.theme.accent-color",
|
|
+ "#0b57d0"
|
|
+ );
|
|
+ root.style.setProperty("--zen-primary-color", themeAccent);
|
|
+ },
|
|
+}
|