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:
parent
edbe9cbbda
commit
a11d4eb03c
2 changed files with 5 additions and 6 deletions
|
|
@ -411,19 +411,18 @@ v8::Local<v8::Value> Browser::GetLoginItemSettings(
|
||||||
#else
|
#else
|
||||||
// If the app was previously set as a LoginItem with the deprecated API,
|
// If the app was previously set as a LoginItem with the deprecated API,
|
||||||
// we should report its LoginItemSettings via the old API.
|
// we should report its LoginItemSettings via the old API.
|
||||||
LoginItemSettings settings_deprecated = GetLoginItemSettingsDeprecated();
|
|
||||||
if (@available(macOS 13, *)) {
|
if (@available(macOS 13, *)) {
|
||||||
const std::string status =
|
const std::string status =
|
||||||
platform_util::GetLoginItemEnabled(options.type, options.service_name);
|
platform_util::GetLoginItemEnabled(options.type, options.service_name);
|
||||||
if (status == "enabled-deprecated") {
|
if (status == "enabled-deprecated") {
|
||||||
settings = settings_deprecated;
|
settings = GetLoginItemSettingsDeprecated();
|
||||||
} else {
|
} else {
|
||||||
settings.open_at_login = status == "enabled";
|
settings.open_at_login = status == "enabled";
|
||||||
settings.opened_at_login = was_launched_at_login_;
|
settings.opened_at_login = was_launched_at_login_;
|
||||||
settings.status = status;
|
settings.status = status;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
settings = settings_deprecated;
|
settings = GetLoginItemSettingsDeprecated();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return gin::ConvertToV8(isolate, settings);
|
return gin::ConvertToV8(isolate, settings);
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,6 @@ void Beep() {
|
||||||
|
|
||||||
std::string GetLoginItemEnabled(const std::string& type,
|
std::string GetLoginItemEnabled(const std::string& type,
|
||||||
const std::string& service_name) {
|
const std::string& service_name) {
|
||||||
bool enabled = GetLoginItemEnabledDeprecated();
|
|
||||||
if (@available(macOS 13, *)) {
|
if (@available(macOS 13, *)) {
|
||||||
SMAppService* service = GetServiceForType(type, service_name);
|
SMAppService* service = GetServiceForType(type, service_name);
|
||||||
SMAppServiceStatus status = [service status];
|
SMAppServiceStatus status = [service status];
|
||||||
|
|
@ -232,10 +231,11 @@ std::string GetLoginItemEnabled(const std::string& type,
|
||||||
return "requires-approval";
|
return "requires-approval";
|
||||||
else if (status == SMAppServiceStatusNotFound) {
|
else if (status == SMAppServiceStatusNotFound) {
|
||||||
// If the login item was enabled with the old API, return that.
|
// 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,
|
bool SetLoginItemEnabled(const std::string& type,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue