summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qiosservices.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-11-28 15:33:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-29 09:55:05 +0100
commitc5b19f252188a01dd7b12090f4776420e3714000 (patch)
tree69ed682eb67690fb98f2a6f451cad67714a9c449 /src/plugins/platforms/ios/qiosservices.mm
parentbedc5a3ae268594100b5e0eb8f35c0ce2b95ee96 (diff)
iOS: Forward [UIApplicationDelegate handleOpenURL:] to QDesktopServices
The user may use QDesktopServices::setUrlHandler() in combination with the appropriate Info.plist keys (CFBundleURLTypes, CFBundleURLSchemes) to react to URL requests from other applications. This is among other things useful for handling OAuth authentication from applications such as Dropbox. See: https://www.dropbox.com/developers/core/start/ios We protect against recursive URL opening, but an application may still redirect a request to open a URL by opening another URL, eg a website. Task-number: QTBUG-35201 Change-Id: I9f1d246206c5594b1b65bb11fa98c6bcdefc443e Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src/plugins/platforms/ios/qiosservices.mm')
-rw-r--r--src/plugins/platforms/ios/qiosservices.mm19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiosservices.mm b/src/plugins/platforms/ios/qiosservices.mm
index 32203aeb71..0ac6c590ca 100644
--- a/src/plugins/platforms/ios/qiosservices.mm
+++ b/src/plugins/platforms/ios/qiosservices.mm
@@ -42,6 +42,7 @@
#include "qiosservices.h"
#include <QtCore/qurl.h>
+#include <QtGui/qdesktopservices.h>
#import <UIKit/UIApplication.h>
@@ -49,6 +50,9 @@ QT_BEGIN_NAMESPACE
bool QIOSServices::openUrl(const QUrl &url)
{
+ if (url == m_handlingUrl)
+ return false;
+
if (url.scheme().isEmpty())
return openDocument(url);
@@ -66,4 +70,19 @@ bool QIOSServices::openDocument(const QUrl &url)
return QPlatformServices::openDocument(url);
}
+/* Callback from iOS that the application should handle a URL */
+bool QIOSServices::handleUrl(const QUrl &url)
+{
+ QUrl previouslyHandling = m_handlingUrl;
+ m_handlingUrl = url;
+
+ // FIXME: Add platform services callback from QDesktopServices::setUrlHandler
+ // so that we can warn the user if calling setUrlHandler without also setting
+ // up the matching keys in the Info.plist file (CFBundleURLTypes and friends).
+ bool couldHandle = QDesktopServices::openUrl(url);
+
+ m_handlingUrl = previouslyHandling;
+ return couldHandle;
+}
+
QT_END_NAMESPACE