Merge remote-tracking branch 'origin/master' into roller/chromium/master

This commit is contained in:
Jeremy Rose 2021-03-23 11:14:58 -07:00
commit 39e3576c48
68 changed files with 578 additions and 182 deletions

View file

@ -363,21 +363,22 @@ void NodeBindings::Initialize() {
// Parse and set Node.js cli flags.
SetNodeCliFlags();
// pass non-null program name to argv so it doesn't crash
// trying to index into a nullptr
int argc = 1;
int exec_argc = 0;
const char* prog_name = "electron";
const char** argv = &prog_name;
const char** exec_argv = nullptr;
std::unique_ptr<base::Environment> env(base::Environment::Create());
SetNodeOptions(env.get());
// TODO(codebytere): this is going to be deprecated in the near future
// in favor of Init(std::vector<std::string>* argv,
// std::vector<std::string>* exec_argv)
node::Init(&argc, argv, &exec_argc, &exec_argv);
std::vector<std::string> argv = {"electron"};
std::vector<std::string> exec_argv;
std::vector<std::string> errors;
int exit_code = node::InitializeNodeWithArgs(&argv, &exec_argv, &errors);
for (const std::string& error : errors) {
fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str());
}
if (exit_code != 0) {
exit(exit_code);
}
#if defined(OS_WIN)
// uv_init overrides error mode to suppress the default crash dialog, bring
@ -533,15 +534,13 @@ void NodeBindings::LoadEnvironment(node::Environment* env) {
void NodeBindings::PrepareMessageLoop() {
#if !defined(OS_WIN)
int handle = uv_backend_fd(uv_loop_);
#else
HANDLE handle = uv_loop_->iocp;
#endif
// If the backend fd hasn't changed, don't proceed.
if (handle == handle_)
return;
handle_ = handle;
#endif
// Add dummy handle for libuv, otherwise libuv would quit when there is
// nothing to do.

View file

@ -159,9 +159,7 @@ class NodeBindings {
// Isolate data used in creating the environment
node::IsolateData* isolate_data_ = nullptr;
#if defined(OS_WIN)
HANDLE handle_;
#else
#if !defined(OS_WIN)
int handle_ = -1;
#endif

View file

@ -32,6 +32,7 @@
#include "base/win/windows_version.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "shell/common/electron_paths.h"
#include "ui/base/win/shell.h"
#include "url/gurl.h"
@ -241,7 +242,8 @@ std::string OpenExternalOnWorkerThread(
// Quote the input scheme to be sure that the command does not have
// parameters unexpected by the external program. This url should already
// have been escaped.
std::wstring escaped_url = L"\"" + base::UTF8ToWide(url.spec()) + L"\"";
std::wstring escaped_url =
L"\"" + base::UTF8ToWide(net::EscapeExternalHandlerValue(url.spec())) +
std::wstring working_dir = options.working_dir.value();
if (reinterpret_cast<ULONG_PTR>(