[Qt][WK2] Make UIProcess decide about encoding of input data for application URL...
authorzeno.albisser@nokia.com <zeno.albisser@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 13:47:59 +0000 (13:47 +0000)
committerzeno.albisser@nokia.com <zeno.albisser@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Jan 2012 13:47:59 +0000 (13:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77417

Make the UIProcess decide about the encoding and display
a warning in case no encoding was defined.
Make the QQuickNetworkReply store a QWeakPointer to the
QQuickWebViewExperimental to get rid of hackish chain of parental queries.

Reviewed by Simon Hausmann.

* UIProcess/API/qt/qquicknetworkreply.cpp:
(QQuickNetworkReply::send):
(QQuickNetworkReply::setWebViewExperimental):
* UIProcess/API/qt/qquicknetworkreply_p.h:
* UIProcess/API/qt/qquickwebview.cpp:
(QQuickWebViewExperimental::schemeDelegates_Append):
* WebProcess/qt/QtNetworkReply.cpp:
(WebKit::QtNetworkReply::QtNetworkReply):
(WebKit::QtNetworkReply::setReplyData):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106355 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/qquicknetworkreply.cpp
Source/WebKit2/UIProcess/API/qt/qquicknetworkreply_p.h
Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
Source/WebKit2/WebProcess/qt/QtNetworkReply.cpp

index 920167cdb5b949b4ffe5b6f533952424b0a51a4f..f303678acf9baec16f1194c2b8ccf38e4e7b839f 100644 (file)
@@ -1,3 +1,25 @@
+2012-01-31  Zeno Albisser  <zeno@webkit.org>
+
+        [Qt][WK2] Make UIProcess decide about encoding of input data for application URL schemes.
+        https://bugs.webkit.org/show_bug.cgi?id=77417
+
+        Make the UIProcess decide about the encoding and display
+        a warning in case no encoding was defined.
+        Make the QQuickNetworkReply store a QWeakPointer to the
+        QQuickWebViewExperimental to get rid of hackish chain of parental queries.
+
+        Reviewed by Simon Hausmann.
+
+        * UIProcess/API/qt/qquicknetworkreply.cpp:
+        (QQuickNetworkReply::send):
+        (QQuickNetworkReply::setWebViewExperimental):
+        * UIProcess/API/qt/qquicknetworkreply_p.h:
+        * UIProcess/API/qt/qquickwebview.cpp:
+        (QQuickWebViewExperimental::schemeDelegates_Append):
+        * WebProcess/qt/QtNetworkReply.cpp:
+        (WebKit::QtNetworkReply::QtNetworkReply):
+        (WebKit::QtNetworkReply::setReplyData):
+
 2012-01-30  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
 
         [Qt] Disconnect the LayerTreeHost from layers when they get removed from their parent.
index 4bea69c050e0655a8d8578dc1745984b2bb34f1d..38ac7b909dbb9ed6b39c83a17cff81355fec88d0 100644 (file)
@@ -68,6 +68,7 @@ void QQuickNetworkReply::send()
         stringData = m_data.toString();
         ptrData = reinterpret_cast<const void*>(stringData.constData());
         smLength = sizeof(QChar) * stringData.length();
+        setContentType(QLatin1String("text/html; charset=utf-16"));
     } else {
         if (!m_data.canConvert<QByteArray>())
             return;
@@ -76,6 +77,11 @@ void QQuickNetworkReply::send()
         smLength = byteArrayData.size();
     }
 
+    if (contentType().isEmpty()) {
+        qWarning("QQuickNetworkReply::send - Cannot send raw data without a content type being specified!");
+        return;
+    }
+
     WTF::RefPtr<WebKit::SharedMemory> sharedMemory = SharedMemory::create(smLength);
     if (!sharedMemory)
         return;
@@ -85,13 +91,8 @@ void QQuickNetworkReply::send()
 
     if (sharedMemory->createHandle(m_networkReplyData->data().m_dataHandle, SharedMemory::ReadOnly)) {
         m_networkReplyData->data().m_contentLength = smLength;
-
-        QObject* schemeParent = parent()->parent();
-        if (schemeParent) {
-            QQuickWebViewExperimental* webViewExperimental = qobject_cast<QQuickWebViewExperimental*>(schemeParent->parent());
-            if (webViewExperimental)
-                webViewExperimental->sendApplicationSchemeReply(this);
-        }
+        if (m_webViewExperimental)
+            m_webViewExperimental.data()->sendApplicationSchemeReply(this);
     }
 
     // After sending the reply data, we have to reinitialize the m_networkReplyData,
@@ -99,6 +100,11 @@ void QQuickNetworkReply::send()
     m_networkReplyData = adoptRef(new WebKit::QtRefCountedNetworkReplyData);
 }
 
+void QQuickNetworkReply::setWebViewExperimental(QQuickWebViewExperimental* webViewExperimental)
+{
+    m_webViewExperimental = webViewExperimental;
+}
+
 WebKit::QtRefCountedNetworkRequestData* QQuickNetworkReply::networkRequestData() const
 {
     return m_networkRequestData.get();
index 713f4e62b186d62a1a1dfacaec24110a6b51baaa..1007f3a78c761dff626f4d435e7d5b68d2bc57b2 100644 (file)
 
 #include "QtNetworkReplyData.h"
 #include "QtNetworkRequestData.h"
+#include "qquickwebview_p.h"
 #include "SharedMemory.h"
 #include "qwebkitglobal.h"
 #include <QNetworkAccessManager>
 #include <QObject>
+#include <QWeakPointer>
 #include <QtDeclarative/qdeclarativelist.h>
 #include <QtQuick/qquickitem.h>
 
@@ -44,6 +46,7 @@ public:
     QVariant data() const;
     void setData(const QVariant& data);
 
+    void setWebViewExperimental(QQuickWebViewExperimental*);
     WebKit::QtRefCountedNetworkRequestData* networkRequestData() const;
     void setNetworkRequestData(WTF::PassRefPtr<WebKit::QtRefCountedNetworkRequestData> data);
     WebKit::QtRefCountedNetworkReplyData* networkReplyData() const;
@@ -55,6 +58,7 @@ private:
     WTF::RefPtr<WebKit::QtRefCountedNetworkRequestData> m_networkRequestData;
     WTF::RefPtr<WebKit::QtRefCountedNetworkReplyData> m_networkReplyData;
     QVariant m_data;
+    QWeakPointer<QQuickWebViewExperimental> m_webViewExperimental;
 };
 
 QML_DECLARE_TYPE(QQuickNetworkReply)
index 935de9272866c96ad8f53ae9d6b4f9b1dd7de942..af818faf8c7b75c2b45d983755e49a8aab0dbfb0 100644 (file)
@@ -824,6 +824,7 @@ void QQuickWebViewExperimental::schemeDelegates_Append(QDeclarativeListProperty<
     QQuickWebViewExperimental* webViewExperimental = qobject_cast<QQuickWebViewExperimental*>(property->object->parent());
     if (!webViewExperimental)
         return;
+    scheme->reply()->setWebViewExperimental(webViewExperimental);
     QQuickWebViewPrivate* d = webViewExperimental->d_func();
     d->webPageProxy->registerApplicationScheme(scheme->scheme());
 }
index c71f13f1a734cdf0a03b4d4dd4acd896d62bfd16..e65022cdfac39063df60d51a75fe3871cfc4af34 100644 (file)
@@ -45,7 +45,6 @@ QtNetworkReply::QtNetworkReply(const QNetworkRequest& req, QtNetworkAccessManage
     setOperation(QNetworkAccessManager::GetOperation);
     setUrl(req.url());
     setOpenMode(QIODevice::ReadOnly);
-    setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QString::fromLocal8Bit("text/html; charset=UTF-16")));
 }
 
 void QtNetworkReply::setData(const SharedMemory::Handle& handle, qint64 dataSize)
@@ -62,7 +61,7 @@ void QtNetworkReply::setData(const SharedMemory::Handle& handle, qint64 dataSize
 
 void QtNetworkReply::setReplyData(const QtNetworkReplyData& replyData)
 {
-    if (!replyData.m_contentType.isNull())
+    if (!replyData.m_contentType.isEmpty())
         setHeader(QNetworkRequest::ContentTypeHeader, QString(replyData.m_contentType));
     setHeader(QNetworkRequest::ContentLengthHeader, QVariant::fromValue(replyData.m_contentLength));
     setData(replyData.m_dataHandle, replyData.m_contentLength);