summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-04-23 22:19:53 +0300
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-04-28 22:39:08 +0300
commita66e6c9a2936aa2126e0e355825e6a969369da53 (patch)
treec5837b3194e98f313f9380e486a439f6c0ab1036
parente0a5e8fb777fc7744a89db0c9b53280aa0d5ddbb (diff)
p#479 make sure running app is the one handling urls
-rw-r--r--indra/newview/llappviewermacosx-objc.h1
-rw-r--r--indra/newview/llappviewermacosx-objc.mm25
-rw-r--r--indra/newview/llappviewermacosx.cpp15
-rw-r--r--indra/newview/llappviewermacosx.h1
4 files changed, 42 insertions, 0 deletions
diff --git a/indra/newview/llappviewermacosx-objc.h b/indra/newview/llappviewermacosx-objc.h
index 3fbf4202f1..bfbb48dadb 100644
--- a/indra/newview/llappviewermacosx-objc.h
+++ b/indra/newview/llappviewermacosx-objc.h
@@ -31,5 +31,6 @@
#include <vector>
void force_ns_sxeption();
+void register_url_schemes();
#endif // LL_LLAPPVIEWERMACOSX_OBJC_H
diff --git a/indra/newview/llappviewermacosx-objc.mm b/indra/newview/llappviewermacosx-objc.mm
index 96a6bc6edc..75d6b56e3e 100644
--- a/indra/newview/llappviewermacosx-objc.mm
+++ b/indra/newview/llappviewermacosx-objc.mm
@@ -38,3 +38,28 @@ void force_ns_sxeption()
NSException *exception = [NSException exceptionWithName:@"Forced NSException" reason:nullptr userInfo:nullptr];
@throw exception;
}
+
+void register_url_schemes()
+{
+ @autoreleasepool // Objective-C automatic memory tracking and release.
+ {
+ NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
+ NSURL *bundleURL = [NSURL fileURLWithPath:bundlePath];
+
+ // Force Launch Services to re-register this app bundle
+ OSStatus status = LSRegisterURL((__bridge CFURLRef)bundleURL, true);
+
+ if (status == noErr)
+ {
+ // Explicitly set this app as the default handler for our URL schemes
+ NSArray *schemes = @[@"secondlife", @"x-grid-location-info"];
+ NSString *bundleID = [[NSBundle mainBundle] bundleIdentifier];
+
+ for (NSString *scheme in schemes)
+ {
+ LSSetDefaultHandlerForURLScheme((__bridge CFStringRef)scheme,
+ (__bridge CFStringRef)bundleID);
+ }
+ }
+ }
+}
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp
index 2bd9c8661a..830e2d4473 100644
--- a/indra/newview/llappviewermacosx.cpp
+++ b/indra/newview/llappviewermacosx.cpp
@@ -412,6 +412,21 @@ bool LLAppViewerMacOSX::restoreErrorTrap()
return reset_count == 0;
}
+bool LLAppViewerMacOSX::initSLURLHandler()
+{
+ if (isSecondInstance())
+ {
+ return false;
+ }
+ // Main secondlife:// registration is in info.plist, but macOS
+ // Launch Services caches URL scheme handlers, and a different
+ // viewer might still be registered.
+ // Register URL schemes with Launch Services on every launch
+ register_url_schemes();
+
+ return true;
+}
+
std::string LLAppViewerMacOSX::generateSerialNumber()
{
char serial_md5[MD5HEX_STR_SIZE]; // Flawfinder: ignore
diff --git a/indra/newview/llappviewermacosx.h b/indra/newview/llappviewermacosx.h
index d50812a35e..35fc99dbd9 100644
--- a/indra/newview/llappviewermacosx.h
+++ b/indra/newview/llappviewermacosx.h
@@ -46,6 +46,7 @@ public:
protected:
virtual bool restoreErrorTrap();
+ virtual bool initSLURLHandler();
std::string generateSerialNumber();
virtual bool initParseCommandLine(LLCommandLineParser& clp);