@@ -163,6 +163,39 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
163163 }
164164}
165165
166+ - (void )webView : (WKWebView *)webView decidePolicyForNavigationAction : (WKNavigationAction *)navigationAction preferences : (WKWebpagePreferences *)preferences decisionHandler : (void (^)(WKNavigationActionPolicy , WKWebpagePreferences * _Nonnull))decisionHandler API_AVAILABLE(ios(13.0 )){
167+ if (webView != _webView) { return ; }
168+ NSURL *url = navigationAction.request .URL ;
169+ __strong typeof (_webViewDelegate) strongDelegate = _webViewDelegate;
170+
171+ if ([_base isWebViewJavascriptBridgeURL: url]) {
172+ if ([_base isBridgeLoadedURL: url]) {
173+ [_base injectJavascriptFile ];
174+ } else if ([_base isQueueMessageURL: url]) {
175+ [self WKFlushMessageQueue ];
176+ } else {
177+ [_base logUnkownMessage: url];
178+ }
179+ decisionHandler (WKNavigationActionPolicyCancel , preferences);
180+ return ;
181+ }
182+
183+ if (strongDelegate && [strongDelegate respondsToSelector: @selector (webView:decidePolicyForNavigationAction:preferences:decisionHandler: )]) {
184+ [_webViewDelegate webView: webView decidePolicyForNavigationAction: navigationAction preferences: preferences decisionHandler: decisionHandler];
185+ } else {
186+ decisionHandler (WKNavigationActionPolicyAllow , preferences);
187+ }
188+ }
189+
190+ - (void )webView : (WKWebView *)webView navigationAction : (WKNavigationAction *)navigationAction didBecomeDownload : (WKDownload *)download API_AVAILABLE(ios(14.5 )){
191+ if (webView != _webView) { return ; }
192+
193+ __strong typeof (_webViewDelegate) strongDelegate = _webViewDelegate;
194+ if (strongDelegate && [strongDelegate respondsToSelector: @selector (webView:navigationAction:didBecomeDownload: )]) {
195+ [strongDelegate webView: webView navigationAction: navigationAction didBecomeDownload: download];
196+ }
197+ }
198+
166199- (void )webView : (WKWebView *)webView didStartProvisionalNavigation : (WKNavigation *)navigation {
167200 if (webView != _webView) { return ; }
168201
@@ -172,6 +205,14 @@ - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation
172205 }
173206}
174207
208+ - (void )webView : (WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation : (WKNavigation *)navigation {
209+ if (webView != _webView) { return ; }
210+
211+ __strong typeof (_webViewDelegate) strongDelegate = _webViewDelegate;
212+ if (strongDelegate && [strongDelegate respondsToSelector: @selector (webView:didReceiveServerRedirectForProvisionalNavigation: )]) {
213+ [strongDelegate webView: webView didReceiveServerRedirectForProvisionalNavigation: navigation];
214+ }
215+ }
175216
176217- (void )webView : (WKWebView *)webView didFailNavigation : (WKNavigation *)navigation withError : (NSError *)error {
177218 if (webView != _webView) { return ; }
@@ -191,6 +232,24 @@ - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation
191232 }
192233}
193234
235+ - (void )webViewWebContentProcessDidTerminate : (WKWebView *)webView {
236+ if (webView != _webView) { return ; }
237+
238+ __strong typeof (_webViewDelegate) strongDelegate = _webViewDelegate;
239+ if (strongDelegate && [strongDelegate respondsToSelector: @selector (webViewWebContentProcessDidTerminate: )]) {
240+ [strongDelegate webViewWebContentProcessDidTerminate: webView];
241+ }
242+ }
243+
244+ - (void )webView : (WKWebView *)webView navigationResponse : (WKNavigationResponse *)navigationResponse didBecomeDownload : (WKDownload *)download API_AVAILABLE(ios(14.5 )){
245+ if (webView != _webView) { return ; }
246+
247+ __strong typeof (_webViewDelegate) strongDelegate = _webViewDelegate;
248+ if (strongDelegate && [strongDelegate respondsToSelector: @selector (webView:navigationResponse:didBecomeDownload: )]) {
249+ [strongDelegate webView: webView navigationResponse: navigationResponse didBecomeDownload: download];
250+ }
251+ }
252+
194253- (NSString *) _evaluateJavascript : (NSString *)javascriptCommand {
195254 [_webView evaluateJavaScript: javascriptCommand completionHandler: nil ];
196255 return NULL ;
0 commit comments