feat: add workingDirectory option to shell.openExternal() (#15065)

Allows passing `workingDirectory` to the underlying `ShellExecuteW` API on Windows.

the motivation is that by default `ShellExecute` would use the current working directory, which would get locked on Windows and can prevent autoUpdater from working correctly. We need to be able specify a different `workingDirectory` to prevent this situation.
This commit is contained in:
Milan Burda 2018-10-10 22:46:54 +02:00 committed by Alexey Kuzmin
parent 2d186cb31a
commit a9475f3590
7 changed files with 42 additions and 35 deletions

View file

@ -8,6 +8,7 @@
#include <string>
#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "build/build_config.h"
#if defined(OS_WIN)
@ -16,10 +17,6 @@
class GURL;
namespace base {
class FilePath;
}
namespace platform_util {
typedef base::Callback<void(const std::string&)> OpenExternalCallback;
@ -32,6 +29,11 @@ bool ShowItemInFolder(const base::FilePath& full_path);
// Must be called from the UI thread.
bool OpenItem(const base::FilePath& full_path);
struct OpenExternalOptions {
bool activate = true;
base::FilePath working_dir;
};
// Open the given external protocol URL in the desktop's default manner.
// (For example, mailto: URLs in the default mail user agent.)
bool OpenExternal(
@ -40,7 +42,7 @@ bool OpenExternal(
#else
const GURL& url,
#endif
bool activate);
const OpenExternalOptions& options);
// The asynchronous version of OpenExternal.
void OpenExternal(
@ -49,7 +51,7 @@ void OpenExternal(
#else
const GURL& url,
#endif
bool activate,
const OpenExternalOptions& options,
const OpenExternalCallback& callback);
// Move a file to trash.