mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #968 from Flow-Launcher/websearchUri
Support Application Uri in OpenUrl API call
This commit is contained in:
commit
af313ebb78
3 changed files with 48 additions and 15 deletions
|
|
@ -231,5 +231,10 @@ namespace Flow.Launcher.Plugin
|
||||||
/// Opens the url. The browser and mode used is based on what's configured in Flow's default browser settings.
|
/// Opens the url. The browser and mode used is based on what's configured in Flow's default browser settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OpenUrl(string url, bool? inPrivate = null);
|
public void OpenUrl(string url, bool? inPrivate = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens the application URI.
|
||||||
|
/// </summary>
|
||||||
|
public void OpenAppUri(string appUri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(psi);
|
Process.Start(psi)?.Dispose();
|
||||||
}
|
}
|
||||||
catch (System.ComponentModel.Win32Exception)
|
catch (System.ComponentModel.Win32Exception)
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +100,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
||||||
psi.FileName = url;
|
psi.FileName = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
Process.Start(psi);
|
Process.Start(psi)?.Dispose();
|
||||||
}
|
}
|
||||||
// This error may be thrown if browser path is incorrect
|
// This error may be thrown if browser path is incorrect
|
||||||
catch (System.ComponentModel.Win32Exception)
|
catch (System.ComponentModel.Win32Exception)
|
||||||
|
|
|
||||||
|
|
@ -209,21 +209,49 @@ namespace Flow.Launcher
|
||||||
explorer.Start();
|
explorer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OpenUri(string url, bool? inPrivate = null, bool isAppUri = false)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (browserInfo.OpenInTab)
|
||||||
|
{
|
||||||
|
url.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAppUri)
|
||||||
|
{
|
||||||
|
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)
|
public void OpenUrl(string url, bool? inPrivate = null)
|
||||||
{
|
{
|
||||||
var browserInfo = _settingsVM.Settings.CustomBrowser;
|
OpenUri(url, inPrivate);
|
||||||
|
}
|
||||||
var path = browserInfo.Path == "*" ? "" : browserInfo.Path;
|
|
||||||
|
|
||||||
if (browserInfo.OpenInTab)
|
|
||||||
{
|
|
||||||
url.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public void OpenAppUri(string appUri)
|
||||||
|
{
|
||||||
|
OpenUri(appUri, isAppUri: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
|
public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent;
|
||||||
|
|
@ -254,4 +282,4 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue