Skip to content

Commit

Permalink
Bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0c committed Mar 30, 2017
1 parent aff2f3b commit 60a68e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Pod/Classes/M2DWebViewController/M2DWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,29 @@ - (void)webView:(WKWebView * _Nonnull)webView runJavaScriptAlertPanelWithMessage
if ([self.delegate respondsToSelector:@selector(m2d_webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)]) {
[self.delegate m2d_webView:webView runJavaScriptAlertPanelWithMessage:message initiatedByFrame:frame completionHandler:completionHandler];
}
else {
completionHandler();
}
}

- (void)webView:(WKWebView * _Nonnull)webView runJavaScriptConfirmPanelWithMessage:(NSString * _Nonnull)message initiatedByFrame:(WKFrameInfo * _Nonnull)frame completionHandler:(void (^ _Nonnull)(BOOL result))completionHandler
{
if ([self.delegate respondsToSelector:@selector(m2d_webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)]) {
[self.delegate m2d_webView:webView runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:frame completionHandler:completionHandler];
}
else {
completionHandler(YES);
}
}

- (void)webView:(WKWebView * _Nonnull)webView runJavaScriptTextInputPanelWithPrompt:(NSString * _Nonnull)prompt defaultText:(NSString * _Nullable)defaultText initiatedByFrame:(WKFrameInfo * _Nonnull)frame completionHandler:(void (^ _Nonnull)(NSString * _Nullable result))completionHandler
{
if ([self.delegate respondsToSelector:@selector(m2d_webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)]) {
[self.delegate m2d_webView:webView runJavaScriptTextInputPanelWithPrompt:prompt defaultText:defaultText initiatedByFrame:frame completionHandler:completionHandler];
}
else {
completionHandler(nil);
}
}

- (BOOL)webView:(WKWebView * _Nonnull)webView shouldPreviewElement:(WKPreviewElementInfo * _Nonnull)elementInfo
Expand Down Expand Up @@ -239,13 +248,19 @@ - (void)webView:(WKWebView * _Nonnull )webView decidePolicyForNavigationAction:(
if ([self.delegate respondsToSelector:@selector(m2d_webView:decidePolicyForNavigationAction:decisionHandler:)]) {
[self.delegate m2d_webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler];
}
else {
decisionHandler(WKNavigationActionPolicyAllow);
}
}

- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
if ([self.delegate respondsToSelector:@selector(m2d_webView:decidePolicyForNavigationResponse:decisionHandler:)]) {
[self.delegate m2d_webView:webView decidePolicyForNavigationResponse:navigationResponse decisionHandler:decisionHandler];
}
else {
decisionHandler(WKNavigationResponsePolicyAllow);
}
}

- (void)webView:(WKWebView * _Nonnull )webView didStartProvisionalNavigation:(WKNavigation * _Null_unspecified)navigation
Expand Down Expand Up @@ -308,6 +323,9 @@ - (void)webView:(WKWebView * _Nonnull )webView didReceiveAuthenticationChallenge
if ([self.delegate respondsToSelector:@selector(m2d_webView:didReceiveAuthenticationChallenge:completionHandler:)]) {
[self.delegate m2d_webView:webView didReceiveAuthenticationChallenge:challenge completionHandler:completionHandler];
}
else {
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
}
}

- (void)webViewWebContentProcessDidTerminate:(WKWebView * _Nonnull )webView
Expand Down

0 comments on commit 60a68e3

Please sign in to comment.