Bug 1615370 - Add fallback to ShellExecuteExW in nsMIMEInfoWin. r=aklotz

If a system uses a custom shell instead of Windows Explorer,
`ShellExecuteByExplorer` always fails because it relies on explorer.exe,
but `ShellExecute` stil works because it's in-proc implementation.

We added a fallback for a local file to address Bug 1602726.  This patch adds
a fallback for a uri.

Differential Revision: https://phabricator.services.mozilla.com/D63095

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Toshihito Kikuchi 2020-03-07 21:43:49 +00:00
Родитель af5571ae8c
Коммит ff780f7c65
1 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -283,10 +283,19 @@ nsresult nsMIMEInfoWin::LoadUriInternal(nsIURI* aURL) {
// Ask Explorer to ShellExecute on our behalf, as some URL handlers do not
// start correctly when inheriting our process's process migitations.
mozilla::LauncherVoidResult shellExecuteOk =
mozilla::ShellExecuteByExplorer(validatedUri.unwrap(), args, verb,
mozilla::ShellExecuteByExplorer(validatedUri.inspect(), args, verb,
workingDir, showCmd);
if (shellExecuteOk.isErr()) {
return NS_ERROR_FAILURE;
SHELLEXECUTEINFOW sinfo = {sizeof(sinfo)};
sinfo.fMask = SEE_MASK_NOASYNC;
sinfo.lpVerb = V_BSTR(&verb);
sinfo.nShow = showCmd;
sinfo.lpFile = validatedUri.inspect();
BOOL result = ShellExecuteExW(&sinfo);
if (!result || reinterpret_cast<LONG_PTR>(sinfo.hInstApp) < 32) {
rv = NS_ERROR_FAILURE;
}
}
}