From 5bd49e68abdfef034f959abf71209535460441c3 Mon Sep 17 00:00:00 2001 From: Erik Kundiman Date: Mon, 15 Jan 2024 11:30:07 +0800 Subject: Revive external web browser spawning on macOS --- indra/llwindow/llwindowsdl.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'indra/llwindow') diff --git a/indra/llwindow/llwindowsdl.cpp b/indra/llwindow/llwindowsdl.cpp index 4a1fb899a4..607e3f3782 100644 --- a/indra/llwindow/llwindowsdl.cpp +++ b/indra/llwindow/llwindowsdl.cpp @@ -72,6 +72,7 @@ static bool ATIbug = false; #include #include +#include BOOL gHiDPISupport = TRUE; @@ -2730,6 +2731,42 @@ void LLWindowSDL::spawnWebBrowser(const std::string& escaped_url, bool async) cmd += "launch_url.sh"; arg = escaped_url; exec_cmd(cmd, arg); + +#elif LL_DARWIN + + S32 result = 0; + CFURLRef urlRef = NULL; + + LL_INFOS() << "Opening URL " << escaped_url << LL_ENDL; + + CFStringRef stringRef = CFStringCreateWithCString(NULL, escaped_url.c_str(), kCFStringEncodingUTF8); + if (stringRef) + { + // This will succeed if the string is a full URL, including the http:// + // Note that URLs specified this way need to be properly percent-escaped. + urlRef = CFURLCreateWithString(NULL, stringRef, NULL); + + // Don't use CRURLCreateWithFileSystemPath -- only want valid URLs + + CFRelease(stringRef); + } + + if (urlRef) + { + result = LSOpenCFURLRef(urlRef, NULL); + + if (result != noErr) + { + LL_INFOS() << "Error " << result << " on open." << LL_ENDL; + } + + CFRelease(urlRef); + } + else + { + LL_INFOS() << "Error: couldn't create URL." << LL_ENDL; + } + #endif // LL_LINUX LL_INFOS() << "spawn_web_browser returning." << LL_ENDL; -- cgit v1.2.3