Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public void OpenUrl(string url, bool? inPrivate = null);

/// <summary>
/// Opens the application URI.
/// </summary>
public void OpenAppUri(string appUri);
}
}
4 changes: 2 additions & 2 deletions Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
46 changes: 37 additions & 9 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -254,4 +282,4 @@ private bool KListener_hookedKeyboardCallback(KeyEvent keyevent, int vkcode, Spe

#endregion
}
}
}