commit e23fbe6f7f06355cb5e1d5a8d68fea0cd8fffe0f
parent f2ad98ff0b52cdbecad1499dc6cc31fa2293aa06
Author: Henry Wilkes <henry@torproject.org>
Date: Mon, 7 Oct 2024 10:46:23 +0100
BB 42739: Use the brand name for profile error messages.
Some messages in profileSelection.properties use gAppData->name as
variable inputs. However, gAppData->name is still "Firefox" for our
base-browser builds, rather than the user-facing browser name. We swap
these instances with the displayed brand name instead.
Diffstat:
2 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/toolkit/xre/ProfileReset.cpp b/toolkit/xre/ProfileReset.cpp
@@ -22,8 +22,8 @@
using namespace mozilla;
-extern const XREAppData* gAppData;
-
+static const char kBrandProperties[] =
+ "chrome://branding/locale/brand.properties";
static const char kProfileProperties[] =
"chrome://mozapps/locale/profile/profileSelection.properties";
@@ -48,12 +48,21 @@ nsresult ProfileResetCleanup(nsToolkitProfileService* aService,
mozilla::components::StringBundle::Service();
if (!sbs) return NS_ERROR_FAILURE;
+ nsCOMPtr<nsIStringBundle> brandBundle;
+ (void)sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle));
+ if (!brandBundle) return NS_ERROR_FAILURE;
+
nsCOMPtr<nsIStringBundle> sb;
(void)sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
if (!sb) return NS_ERROR_FAILURE;
- NS_ConvertUTF8toUTF16 appName(gAppData->name);
- AutoTArray<nsString, 2> params = {appName, appName};
+ nsAutoString appName;
+ rv = brandBundle->GetStringFromName("brandShortName", appName);
+ if (NS_FAILED(rv)) return rv;
+
+ AutoTArray<nsString, 2> params;
+ params.AppendElement(appName);
+ params.AppendElement(appName);
nsAutoString resetBackupDirectoryName;
diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
@@ -2657,6 +2657,8 @@ nsresult LaunchChild(bool aBlankCommandLine, bool aTryExec) {
return NS_ERROR_LAUNCHED_CHILD_PROCESS;
}
+static const char kBrandProperties[] =
+ "chrome://branding/locale/brand.properties";
static const char kProfileProperties[] =
"chrome://mozapps/locale/profile/profileSelection.properties";
@@ -2730,12 +2732,20 @@ static nsresult ProfileMissingDialog(nsINativeAppSupport* aNative) {
mozilla::components::StringBundle::Service();
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIStringBundle> brandBundle;
+ sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle));
+ NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> sb;
sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
- NS_ConvertUTF8toUTF16 appName(gAppData->name);
- AutoTArray<nsString, 2> params = {appName, appName};
+ nsAutoString appName;
+ rv = brandBundle->GetStringFromName("brandShortName", appName);
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
+
+ AutoTArray<nsString, 2> params;
+ params.AppendElement(appName);
+ params.AppendElement(appName);
// profileMissing
nsAutoString missingMessage;
@@ -2799,12 +2809,21 @@ static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir,
mozilla::components::StringBundle::Service();
NS_ENSURE_TRUE(sbs, NS_ERROR_FAILURE);
+ nsCOMPtr<nsIStringBundle> brandBundle;
+ sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle));
+ NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> sb;
sbs->CreateBundle(kProfileProperties, getter_AddRefs(sb));
NS_ENSURE_TRUE_LOG(sbs, NS_ERROR_FAILURE);
- NS_ConvertUTF8toUTF16 appName(gAppData->name);
- AutoTArray<nsString, 3> params = {appName, appName, appName};
+ nsAutoString appName;
+ rv = brandBundle->GetStringFromName("brandShortName", appName);
+ NS_ENSURE_SUCCESS(rv, NS_ERROR_ABORT);
+
+ AutoTArray<nsString, 3> params;
+ params.AppendElement(appName);
+ params.AppendElement(appName);
+ params.AppendElement(appName);
nsAutoString killMessage;
#ifndef XP_MACOSX