fix: app.setLoginItemSettings error getting swallowed by gin conversion (#41647)

* fix: errors getting swallowed by gin conversion

* fix: Windows build

* test: re-enable disabled test
This commit is contained in:
Shelley Vohr 2024-03-22 14:00:21 +01:00 committed by GitHub
parent a32705fd30
commit 707b9a58cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 211 additions and 154 deletions

View file

@ -89,7 +89,6 @@
#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/mac/mac_util.h"
#include "shell/browser/ui/cocoa/electron_bundle_mover.h"
#endif
@ -324,80 +323,6 @@ struct Converter<JumpListResult> {
};
#endif
#if BUILDFLAG(IS_WIN)
template <>
struct Converter<Browser::LaunchItem> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
Browser::LaunchItem* out) {
gin_helper::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
dict.Get("name", &(out->name));
dict.Get("path", &(out->path));
dict.Get("args", &(out->args));
dict.Get("scope", &(out->scope));
dict.Get("enabled", &(out->enabled));
return true;
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
Browser::LaunchItem val) {
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
dict.Set("name", val.name);
dict.Set("path", val.path);
dict.Set("args", val.args);
dict.Set("scope", val.scope);
dict.Set("enabled", val.enabled);
return dict.GetHandle();
}
};
#endif
template <>
struct Converter<Browser::LoginItemSettings> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
Browser::LoginItemSettings* out) {
gin_helper::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
dict.Get("openAtLogin", &(out->open_at_login));
dict.Get("openAsHidden", &(out->open_as_hidden));
dict.Get("path", &(out->path));
dict.Get("args", &(out->args));
#if BUILDFLAG(IS_WIN)
dict.Get("name", &(out->name));
dict.Get("enabled", &(out->enabled));
#elif BUILDFLAG(IS_MAC)
dict.Get("serviceName", &(out->service_name));
dict.Get("type", &(out->type));
#endif
return true;
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
Browser::LoginItemSettings val) {
auto dict = gin_helper::Dictionary::CreateEmpty(isolate);
#if BUILDFLAG(IS_WIN)
dict.Set("launchItems", val.launch_items);
dict.Set("executableWillLaunchAtLogin",
val.executable_will_launch_at_login);
#elif BUILDFLAG(IS_MAC)
if (base::mac::MacOSMajorVersion() >= 13)
dict.Set("status", val.status);
#endif
dict.Set("openAtLogin", val.open_at_login);
dict.Set("openAsHidden", val.open_as_hidden);
dict.Set("restoreState", val.restore_state);
dict.Set("wasOpenedAtLogin", val.opened_at_login);
dict.Set("wasOpenedAsHidden", val.opened_as_hidden);
return dict.GetHandle();
}
};
template <>
struct Converter<content::CertificateRequestResultType> {
static bool FromV8(v8::Isolate* isolate,
@ -1216,8 +1141,8 @@ void App::SetAccessibilitySupportEnabled(gin_helper::ErrorThrower thrower,
Browser::Get()->OnAccessibilitySupportChanged();
}
Browser::LoginItemSettings App::GetLoginItemSettings(gin::Arguments* args) {
Browser::LoginItemSettings options;
v8::Local<v8::Value> App::GetLoginItemSettings(gin::Arguments* args) {
LoginItemSettings options;
args->GetNext(&options);
return Browser::Get()->GetLoginItemSettings(options);
}