fix(macos): Enable applicationSupportsSecureRestorableState = YES (#852)

This commit is contained in:
Harry Mallon
2023-11-28 12:13:32 +00:00
committed by GitHub
parent 499e492c21
commit 5eb2124e70
2 changed files with 17 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"tao": patch
---
Enable macOS secure state restoration on OS versions that support it. This avoids
'WARNING: Secure coding is not enabled for restorable state!' on macOS Sonoma.

View File

@@ -8,7 +8,7 @@ use cocoa::base::id;
use cocoa::foundation::NSString;
use objc::{
declare::ClassDecl,
runtime::{Class, Object, Sel},
runtime::{Class, Object, Sel, BOOL},
};
use std::{
cell::{RefCell, RefMut},
@@ -54,6 +54,10 @@ lazy_static! {
sel!(application:openURLs:),
application_open_urls as extern "C" fn(&Object, Sel, id, id),
);
decl.add_method(
sel!(applicationSupportsSecureRestorableState:),
application_supports_secure_restorable_state as extern "C" fn(&Object, Sel, id) -> BOOL,
);
decl.add_ivar::<*mut c_void>(AUX_DELEGATE_STATE_NAME);
AppDelegateClass(decl.register())
@@ -120,3 +124,9 @@ extern "C" fn application_open_urls(_: &Object, _: Sel, _: id, urls: id) -> () {
AppState::open_urls(urls);
trace!("Completed `application:openURLs:`");
}
extern "C" fn application_supports_secure_restorable_state(_: &Object, _: Sel, _: id) -> BOOL {
trace!("Triggered `applicationSupportsSecureRestorableState`");
trace!("Completed `applicationSupportsSecureRestorableState`");
objc::runtime::YES
}