You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2014/08/26 22:46:35 UTC

[02/15] git commit: CordovaViewInternal: add overrideScheme

CordovaViewInternal: add overrideScheme


Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/1120af7a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/1120af7a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/1120af7a

Branch: refs/heads/master
Commit: 1120af7a028dbac7006aef4b6a7f2c4b7f9078aa
Parents: 60a10cd
Author: Maxim Ermilov <ma...@canonical.com>
Authored: Sat May 17 00:59:09 2014 +0400
Committer: Maxim Ermilov <ma...@canonical.com>
Committed: Tue Aug 19 14:18:53 2014 +0400

----------------------------------------------------------------------
 Cordovaqt/CordovaViewInternal.qml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/1120af7a/Cordovaqt/CordovaViewInternal.qml
----------------------------------------------------------------------
diff --git a/Cordovaqt/CordovaViewInternal.qml b/Cordovaqt/CordovaViewInternal.qml
index a6d798a..bdfbbc9 100644
--- a/Cordovaqt/CordovaViewInternal.qml
+++ b/Cordovaqt/CordovaViewInternal.qml
@@ -42,6 +42,20 @@ Item {
         return CordovaWrapper.pluginObjects[plugin];
     }
 
+    function overrideScheme(schemeName, pluginName) {
+        var handler = Qt.createQmlObject("import QtWebKit.experimental 1.0;"
+            + "UrlSchemeDelegate { scheme: '" + schemeName + "';"
+            + "onReceivedRequest: { var data = plugin('" + pluginName + "').handleUri(request.url); reply.data = data; reply.contentType = 'application/octet-stream'; reply.send(); } } ", webView);
+
+        var handlers = [];
+        // QQmlListProperty (qt 5.2) does not support appending items from qml
+        for (var i in webView.experimental.urlSchemeDelegates)
+            handlers.push(webView.experimental.urlSchemeDelegates[i])
+
+        handlers.push(handler);
+        webView.experimental.urlSchemeDelegates = handlers;
+    }
+
     Rectangle {
         id: webViewContainer
         anchors.fill: parent