fix: crash in utilityProcess when generating code from strings (#38014)

This commit is contained in:
Robo 2023-04-20 09:27:02 +09:00 committed by GitHub
parent f12e12b341
commit 0240f6664e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 72 additions and 48 deletions

View file

@ -4,6 +4,8 @@
#include "shell/common/process_util.h"
#include "base/command_line.h"
#include "content/public/common/content_switches.h"
#include "gin/dictionary.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/node_includes.h"
@ -24,4 +26,18 @@ void EmitWarning(node::Environment* env,
emit_warning.Run(warning_msg, warning_type, "");
}
bool IsBrowserProcess() {
auto* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
return process_type.empty();
}
bool IsRendererProcess() {
auto* command_line = base::CommandLine::ForCurrentProcess();
std::string process_type =
command_line->GetSwitchValueASCII(switches::kProcessType);
return process_type == switches::kRendererProcess;
}
} // namespace electron