feat: add app.runningUnderRosettaTranslation to detect running under rosetta (#26444)
* feat: add app.isRunningUnderRosettaTranslation to detect running under rosetta * chore: fixup * chore: make const * chore: add missing import
This commit is contained in:
parent
d6431a0ff2
commit
d6019634f9
4 changed files with 23 additions and 0 deletions
|
@ -1666,6 +1666,8 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) {
|
|||
#endif
|
||||
#if defined(OS_MAC)
|
||||
.SetProperty("dock", &App::GetDockAPI)
|
||||
.SetProperty("runningUnderRosettaTranslation",
|
||||
&App::IsRunningUnderRosettaTranslation)
|
||||
#endif
|
||||
.SetProperty("userAgentFallback", &App::GetUserAgentFallback,
|
||||
&App::SetUserAgentFallback)
|
||||
|
|
|
@ -221,6 +221,7 @@ class App : public ElectronBrowserClient::Delegate,
|
|||
bool MoveToApplicationsFolder(gin_helper::ErrorThrower, gin::Arguments* args);
|
||||
bool IsInApplicationsFolder();
|
||||
v8::Local<v8::Value> GetDockAPI(v8::Isolate* isolate);
|
||||
bool IsRunningUnderRosettaTranslation() const;
|
||||
v8::Global<v8::Value> dock_;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "shell/common/electron_paths.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <sys/sysctl.h>
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -58,6 +59,16 @@ void App::SetActivationPolicy(gin_helper::ErrorThrower thrower,
|
|||
[NSApp setActivationPolicy:activation_policy];
|
||||
}
|
||||
|
||||
bool App::IsRunningUnderRosettaTranslation() const {
|
||||
int proc_translated = 0;
|
||||
size_t size = sizeof(proc_translated);
|
||||
if (sysctlbyname("sysctl.proc_translated", &proc_translated, &size, NULL,
|
||||
0) == -1) {
|
||||
return false;
|
||||
}
|
||||
return proc_translated == 1;
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue