diff --git a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs index 5743181ed..68667f50a 100644 --- a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs +++ b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs @@ -35,7 +35,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// Opens search in a new browser. If no browser path is passed in then Chrome is used. /// Leave browser path blank to use Chrome. /// - public static void NewBrowserWindow(this string url, string browserPath = "", bool inPrivate = false) + public static void NewBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "") { browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath; @@ -46,7 +46,7 @@ namespace Flow.Launcher.Plugin.SharedCommands var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath; // Internet Explorer will open url in new browser window, and does not take the --new-window parameter - var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url; + var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url + (inPrivate ? "" : privateArg); var psi = new ProcessStartInfo { @@ -68,7 +68,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// /// Opens search as a tab in the default browser chosen in Windows settings. /// - public static void NewTabInBrowser(this string url, string browserPath = "", bool inPrivate = false) + public static void NewTabInBrowser(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "") { browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath; @@ -78,7 +78,7 @@ namespace Flow.Launcher.Plugin.SharedCommands if (!string.IsNullOrEmpty(browserPath)) { psi.FileName = browserPath; - psi.Arguments = url + (inPrivate ? "" : "-inprivate"); + psi.Arguments = url + (inPrivate ? "" : privateArg); } else { diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index 9b2e1bd48..4c93fe3cc 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -216,23 +216,14 @@ namespace Flow.Launcher var path = browserInfo.Path == "*" ? "" : browserInfo.Path; - if (browserInfo.Path == "Default") + if (browserInfo.OpenInTab) { - if (browserInfo.OpenInTab) - SearchWeb.NewTabInBrowser(url); - else - SearchWeb.NewBrowserWindow(url); - return; + SearchWeb.NewTabInBrowser(url, path, browserInfo.EnablePrivate, browserInfo.PrivateArg); + }else + { + SearchWeb.NewBrowserWindow(url, path, browserInfo.EnablePrivate, browserInfo.PrivateArg); } - var browserStartInfo = new ProcessStartInfo() - { - FileName = browserInfo.Path - }; - browserStartInfo.ArgumentList.Add(url); - - if(browserInfo.EnablePrivate) - browserStartInfo.ArgumentList.Add(browserInfo.PrivateArg); } public event FlowLauncherGlobalKeyboardEventHandler GlobalKeyboardEvent; diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 27726c30f..d389d8d5c 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -257,7 +257,7 @@ namespace Flow.Launcher private void OnRequestNavigate(object sender, RequestNavigateEventArgs e) { - e.Uri.AbsoluteUri.NewTabInBrowser(); + API.OpenUrl(e.Uri.AbsoluteUri); e.Handled = true; } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 1d666426f..5d817672d 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -191,7 +191,7 @@ namespace Flow.Launcher.ViewModel StartHelpCommand = new RelayCommand(_ => { - SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); + PluginManager.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher/wiki/Flow-Launcher/"); }); OpenSettingCommand = new RelayCommand(_ => { App.API.OpenSettingDialog(); }); OpenResultCommand = new RelayCommand(index => diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs index 035ae629a..a20e5a267 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/ContextMenu.cs @@ -29,7 +29,7 @@ namespace Flow.Launcher.Plugin.PluginsManager IcoPath = selectedResult.IcoPath, Action = _ => { - SharedCommands.SearchWeb.NewTabInBrowser(pluginManifestInfo.Website); + Context.API.OpenUrl(pluginManifestInfo.Website); return true; } }, @@ -40,7 +40,7 @@ namespace Flow.Launcher.Plugin.PluginsManager IcoPath = "Images\\sourcecode.png", Action = _ => { - SharedCommands.SearchWeb.NewTabInBrowser(pluginManifestInfo.UrlSourceCode); + Context.API.OpenUrl(pluginManifestInfo.UrlSourceCode); return true; } }, @@ -56,7 +56,7 @@ namespace Flow.Launcher.Plugin.PluginsManager ? pluginManifestInfo.UrlSourceCode.Replace("/tree/master", "/issues/new/choose") : pluginManifestInfo.UrlSourceCode; - SharedCommands.SearchWeb.NewTabInBrowser(link); + Context.API.OpenUrl(link); return true; } }, @@ -67,7 +67,7 @@ namespace Flow.Launcher.Plugin.PluginsManager IcoPath = "Images\\manifestsite.png", Action = _ => { - SharedCommands.SearchWeb.NewTabInBrowser("https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest"); + Context.API.OpenUrl("https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest"); return true; } } diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs index 6208fc000..7b5d85ae9 100644 --- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs @@ -315,7 +315,7 @@ namespace Flow.Launcher.Plugin.Sys IcoPath = "Images\\app.png", Action = c => { - SearchWeb.NewTabInBrowser(Constant.Documentation); + context.API.OpenUrl(Constant.Documentation); return true; } }, diff --git a/Plugins/Flow.Launcher.Plugin.Url/Main.cs b/Plugins/Flow.Launcher.Plugin.Url/Main.cs index 0f4b6c117..9d5b528ec 100644 --- a/Plugins/Flow.Launcher.Plugin.Url/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Url/Main.cs @@ -68,14 +68,7 @@ namespace Flow.Launcher.Plugin.Url } try { - if (_settings.OpenInNewBrowserWindow) - { - raw.NewBrowserWindow(_settings.BrowserPath); - } - else - { - raw.NewTabInBrowser(_settings.BrowserPath); - } + context.API.OpenUrl(raw); return true; } diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 8d8c84392..1394e8c15 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -74,14 +74,7 @@ namespace Flow.Launcher.Plugin.WebSearch Score = score, Action = c => { - if (_settings.OpenInNewBrowser) - { - searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewBrowserWindow(_settings.BrowserPath); - } - else - { - searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword)).NewTabInBrowser(_settings.BrowserPath); - } + _context.API.OpenUrl(searchSource.Url.Replace("{q}", Uri.EscapeDataString(keyword))); return true; } @@ -143,14 +136,7 @@ namespace Flow.Launcher.Plugin.WebSearch ActionKeywordAssigned = searchSource.ActionKeyword == SearchSourceGlobalPluginWildCardSign ? string.Empty : searchSource.ActionKeyword, Action = c => { - if (_settings.OpenInNewBrowser) - { - searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewBrowserWindow(_settings.BrowserPath); - } - else - { - searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)).NewTabInBrowser(_settings.BrowserPath); - } + searchSource.Url.Replace("{q}", Uri.EscapeDataString(o)); return true; }