fix: crash in utilityProcess when generating code from strings (#38014)
This commit is contained in:
parent
f12e12b341
commit
0240f6664e
14 changed files with 72 additions and 48 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue