fix: avoid deprecated login item methods (#48096)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <sattard@anthropic.com>
This commit is contained in:
trop[bot] 2025-08-18 12:00:14 +02:00 committed by GitHub
commit a11d4eb03c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View file

@ -411,19 +411,18 @@ v8::Local<v8::Value> Browser::GetLoginItemSettings(
#else
// If the app was previously set as a LoginItem with the deprecated API,
// we should report its LoginItemSettings via the old API.
LoginItemSettings settings_deprecated = GetLoginItemSettingsDeprecated();
if (@available(macOS 13, *)) {
const std::string status =
platform_util::GetLoginItemEnabled(options.type, options.service_name);
if (status == "enabled-deprecated") {
settings = settings_deprecated;
settings = GetLoginItemSettingsDeprecated();
} else {
settings.open_at_login = status == "enabled";
settings.opened_at_login = was_launched_at_login_;
settings.status = status;
}
} else {
settings = settings_deprecated;
settings = GetLoginItemSettingsDeprecated();
}
#endif
return gin::ConvertToV8(isolate, settings);

View file

@ -220,7 +220,6 @@ void Beep() {
std::string GetLoginItemEnabled(const std::string& type,
const std::string& service_name) {
bool enabled = GetLoginItemEnabledDeprecated();
if (@available(macOS 13, *)) {
SMAppService* service = GetServiceForType(type, service_name);
SMAppServiceStatus status = [service status];
@ -232,10 +231,11 @@ std::string GetLoginItemEnabled(const std::string& type,
return "requires-approval";
else if (status == SMAppServiceStatusNotFound) {
// If the login item was enabled with the old API, return that.
return enabled ? "enabled-deprecated" : "not-found";
return GetLoginItemEnabledDeprecated() ? "enabled-deprecated"
: "not-found";
}
}
return enabled ? "enabled" : "not-registered";
return GetLoginItemEnabledDeprecated() ? "enabled" : "not-registered";
}
bool SetLoginItemEnabled(const std::string& type,