diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 76c7a4911..f47ee5e11 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -336,13 +336,28 @@ namespace Flow.Launcher.Plugin public void OpenDirectory(string DirectoryPath, string FileNameOrFilePath = null); /// - /// Opens the URL with the given Uri object. + /// 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 in browser if scheme is Http or Https. + /// If the URL is a local file, it will instead be opened with the default application for that file type. /// The browser and mode used is based on what's configured in Flow's default browser settings. /// public void OpenUrl(Uri url, bool? inPrivate = null); /// - /// Opens the URL with the given string. + /// Opens the URL with the given string in browser if scheme is Http or Https. + /// If the URL is a local file, it will instead be opened with the default application for that file type. /// The browser and mode used is based on what's configured in Flow's default browser settings. /// Non-C# plugins should use this method. /// diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index c125ea00f..6e82032ff 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -400,10 +400,9 @@ namespace Flow.Launcher } } - - 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; @@ -444,6 +443,16 @@ namespace Flow.Launcher } } + 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 76aeb3250..0040cffa7 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -71,7 +71,7 @@ namespace Flow.Launcher.Plugin.WebSearch 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 @@ namespace Flow.Launcher.Plugin.WebSearch 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; },