@@ -22,6 +22,7 @@ use crate::{
2222 download:: { navigation_download_action, navigation_download_response} ,
2323 navigation:: {
2424 did_commit_navigation, did_finish_navigation, navigation_policy, navigation_policy_response,
25+ web_content_process_did_terminate,
2526 } ,
2627 } ,
2728 PageLoadEvent , WryWebView ,
@@ -35,6 +36,7 @@ pub struct WryNavigationDelegateIvars {
3536 pub navigation_policy_function : Box < dyn Fn ( String ) -> bool > ,
3637 pub download_delegate : Option < Retained < WryDownloadDelegate > > ,
3738 pub on_page_load_handler : Option < Box < dyn Fn ( PageLoadEvent ) > > ,
39+ pub on_web_content_process_terminate_handler : Option < Box < dyn Fn ( ) > > ,
3840}
3941
4042define_class ! (
@@ -96,6 +98,11 @@ define_class!(
9698 ) {
9799 navigation_download_response( self , webview, response, download) ;
98100 }
101+
102+ #[ unsafe ( method( webViewWebContentProcessDidTerminate: ) ) ]
103+ fn web_content_process_did_terminate( & self , webview: & WKWebView ) {
104+ web_content_process_did_terminate( self , webview) ;
105+ }
99106 }
100107) ;
101108
@@ -108,6 +115,7 @@ impl WryNavigationDelegate {
108115 navigation_handler : Option < Box < dyn Fn ( String ) -> bool > > ,
109116 download_delegate : Option < Retained < WryDownloadDelegate > > ,
110117 on_page_load_handler : Option < Box < dyn Fn ( PageLoadEvent , String ) > > ,
118+ on_web_content_process_terminate_handler : Option < Box < dyn Fn ( ) > > ,
111119 mtm : MainThreadMarker ,
112120 ) -> Retained < Self > {
113121 let navigation_policy_function = Box :: new ( move |url : String | -> bool {
@@ -125,6 +133,16 @@ impl WryNavigationDelegate {
125133 None
126134 } ;
127135
136+ let on_web_content_process_terminate_handler =
137+ if let Some ( handler) = on_web_content_process_terminate_handler {
138+ let custom_handler = Box :: new ( move || {
139+ handler ( ) ;
140+ } ) as Box < dyn Fn ( ) > ;
141+ Some ( custom_handler)
142+ } else {
143+ None
144+ } ;
145+
128146 let delegate = mtm
129147 . alloc :: < WryNavigationDelegate > ( )
130148 . set_ivars ( WryNavigationDelegateIvars {
@@ -133,6 +151,7 @@ impl WryNavigationDelegate {
133151 has_download_handler,
134152 download_delegate,
135153 on_page_load_handler,
154+ on_web_content_process_terminate_handler,
136155 } ) ;
137156
138157 unsafe { msg_send ! [ super ( delegate) , init] }
0 commit comments