summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-01-02 08:51:48 +0100
committerAndy Shaw <andy.shaw@qt.io>2019-01-08 13:35:50 +0000
commitbb7b87f584128bfa5325921a60e80e3d03f9e194 (patch)
tree23a6c2805ca9e61a588cfc499b02159a7582be95
parent0a68deca4de8eca51024cd7ca4235d274cf984fd (diff)
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 <christian.stromme@qt.io>
-rw-r--r--src/plugins/darwin/qdarwinwebview.mm8
1 files changed, 7 insertions, 1 deletions
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);