diff --git a/Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewModel.cs b/Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewModel.cs index 009b27666e8..6bfdefa98cc 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewModel.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/CustomBrowserViewModel.cs @@ -10,6 +10,7 @@ public class CustomBrowserViewModel : BaseModel public string DisplayName => Name == "Default" ? Localize.defaultBrowser_default() : Name; public string Path { get; set; } public string PrivateArg { get; set; } + public string ExtraArgs { get; set; } public bool EnablePrivate { get; set; } public bool OpenInTab { get; set; } = true; [JsonIgnore] @@ -24,6 +25,7 @@ public CustomBrowserViewModel Copy() Path = Path, OpenInTab = OpenInTab, PrivateArg = PrivateArg, + ExtraArgs = ExtraArgs, EnablePrivate = EnablePrivate, Editable = Editable }; diff --git a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs index ed3e91daf43..1b4f780a372 100644 --- a/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs +++ b/Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs @@ -38,7 +38,7 @@ private static string GetDefaultBrowserPath() /// 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 OpenInBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "") + public static void OpenInBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "", string extraArgs = "") { browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath; @@ -52,12 +52,15 @@ public static void OpenInBrowserWindow(this string url, string browserPath = "", 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" ? "" : "--new-window ") + (inPrivate ? $"{privateArg} " : "") + url; + var browserArguments = (browserExecutableName == "iexplore.exe" ? "" : "--new-window ") + + (inPrivate ? $"{privateArg} " : "") + + (string.IsNullOrWhiteSpace(extraArgs) ? "" : $"{extraArgs} ") + + url; var psi = new ProcessStartInfo { FileName = browser, - Arguments = browserArguements, + Arguments = browserArguments, UseShellExecute = true }; @@ -86,7 +89,7 @@ public static void OpenInBrowserWindow(this string url, string browserPath = "", /// /// Opens search as a tab in the default browser chosen in Windows settings. /// - public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "") + public static void OpenInBrowserTab(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "", string extraArgs = "") { browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath; @@ -99,7 +102,9 @@ public static void OpenInBrowserTab(this string url, string browserPath = "", bo if (!string.IsNullOrEmpty(browserPath)) { psi.FileName = browserPath; - psi.Arguments = (inPrivate ? $"{privateArg} " : "") + url; + psi.Arguments = (inPrivate ? $"{privateArg} " : "") + + (string.IsNullOrWhiteSpace(extraArgs) ? "" : $"{extraArgs} ") + + url; } else { diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 02c7becacca..cde09f9915a 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -518,6 +518,7 @@ New Window New Tab Private Mode + Extra Args Default New Profile diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs index b939cfb5a5e..5cefd2298cb 100644 --- a/Flow.Launcher/PublicAPIInstance.cs +++ b/Flow.Launcher/PublicAPIInstance.cs @@ -454,17 +454,20 @@ private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false) { if (browserInfo.OpenInTab) { - uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg); + uri.AbsoluteUri.OpenInBrowserTab(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg, browserInfo.ExtraArgs); } else { - uri.AbsoluteUri.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg); + uri.AbsoluteUri.OpenInBrowserWindow(path, inPrivate ?? browserInfo.EnablePrivate, browserInfo.PrivateArg, browserInfo.ExtraArgs); } } catch (Exception e) { var tabOrWindow = browserInfo.OpenInTab ? "tab" : "window"; - LogException(ClassName, $"Failed to open URL in browser {tabOrWindow}: {path}, {inPrivate ?? browserInfo.EnablePrivate}, {browserInfo.PrivateArg}", e); + var includesExtraArgs = string.IsNullOrWhiteSpace(browserInfo.ExtraArgs) + ? "" + : ", [including omitted Extra Args]"; + LogException(ClassName, $"Failed to open URL in browser {tabOrWindow}: {path}, {inPrivate ?? browserInfo.EnablePrivate}, {browserInfo.PrivateArg}{includesExtraArgs}", e); ShowMsgError( Localize.errorTitle(), Localize.browserOpenError() diff --git a/Flow.Launcher/SelectBrowserWindow.xaml b/Flow.Launcher/SelectBrowserWindow.xaml index 8af33206cd8..8cd33de8138 100644 --- a/Flow.Launcher/SelectBrowserWindow.xaml +++ b/Flow.Launcher/SelectBrowserWindow.xaml @@ -126,6 +126,7 @@ + @@ -230,6 +231,21 @@ + +