mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 22:43:31 +08:00
Reverse out common open browser call and update open browser in tab
This commit is contained in:
parent
3e292d7604
commit
adb2582856
@ -36,22 +36,19 @@ namespace Wox.Plugin.SharedCommands
|
||||
/// Opens search as a tab in the default browser chosen in Windows settings.
|
||||
/// </summary>
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
Process.Start(url);
|
||||
|
Loading…
Reference in New Issue
Block a user