From a7c5a02b1e5515e04e88068d9125b4078b5137a0 Mon Sep 17 00:00:00 2001 From: LibreWolf Developers Date: Sun, 6 Sep 2026 10:10:30 +0100 Subject: [PATCH 21/52] mozilla_dirs.patch --- .../extensions/NativeManifests.sys.mjs | 2 + toolkit/xre/nsXREDirProvider.cpp | 54 ++++++++----------- xpcom/build/nsXULAppAPI.h | 2 + 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/toolkit/components/extensions/NativeManifests.sys.mjs b/toolkit/components/extensions/NativeManifests.sys.mjs index 48d7d50cdec3..fbf39fba0d3a 100644 --- a/toolkit/components/extensions/NativeManifests.sys.mjs +++ b/toolkit/components/extensions/NativeManifests.sys.mjs @@ -37,6 +37,8 @@ export var NativeManifests = { let dirs = [ Services.dirsvc.get("XREUserNativeManifests", Ci.nsIFile).path, Services.dirsvc.get("XRESysNativeManifests", Ci.nsIFile).path, + Services.dirsvc.get("XREMozUserNativeManifests", Ci.nsIFile).path, + Services.dirsvc.get("XREMozSysNativeManifests", Ci.nsIFile).path, ]; this._lookup = (type, name, context) => this._tryPaths(type, name, dirs, context); diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index dcce3335e14f..004c767956f2 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -332,23 +332,25 @@ nsresult nsXREDirProvider::GetBackgroundTasksProfilesRootDir( * On Linux this is /usr/{lib,lib64}/mozilla * (for 32- and 64-bit systems respsectively) */ -static nsresult GetSystemParentDirectory(nsIFile** aFile) { +static nsresult GetSystemParentDirectory(nsIFile** aFile, + nsCString aName = "LibreWolf"_ns) { nsresult rv; nsCOMPtr localDir; # if defined(XP_MACOSX) rv = GetOSXFolderType(kOnSystemDisk, kApplicationSupportFolderType, getter_AddRefs(localDir)); if (NS_SUCCEEDED(rv)) { - rv = localDir->AppendNative("Mozilla"_ns); + rv = localDir->AppendNative(aName); } # else - constexpr auto dirname = + ToLowerCase(aName); + nsCString dirname = # ifdef HAVE_USR_LIB64_DIR - "/usr/lib64/mozilla"_ns + "/usr/lib64/"_ns + aName # elif defined(__OpenBSD__) || defined(__FreeBSD__) - "/usr/local/lib/mozilla"_ns + "/usr/local/lib/"_ns + aName # else - "/usr/lib/mozilla"_ns + "/usr/lib/"_ns + aName # endif ; rv = NS_NewNativeLocalFile(dirname, getter_AddRefs(localDir)); @@ -416,11 +418,21 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent, #if defined(XP_UNIX) || defined(XP_MACOSX) else if (!strcmp(aProperty, XRE_SYS_NATIVE_MANIFESTS)) { rv = ::GetSystemParentDirectory(getter_AddRefs(file)); + } else if (!strcmp(aProperty, XRE_MOZ_SYS_NATIVE_MANIFESTS)) { + rv = ::GetSystemParentDirectory(getter_AddRefs(file), "Mozilla"_ns); } else if (!strcmp(aProperty, XRE_USER_NATIVE_MANIFESTS)) { // Keep forcing the legacy path for compatibility rv = GetUserDataDirectoryHome(getter_AddRefs(file), /* aLocal */ false, /* aForceLegacy */ true); NS_ENSURE_SUCCESS(rv, rv); +# if defined(XP_MACOSX) + rv = file->AppendNative("LibreWolf"_ns); +# else // defined(XP_MACOSX) + rv = file->AppendNative(".librewolf"_ns); +# endif // defined(XP_MACOSX) + } else if (!strcmp(aProperty, XRE_MOZ_USER_NATIVE_MANIFESTS)) { + rv = GetUserDataDirectoryHome(getter_AddRefs(file), false, true); + NS_ENSURE_SUCCESS(rv, rv); # if defined(XP_MACOSX) rv = file->AppendNative("Mozilla"_ns); # else // defined(XP_MACOSX) @@ -454,9 +466,9 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent, else if (!strcmp(aProperty, XRE_SYS_SHARE_EXTENSION_PARENT_DIR)) { # ifdef ENABLE_SYSTEM_EXTENSION_DIRS # if defined(__OpenBSD__) || defined(__FreeBSD__) - static const char* const sysLExtDir = "/usr/local/share/mozilla/extensions"; + static const char* const sysLExtDir = "/usr/local/share/librewolf/extensions"; # else - static const char* const sysLExtDir = "/usr/share/mozilla/extensions"; + static const char* const sysLExtDir = "/usr/share/librewolf/extensions"; # endif rv = NS_NewNativeLocalFile(nsDependentCString(sysLExtDir), getter_AddRefs(file)); @@ -980,13 +992,7 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile** aResult, } appDirPath = Substring(appDirPath, 1, dotIndex - 1); - bool hasVendor = GetAppVendor() && strlen(GetAppVendor()) != 0; - if (hasVendor || GetAppName()) { - if (NS_FAILED(localDir->AppendNative( - nsDependentCString(hasVendor ? GetAppVendor() : GetAppName())))) { - return NS_ERROR_FAILURE; - } - } else if (NS_FAILED(localDir->AppendNative("Mozilla"_ns))) { + if (NS_FAILED(localDir->AppendNative("LibreWolf"_ns))) { return NS_ERROR_FAILURE; } @@ -1284,7 +1290,7 @@ nsresult nsXREDirProvider::AppendSysUserExtensionPath(nsIFile* aFile) { #if defined(XP_MACOSX) || defined(XP_WIN) - static const char* const sXR = "Mozilla"; + static const char* const sXR = "LibreWolf"; rv = aFile->AppendNative(nsDependentCString(sXR)); NS_ENSURE_SUCCESS(rv, rv); @@ -1294,7 +1300,7 @@ nsresult nsXREDirProvider::AppendSysUserExtensionPath(nsIFile* aFile) { #elif defined(XP_UNIX) - static const char* const sXR = ".mozilla"; + static const char* const sXR = ".librewolf"; rv = aFile->AppendNative(nsDependentCString(sXR)); NS_ENSURE_SUCCESS(rv, rv); @@ -1599,10 +1605,6 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) { if (!profile.IsEmpty()) { rv = AppendProfileString(aFile, profile.get()); } else { - if (!vendor.IsEmpty()) { - rv = aFile->AppendNative(vendor); - NS_ENSURE_SUCCESS(rv, rv); - } rv = aFile->AppendNative(appName); } NS_ENSURE_SUCCESS(rv, rv); @@ -1640,16 +1642,6 @@ nsresult nsXREDirProvider::AppendProfilePath(nsIFile* aFile, bool aLocal) { rv = AppendProfileString(aFile, folder.get()); } else { - if (!vendor.IsEmpty()) { - folder.Append(vendor); - ToLowerCase(folder); - - rv = aFile->AppendNative(folder); - NS_ENSURE_SUCCESS(rv, rv); - - folder.Truncate(); - } - // This can be the case in tests. if (!appName.IsEmpty()) { folder.Append(appName); diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 8a09115312f2..f8c623b611d4 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -113,6 +113,8 @@ struct BootstrapConfig; */ # define XRE_SYS_NATIVE_MANIFESTS "XRESysNativeManifests" # define XRE_USER_NATIVE_MANIFESTS "XREUserNativeManifests" +# define XRE_MOZ_SYS_NATIVE_MANIFESTS "XREMozSysNativeManifests" +# define XRE_MOZ_USER_NATIVE_MANIFESTS "XREMozUserNativeManifests" #endif /** -- 2.47.3