Use Global Browser Setting around flow

This commit is contained in:
Kevin Zhang 2021-12-05 13:34:23 -06:00
parent 47562eabf3
commit d8eef69e21
8 changed files with 19 additions and 49 deletions

View file

@ -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.
/// </summary>
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
/// <summary>
/// Opens search as a tab in the default browser chosen in Windows settings.
/// </summary>
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
{

View file

@ -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;

View file

@ -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;
}

View file

@ -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 =>

View file

@ -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;
}
}

View file

@ -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;
}
},

View file

@ -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;
}

View file

@ -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;
}