Commit 445feb54 authored by Peter K. Lee's avatar Peter K. Lee Committed by Commit Bot

Calls decisionsHandler asynchronously

This change is a precursor to a more extensive change where
ExternalAppLauncher API is changed to be asynchronous.

This simpler change is to call the decision handler in the implemention
of WKNavigateDelegate method
webView:decidePolicyForNavigationResponse:decisionHandler:
asynchronously on iOS 11 and up.

iOS 10 (and possible below) has a bug where JavaScript on the page would
not execute if the decision handler is called asynchronously.

This change is to make sure that there are no other unforeseen
issues with calling decision handler asynchronously on iOS 11.

Bug: 774736
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I7a6dfe637cb6be4ce5c7efe5824728b8f06b902a
Reviewed-on: https://chromium-review.googlesource.com/773570
Commit-Queue: Peter Lee <pkl@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517129}
parent 5913da3a
......@@ -4271,8 +4271,19 @@ registerLoadRequestForURL:(const GURL&)requestURL
self.navigationManagerImpl->DiscardNonCommittedItems();
}
// Although the Apple documentation says that |handler| can be called
// immediately or saved and called asynchronously, there is a bug in
// iOS 10 (and possibly before) that JavaScript code is not executed
// when the |handler| is called asynchronously.
if (@available(iOS 11, *)) {
dispatch_async(dispatch_get_main_queue(), ^{
handler(allowNavigation ? WKNavigationResponsePolicyAllow
: WKNavigationResponsePolicyCancel);
});
} else {
handler(allowNavigation ? WKNavigationResponsePolicyAllow
: WKNavigationResponsePolicyCancel);
}
}
- (void)webView:(WKWebView*)webView
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment