Skip to content

Commit a11d4eb

Browse files
fix: avoid deprecated login item methods (#48096)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <[email protected]>
1 parent edbe9cb commit a11d4eb

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

shell/browser/browser_mac.mm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,18 @@ LoginItemSettings GetLoginItemSettingsDeprecated() {
411411
#else
412412
// If the app was previously set as a LoginItem with the deprecated API,
413413
// we should report its LoginItemSettings via the old API.
414-
LoginItemSettings settings_deprecated = GetLoginItemSettingsDeprecated();
415414
if (@available(macOS 13, *)) {
416415
const std::string status =
417416
platform_util::GetLoginItemEnabled(options.type, options.service_name);
418417
if (status == "enabled-deprecated") {
419-
settings = settings_deprecated;
418+
settings = GetLoginItemSettingsDeprecated();
420419
} else {
421420
settings.open_at_login = status == "enabled";
422421
settings.opened_at_login = was_launched_at_login_;
423422
settings.status = status;
424423
}
425424
} else {
426-
settings = settings_deprecated;
425+
settings = GetLoginItemSettingsDeprecated();
427426
}
428427
#endif
429428
return gin::ConvertToV8(isolate, settings);

shell/common/platform_util_mac.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ void Beep() {
220220

221221
std::string GetLoginItemEnabled(const std::string& type,
222222
const std::string& service_name) {
223-
bool enabled = GetLoginItemEnabledDeprecated();
224223
if (@available(macOS 13, *)) {
225224
SMAppService* service = GetServiceForType(type, service_name);
226225
SMAppServiceStatus status = [service status];
@@ -232,10 +231,11 @@ void Beep() {
232231
return "requires-approval";
233232
else if (status == SMAppServiceStatusNotFound) {
234233
// If the login item was enabled with the old API, return that.
235-
return enabled ? "enabled-deprecated" : "not-found";
234+
return GetLoginItemEnabledDeprecated() ? "enabled-deprecated"
235+
: "not-found";
236236
}
237237
}
238-
return enabled ? "enabled" : "not-registered";
238+
return GetLoginItemEnabledDeprecated() ? "enabled" : "not-registered";
239239
}
240240

241241
bool SetLoginItemEnabled(const std::string& type,

0 commit comments

Comments
 (0)