From bb7b87f584128bfa5325921a60e80e3d03f9e194 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 2 Jan 2019 08:51:48 +0100 Subject: iOS: Check if the external browser can open the url first If the external browser cannot open the url (as can be the case with file schemes) then it should fall back to using the same webview instead so that the link is not ignored. [ChangeLog][Platform Specific Changes][iOS] Now opens links with _blank target in the current WebView if the external browser cannot open them. Fixes: QTBUG-63963 Change-Id: Ibd77c82a084d130e034c4d98ba9b08bb5cdf5743 Reviewed-by: Christian Stromme --- src/plugins/darwin/qdarwinwebview.mm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/darwin/qdarwinwebview.mm b/src/plugins/darwin/qdarwinwebview.mm index e82771f..ba99ac6 100644 --- a/src/plugins/darwin/qdarwinwebview.mm +++ b/src/plugins/darwin/qdarwinwebview.mm @@ -244,7 +244,13 @@ decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction #ifdef Q_OS_MACOS [[NSWorkspace sharedWorkspace] openURL:url]; #elif defined(Q_OS_IOS) - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + // Check if it can be opened first, if it is a file scheme then it can't + // be opened, therefore if it is a _blank target in that case we need to open + // inside the current webview + if ([[UIApplication sharedApplication] canOpenURL:url]) + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + else if (!navigationAction.targetFrame) + [webView loadRequest:navigationAction.request]; #endif } decisionHandler(handled ? WKNavigationActionPolicyAllow : WKNavigationActionPolicyCancel); -- cgit v1.2.3