mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
Reverse out common open browser call and update open browser in tab
This commit is contained in:
@@ -36,22 +36,19 @@ namespace Wox.Plugin.SharedCommands
|
|||||||
/// Opens search as a tab in the default browser chosen in Windows settings.
|
/// Opens search as a tab in the default browser chosen in Windows settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void NewTabInBrowser(this string url, string browserPath)
|
public static void NewTabInBrowser(this string url, string browserPath)
|
||||||
{
|
|
||||||
var browserExecutableName = browserPath?
|
|
||||||
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
|
|
||||||
.Last();
|
|
||||||
|
|
||||||
var selectedBrowserPath = string.IsNullOrEmpty(browserExecutableName) ? "" : browserPath;
|
|
||||||
|
|
||||||
OpenWebSearch(selectedBrowserPath, "", url);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void OpenWebSearch(string chosenBrowser, string browserArguements, string url)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(chosenBrowser, browserArguements + url);
|
if (!string.IsNullOrEmpty(browserPath))
|
||||||
|
{
|
||||||
|
Process.Start(browserPath, url);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Process.Start(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// This error may be thrown for Process.Start(browserPath, url)
|
||||||
catch (System.ComponentModel.Win32Exception)
|
catch (System.ComponentModel.Win32Exception)
|
||||||
{
|
{
|
||||||
Process.Start(url);
|
Process.Start(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user