fix: restore wasOpenedAtLogin
functionality (#42411)
fix: restore opened at login functionality
This commit is contained in:
parent
c3b4cd987c
commit
91205540c4
4 changed files with 16 additions and 1 deletions
|
@ -1265,7 +1265,7 @@ Returns `Object`:
|
||||||
|
|
||||||
* `openAtLogin` boolean - `true` if the app is set to open at login.
|
* `openAtLogin` boolean - `true` if the app is set to open at login.
|
||||||
* `openAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app is set to open as hidden at login. This does not work on macOS 13 and up.
|
* `openAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app is set to open as hidden at login. This does not work on macOS 13 and up.
|
||||||
* `wasOpenedAtLogin` boolean _macOS_ _Deprecated_ - `true` if the app was opened at login automatically. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up.
|
* `wasOpenedAtLogin` boolean _macOS_ - `true` if the app was opened at login automatically.
|
||||||
* `wasOpenedAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a hidden login item. This indicates that the app should not open any windows at startup. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up.
|
* `wasOpenedAsHidden` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a hidden login item. This indicates that the app should not open any windows at startup. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up.
|
||||||
* `restoreState` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a login item that should restore the state from the previous session. This indicates that the app should restore the windows that were open the last time the app was closed. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up.
|
* `restoreState` boolean _macOS_ _Deprecated_ - `true` if the app was opened as a login item that should restore the state from the previous session. This indicates that the app should restore the windows that were open the last time the app was closed. This setting is not available on [MAS builds][mas-builds] or on macOS 13 and up.
|
||||||
* `status` string _macOS_ - can be one of `not-registered`, `enabled`, `requires-approval`, or `not-found`.
|
* `status` string _macOS_ - can be one of `not-registered`, `enabled`, `requires-approval`, or `not-found`.
|
||||||
|
|
|
@ -236,6 +236,10 @@ class Browser : private WindowListObserver {
|
||||||
// Set docks' icon.
|
// Set docks' icon.
|
||||||
void DockSetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon);
|
void DockSetIcon(v8::Isolate* isolate, v8::Local<v8::Value> icon);
|
||||||
|
|
||||||
|
void SetLaunchedAtLogin(bool launched_at_login) {
|
||||||
|
was_launched_at_login_ = launched_at_login;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BUILDFLAG(IS_MAC)
|
#endif // BUILDFLAG(IS_MAC)
|
||||||
|
|
||||||
void ShowAboutPanel();
|
void ShowAboutPanel();
|
||||||
|
@ -370,6 +374,7 @@ class Browser : private WindowListObserver {
|
||||||
#if BUILDFLAG(IS_MAC)
|
#if BUILDFLAG(IS_MAC)
|
||||||
std::unique_ptr<ui::ScopedPasswordInputEnabler> password_input_enabler_;
|
std::unique_ptr<ui::ScopedPasswordInputEnabler> password_input_enabler_;
|
||||||
base::Time last_dock_show_;
|
base::Time last_dock_show_;
|
||||||
|
bool was_launched_at_login_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
base::Value::Dict about_panel_options_;
|
base::Value::Dict about_panel_options_;
|
||||||
|
|
|
@ -392,6 +392,7 @@ v8::Local<v8::Value> Browser::GetLoginItemSettings(
|
||||||
platform_util::GetLoginItemEnabled(options.type, options.service_name);
|
platform_util::GetLoginItemEnabled(options.type, options.service_name);
|
||||||
settings.open_at_login =
|
settings.open_at_login =
|
||||||
status == "enabled" || status == "enabled-deprecated";
|
status == "enabled" || status == "enabled-deprecated";
|
||||||
|
settings.opened_at_login = was_launched_at_login_;
|
||||||
if (@available(macOS 13, *))
|
if (@available(macOS 13, *))
|
||||||
settings.status = status;
|
settings.status = status;
|
||||||
#else
|
#else
|
||||||
|
@ -405,6 +406,7 @@ v8::Local<v8::Value> Browser::GetLoginItemSettings(
|
||||||
settings = settings_deprecated;
|
settings = settings_deprecated;
|
||||||
} else {
|
} else {
|
||||||
settings.open_at_login = status == "enabled";
|
settings.open_at_login = status == "enabled";
|
||||||
|
settings.opened_at_login = was_launched_at_login_;
|
||||||
settings.status = status;
|
settings.status = status;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -84,6 +84,14 @@ static NSDictionary* UNNotificationResponseToNSDictionary(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSAppleEventDescriptor* event =
|
||||||
|
NSAppleEventManager.sharedAppleEventManager.currentAppleEvent;
|
||||||
|
BOOL launched_as_login_item =
|
||||||
|
(event.eventID == kAEOpenApplication &&
|
||||||
|
[event paramDescriptorForKeyword:keyAEPropData].enumCodeValue ==
|
||||||
|
keyAELaunchedAsLogInItem);
|
||||||
|
electron::Browser::Get()->SetLaunchedAtLogin(launched_as_login_item);
|
||||||
|
|
||||||
electron::Browser::Get()->DidFinishLaunching(
|
electron::Browser::Get()->DidFinishLaunching(
|
||||||
electron::NSDictionaryToValue(notification_info));
|
electron::NSDictionaryToValue(notification_info));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue