commit 41c69226acc71bbe6793d74b8c2e5aa8b561f322
parent ad17dd8f624b75cf638ebc4057a04fff374b9a3c
Author: Josh Aas <jaas@kflag.net>
Date: Wed, 5 Nov 2025 14:04:05 +0000
Bug 1998336 - remove unnecessary code in nsOSHelperAppService for macOS. r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D271354
Diffstat:
1 file changed, 18 insertions(+), 35 deletions(-)
diff --git a/uriloader/exthandler/mac/nsOSHelperAppService.mm b/uriloader/exthandler/mac/nsOSHelperAppService.mm
@@ -24,11 +24,6 @@
#import <CoreFoundation/CoreFoundation.h>
#import <ApplicationServices/ApplicationServices.h>
-// chrome URL's
-#define HELPERAPPLAUNCHER_BUNDLE_URL \
- "chrome://global/locale/helperAppLauncher.properties"
-#define BRAND_BUNDLE_URL "chrome://branding/locale/brand.properties"
-
nsresult GetDefaultBundleURL(const nsACString& aScheme, CFURLRef* aBundleURL) {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
@@ -210,46 +205,34 @@ nsresult nsOSHelperAppService::GetFileTokenForPath(
const char16_t* aPlatformAppPath, nsIFile** aFile) {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
- CFURLRef pathAsCFURL;
CFStringRef pathAsCFString = ::CFStringCreateWithCharacters(
NULL, reinterpret_cast<const UniChar*>(aPlatformAppPath),
NS_strlen(aPlatformAppPath));
- if (!pathAsCFString) return NS_ERROR_OUT_OF_MEMORY;
-
- if (::CFStringGetCharacterAtIndex(pathAsCFString, 0) == '/') {
- // we have a Posix path
- pathAsCFURL = ::CFURLCreateWithFileSystemPath(nullptr, pathAsCFString,
- kCFURLPOSIXPathStyle, false);
- if (!pathAsCFURL) {
- ::CFRelease(pathAsCFString);
- return NS_ERROR_OUT_OF_MEMORY;
- }
- } else {
- // if it doesn't start with a / it's not an absolute Posix path
- // let's check if it's a HFS path left over from old preferences
-
- // If it starts with a ':' char, it's not an absolute HFS path
- // so bail for that, and also if it's empty
- if (::CFStringGetLength(pathAsCFString) == 0 ||
- ::CFStringGetCharacterAtIndex(pathAsCFString, 0) == ':') {
- ::CFRelease(pathAsCFString);
- return NS_ERROR_FILE_UNRECOGNIZED_PATH;
- }
+ if (!pathAsCFString) {
+ return NS_ERROR_FAILURE;
+ }
- pathAsCFURL = ::CFURLCreateWithFileSystemPath(nullptr, pathAsCFString,
- kCFURLHFSPathStyle, false);
- if (!pathAsCFURL) {
- ::CFRelease(pathAsCFString);
- return NS_ERROR_OUT_OF_MEMORY;
- }
+ // Require a posix path
+ if (::CFStringGetCharacterAtIndex(pathAsCFString, 0) != '/') {
+ ::CFRelease(pathAsCFString);
+ return NS_ERROR_FILE_UNRECOGNIZED_PATH;
+ }
+
+ CFURLRef pathAsCFURL = ::CFURLCreateWithFileSystemPath(
+ nullptr, pathAsCFString, kCFURLPOSIXPathStyle, false);
+ ::CFRelease(pathAsCFString);
+ if (!pathAsCFURL) {
+ return NS_ERROR_FAILURE;
}
nsCOMPtr<nsILocalFileMac> localFile;
nsresult rv =
NS_NewLocalFileWithCFURL(pathAsCFURL, getter_AddRefs(localFile));
- ::CFRelease(pathAsCFString);
::CFRelease(pathAsCFURL);
- if (NS_FAILED(rv)) return rv;
+ if (NS_FAILED(rv)) {
+ return rv;
+ }
+
*aFile = localFile;
NS_IF_ADDREF(*aFile);