@@ -163,6 +163,39 @@ - (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigati
163
163
}
164
164
}
165
165
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
+
166
199
- (void )webView : (WKWebView *)webView didStartProvisionalNavigation : (WKNavigation *)navigation {
167
200
if (webView != _webView) { return ; }
168
201
@@ -172,6 +205,14 @@ - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation
172
205
}
173
206
}
174
207
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
+ }
175
216
176
217
- (void )webView : (WKWebView *)webView didFailNavigation : (WKNavigation *)navigation withError : (NSError *)error {
177
218
if (webView != _webView) { return ; }
@@ -191,6 +232,24 @@ - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation
191
232
}
192
233
}
193
234
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
+
194
253
- (NSString *) _evaluateJavascript : (NSString *)javascriptCommand {
195
254
[_webView evaluateJavaScript: javascriptCommand completionHandler: nil ];
196
255
return NULL ;
0 commit comments