[PT Run] Web search should use user's default browser (#17304)

* Web search does not use my default browser #16549
updated DefaultBrowserInfo logic to get program location from shell open command not icon location

* Refactored DefaultBrowserInfo to start default browser with arguments specified in shell/open/command value for the browser.
Added fallback to Microsoft Edge if no browser information available.
#16549 Web search does not use my default browser

* fixed comment
#16549 Web search does not use my default browser
This commit is contained in:
lncubus
2022-04-12 17:10:05 +02:00
committed by GitHub
parent f778d010e5
commit 86783e9815
3 changed files with 85 additions and 151 deletions

View File

@@ -63,7 +63,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
// empty non-global query:
if (!AreResultsGlobal() && query.ActionKeyword == query.RawQuery)
{
string arguments = "\"? \"";
string arguments = "? ";
results.Add(new Result
{
Title = Properties.Resources.plugin_description.Remove(Description.Length - 1, 1),
@@ -73,7 +73,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
ProgramArguments = arguments,
Action = action =>
{
if (!Helper.OpenInShell(BrowserInfo.Path ?? BrowserInfo.MSEdgePath, arguments))
if (!Helper.OpenCommandInShell(BrowserInfo.Path, BrowserInfo.ArgumentsPattern, arguments))
{
onPluginError();
return false;
@@ -105,37 +105,19 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
IcoPath = _iconPath,
};
if (BrowserInfo.SupportsWebSearchByCmdLineArgument)
string arguments = $"? {searchTerm}";
result.ProgramArguments = arguments;
result.Action = action =>
{
string arguments = $"\"? {searchTerm}\"";
result.ProgramArguments = arguments;
result.Action = action =>
if (!Helper.OpenCommandInShell(BrowserInfo.Path, BrowserInfo.ArgumentsPattern, arguments))
{
if (!Helper.OpenInShell(BrowserInfo.Path ?? BrowserInfo.MSEdgePath, arguments))
{
onPluginError();
return false;
}
onPluginError();
return false;
}
return true;
};
}
else
{
string url = string.Format(CultureInfo.InvariantCulture, BrowserInfo.SearchEngineUrl, searchTerm);
result.Action = action =>
{
if (!Helper.OpenInShell(url))
{
onPluginError();
return false;
}
return true;
};
}
return true;
};
results.Add(result);
}