@@ -40,10 +40,10 @@ use tao::platform::windows::{WindowBuilderExtWindows, WindowExtWindows};
4040use webview2_com:: FocusChangedEventHandler ;
4141#[ cfg( windows) ]
4242use windows:: Win32 :: Foundation :: HWND ;
43- #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
44- use wry:: WebViewBuilderExtDarwin ;
4543#[ cfg( windows) ]
4644use wry:: WebViewBuilderExtWindows ;
45+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
46+ use wry:: { WebViewBuilderExtDarwin , WebViewExtDarwin } ;
4747
4848use tao:: {
4949 dpi:: {
@@ -1180,11 +1180,15 @@ unsafe impl Send for GtkBox {}
11801180pub struct SendRawWindowHandle ( pub raw_window_handle:: RawWindowHandle ) ;
11811181unsafe impl Send for SendRawWindowHandle { }
11821182
1183- #[ cfg( target_os = "macos" ) ]
1184- #[ derive( Debug , Clone ) ]
11851183pub enum ApplicationMessage {
1184+ #[ cfg( target_os = "macos" ) ]
11861185 Show ,
1186+ #[ cfg( target_os = "macos" ) ]
11871187 Hide ,
1188+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
1189+ FetchDataStoreIdentifiers ( Box < dyn FnOnce ( Vec < [ u8 ; 16 ] > ) + Send + ' static > ) ,
1190+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
1191+ RemoveDataStore ( [ u8 ; 16 ] , Box < dyn FnOnce ( Result < ( ) > ) + Send + ' static > ) ,
11881192}
11891193
11901194pub enum WindowMessage {
@@ -1347,7 +1351,6 @@ pub enum Message<T: 'static> {
13471351 #[ cfg( target_os = "macos" ) ]
13481352 SetActivationPolicy ( ActivationPolicy ) ,
13491353 RequestExit ( i32 ) ,
1350- #[ cfg( target_os = "macos" ) ]
13511354 Application ( ApplicationMessage ) ,
13521355 Window ( WindowId , WindowMessage ) ,
13531356 Webview ( WindowId , WebviewId , WebviewMessage ) ,
@@ -2507,6 +2510,29 @@ impl<T: UserEvent> RuntimeHandle<T> for WryHandle<T> {
25072510 {
25082511 dispatch ( f)
25092512 }
2513+
2514+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
2515+ fn fetch_data_store_identifiers < F : FnOnce ( Vec < [ u8 ; 16 ] > ) + Send + ' static > (
2516+ & self ,
2517+ cb : F ,
2518+ ) -> Result < ( ) > {
2519+ send_user_message (
2520+ & self . context ,
2521+ Message :: Application ( ApplicationMessage :: FetchDataStoreIdentifiers ( Box :: new ( cb) ) ) ,
2522+ )
2523+ }
2524+
2525+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
2526+ fn remove_data_store < F : FnOnce ( Result < ( ) > ) + Send + ' static > (
2527+ & self ,
2528+ uuid : [ u8 ; 16 ] ,
2529+ cb : F ,
2530+ ) -> Result < ( ) > {
2531+ send_user_message (
2532+ & self . context ,
2533+ Message :: Application ( ApplicationMessage :: RemoveDataStore ( uuid, Box :: new ( cb) ) ) ,
2534+ )
2535+ }
25102536}
25112537
25122538impl < T : UserEvent > Wry < T > {
@@ -2923,14 +2949,29 @@ fn handle_user_message<T: UserEvent>(
29232949 event_loop. set_activation_policy_at_runtime ( tao_activation_policy ( activation_policy) )
29242950 }
29252951 Message :: RequestExit ( _code) => panic ! ( "cannot handle RequestExit on the main thread" ) ,
2926- #[ cfg( target_os = "macos" ) ]
29272952 Message :: Application ( application_message) => match application_message {
2953+ #[ cfg( target_os = "macos" ) ]
29282954 ApplicationMessage :: Show => {
29292955 event_loop. show_application ( ) ;
29302956 }
2957+ #[ cfg( target_os = "macos" ) ]
29312958 ApplicationMessage :: Hide => {
29322959 event_loop. hide_application ( ) ;
29332960 }
2961+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
2962+ ApplicationMessage :: FetchDataStoreIdentifiers ( cb) => {
2963+ if let Err ( e) = WebView :: fetch_data_store_identifiers ( cb) {
2964+ // this shouldn't ever happen because we're running on the main thread
2965+ // but let's be safe and warn here
2966+ log:: error!( "failed to fetch data store identifiers: {e}" ) ;
2967+ }
2968+ }
2969+ #[ cfg( any( target_os = "macos" , target_os = "ios" ) ) ]
2970+ ApplicationMessage :: RemoveDataStore ( uuid, cb) => {
2971+ WebView :: remove_data_store ( & uuid, move |res| {
2972+ cb ( res. map_err ( |_| Error :: FailedToRemoveDataStore ) )
2973+ } )
2974+ }
29342975 } ,
29352976 Message :: Window ( id, window_message) => {
29362977 let w = windows. 0 . borrow ( ) . get ( & id) . map ( |w| {
0 commit comments