diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index cb60251ed95..b87cc52d0ab 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -305,6 +305,19 @@ public interface IPublicAPI /// Extra FileName Info public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null); + /// + /// Opens the URL using the browser with the given Uri object, even if the URL is a local file. + /// The browser and mode used is based on what's configured in Flow's default browser settings. + /// + public void OpenWebUrl(Uri url, bool? inPrivate = null); + + /// + /// Opens the URL using the browser with the given string, even if the URL is a local file. + /// The browser and mode used is based on what's configured in Flow's default browser settings. + /// Non-C# plugins should use this method. + /// + public void OpenWebUrl(string url, bool? inPrivate = null); + /// /// Opens the URL with the given Uri object. /// The browser and mode used is based on what's configured in Flow's default browser settings. diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index c06c5603991..b4a6b47b7f4 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -390,10 +390,9 @@ public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null } } - - private void OpenUri(Uri uri, bool? inPrivate = null) + private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) { - if (uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) + if (forceBrowser || uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) { var browserInfo = _settings.CustomBrowser; @@ -420,6 +419,16 @@ private void OpenUri(Uri uri, bool? inPrivate = null) } } + public void OpenWebUrl(string url, bool? inPrivate = null) + { + OpenUri(new Uri(url), inPrivate, true); + } + + public void OpenWebUrl(Uri url, bool? inPrivate = null) + { + OpenUri(url, inPrivate, true); + } + public void OpenUrl(string url, bool? inPrivate = null) { OpenUri(new Uri(url), inPrivate); diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 76aeb3250b1..0040cffa7da 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -71,7 +71,7 @@ public async Task> QueryAsync(Query query, CancellationToken token) Score = score, Action = c => { - _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword))); + _context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword))); return true; }, @@ -135,7 +135,7 @@ private async Task> SuggestionsAsync(string keyword, string ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword, Action = c => { - _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o))); + _context.API.OpenWebUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(o))); return true; },