diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 133ad25a5cf..986710ab8cb 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -231,5 +231,10 @@ public interface IPublicAPI /// Opens the url. The browser and mode used is based on what's configured in Flow's default browser settings. /// public void OpenUrl(string url, bool? inPrivate = null); + + /// + /// Opens the application URI. + /// + public void OpenAppUri(string appUri); } } diff --git a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs index 6c4ac8ebf0a..6588132b940 100644 --- a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs +++ b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs @@ -60,7 +60,7 @@ public static void OpenInBrowserWindow(this string url, string browserPath = "", try { - Process.Start(psi); + Process.Start(psi)?.Dispose(); } catch (System.ComponentModel.Win32Exception) { @@ -100,7 +100,7 @@ public static void OpenInBrowserTab(this string url, string browserPath = "", bo psi.FileName = url; } - Process.Start(psi); + Process.Start(psi)?.Dispose(); } // This error may be thrown if browser path is incorrect catch (System.ComponentModel.Win32Exception) diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 5b490bede72..e3b7de31d5a 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -209,21 +209,49 @@ public void OpenDirectory(string DirectoryPath, string FileName = null) explorer.Start(); } - public void OpenUrl(string url, bool? inPrivate = null) + public void OpenUri(string url, bool? inPrivate = null, bool isAppUri = false) { - var browserInfo = _settingsVM.Settings.CustomBrowser; + var uri = new Uri(url); + if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) + { + var browserInfo = _settingsVM.Settings.CustomBrowser; - var path = browserInfo.Path == "*" ? "" : browserInfo.Path; + var path = browserInfo.Path == "*" ? "" : browserInfo.Path; - if (browserInfo.OpenInTab) - { - url.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg); + if (browserInfo.OpenInTab) + { + url.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg); + } + else + { + url.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg); + } + + return; } - else + + if (isAppUri) { - url.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg); + Process.Start(new ProcessStartInfo() + { + FileName = url, + UseShellExecute = true + })?.Dispose(); + + return; } + throw new InvalidOperationException("URI scheme not specified or supported "); + } + + public void OpenUrl(string url, bool? inPrivate = null) + { + OpenUri(url, inPrivate); + } + + public void OpenAppUri(string appUri) + { + OpenUri(appUri, isAppUri: true); } public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent; @@ -254,4 +282,4 @@ private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, Spe #endregion } -} +} \ No newline at end of file