[tbb-commits] [Git][tpo/applications/tor-browser][base-browser-128.4.0esr-14.5-1] Bug 42739: Use the brand name for profile error messages.

morgan (@morgan) git at gitlab.torproject.org
Tue Oct 29 20:48:25 UTC 2024



morgan pushed to branch base-browser-128.4.0esr-14.5-1 at The Tor Project / Applications / Tor Browser


Commits:
b64a2539 by Henry Wilkes at 2024-10-29T20:48:07+00:00
Bug 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.

- - - - -


2 changed files:

- toolkit/xre/ProfileReset.cpp
- toolkit/xre/nsAppRunner.cpp


Changes:

=====================================
toolkit/xre/ProfileReset.cpp
=====================================
@@ -23,8 +23,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";
 
@@ -49,12 +49,21 @@ nsresult ProfileResetCleanup(nsToolkitProfileService* aService,
       mozilla::components::StringBundle::Service();
   if (!sbs) return NS_ERROR_FAILURE;
 
+  nsCOMPtr<nsIStringBundle> brandBundle;
+  Unused << sbs->CreateBundle(kBrandProperties, getter_AddRefs(brandBundle));
+  if (!brandBundle) return NS_ERROR_FAILURE;
+
   nsCOMPtr<nsIStringBundle> sb;
   Unused << 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;
 


=====================================
toolkit/xre/nsAppRunner.cpp
=====================================
@@ -2597,6 +2597,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";
 
@@ -2666,12 +2668,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;
@@ -2733,12 +2743,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



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/b64a2539c96e468bdc0e03c8e6267075a6df3450

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/b64a2539c96e468bdc0e03c8e6267075a6df3450
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20241029/a4b4d7a5/attachment-0001.htm>


More information about the tbb-commits mailing list