Skip to content

Commit ead7d18

Browse files
committed
linuxsessionmgr: make browser detection more robust
Now that we know how to launch a browser via $BROWSER (if set), we should adjust our `IsWebBrowserAvailable` check for Linux. In both WSL and non-WSL (native Linux) environments we immediately return true when $BROWSER is set. VSCode remote tunnels set the $BROWSER variable to a script that redirects requests back to the client's browser, for example. In non-WSL environments we also make our checks for a browser more robust by checking for a 'shell execute' handler (like xdg-open). Previously we just relied on a desktop session ($DISPLAY or $WAYLAND_DISPLAY), which isn't accurate since in BrowserUtils::OpenDefaultBrowser we require a shell execute handler (or $BROWSER). The check and implementation are now aligned! Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
1 parent 3701a50 commit ead7d18

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

src/shared/Core/Interop/Linux/LinuxSessionManager.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,21 @@ public override bool IsWebBrowserAvailable
2121

2222
private bool GetWebBrowserAvailable()
2323
{
24+
if (BrowserUtils.TryGetBrowserEnvironment(Environment, out _))
25+
{
26+
return true;
27+
}
28+
29+
// We need a shell execute handler to be able to launch to browser
30+
if (!BrowserUtils.TryGetLinuxShellExecuteHandler(Environment, out _))
31+
{
32+
return false;
33+
}
34+
2435
// If this is a Windows Subsystem for Linux distribution we may
2536
// be able to launch the web browser of the host Windows OS.
2637
if (WslUtils.IsWslDistribution(Environment, FileSystem, out _))
2738
{
28-
// We need a shell execute handler to be able to launch to browser
29-
if (!BrowserUtils.TryGetLinuxShellExecuteHandler(Environment, out _))
30-
{
31-
return false;
32-
}
33-
3439
//
3540
// If we are in Windows logon session 0 then the user can never interact,
3641
// even in the WinSta0 window station. This is typical when SSH-ing into a
@@ -55,10 +60,9 @@ private bool GetWebBrowserAvailable()
5560

5661
// If we are not in session 0, or we cannot get the Windows session ID,
5762
// assume that we *CAN* launch the browser so that users are never blocked.
58-
return true;
63+
// Fall through to return true.
5964
}
6065

61-
// We require an interactive desktop session to be able to launch a browser
62-
return IsDesktopSession;
66+
return true;
6367
}
6468
}

0 commit comments

Comments
 (0)