summaryrefslogtreecommitdiffstats
path: root/WebKit/qt/WebCoreSupport
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/qt/WebCoreSupport')
-rw-r--r--WebKit/qt/WebCoreSupport/ChromeClientQt.cpp2
-rw-r--r--WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp2
-rw-r--r--WebKit/qt/WebCoreSupport/EditorClientQt.cpp4
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp15
-rw-r--r--WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h2
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.cpp43
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorClientQt.h8
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorServerQt.cpp386
-rw-r--r--WebKit/qt/WebCoreSupport/InspectorServerQt.h110
-rw-r--r--WebKit/qt/WebCoreSupport/PageClientQt.cpp13
-rw-r--r--WebKit/qt/WebCoreSupport/PageClientQt.h6
-rw-r--r--WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp12
-rw-r--r--WebKit/qt/WebCoreSupport/QtPlatformPlugin.h2
-rw-r--r--WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp68
-rw-r--r--WebKit/qt/WebCoreSupport/WebPlatformStrategies.h22
15 files changed, 639 insertions, 56 deletions
diff --git a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
index a5dfdc7..9fbc5e5 100644
--- a/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
@@ -644,8 +644,6 @@ QWebSelectMethod* ChromeClientQt::createSelectPopup() const
void ChromeClientQt::didReceiveViewportArguments(Frame* frame, const ViewportArguments& arguments) const
{
- m_webPage->mainFrame()->d->viewportArguments = arguments;
-
emit m_webPage->viewportChangeRequested();
}
diff --git a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
index ed7ac32..836df49 100644
--- a/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
+++ b/WebKit/qt/WebCoreSupport/DumpRenderTreeSupportQt.cpp
@@ -631,7 +631,7 @@ void DumpRenderTreeSupportQt::dumpNotification(bool b)
QString DumpRenderTreeSupportQt::viewportAsText(QWebPage* page, const QSize& availableSize)
{
- WebCore::ViewportArguments args = page->mainFrame()->d->viewportArguments;
+ WebCore::ViewportArguments args = page->mainFrame()->d->viewportArguments();
WebCore::ViewportConfiguration conf = WebCore::findConfigurationForViewportData(args,
/* desktop-width */ 980,
/* device-width */ 320,
diff --git a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
index 080c459..9db4333 100644
--- a/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
@@ -595,7 +595,6 @@ void EditorClientQt::setInputMethodState(bool active)
{
QWebPageClient* webPageClient = m_page->d->client;
if (webPageClient) {
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
Qt::InputMethodHints hints;
HTMLInputElement* inputElement = 0;
@@ -628,8 +627,7 @@ void EditorClientQt::setInputMethodState(bool active)
hints |= Qt::ImhNoAutoUppercase;
hints |= Qt::ImhNoPredictiveText;
#endif // Q_WS_MAEMO_5 || Q_WS_MAEMO_6 || Q_OS_SYMBIAN
- webPageClient->setInputMethodHints(hints);
-#endif // QT_VERSION check
+ webPageClient->setInputMethodHints(hints);
webPageClient->setInputMethodEnabled(active);
}
emit m_page->microFocusChanged();
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index 4aadeb0..41bcb3c 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -442,9 +442,6 @@ void FrameLoaderClientQt::dispatchDidCommitLoad()
if (m_frame->tree()->parent() || !m_webFrame)
return;
- // Clear the viewport arguments.
- m_webFrame->d->viewportArguments = WebCore::ViewportArguments();
-
emit m_webFrame->urlChanged(m_webFrame->url());
m_webFrame->page()->d->updateNavigationActions();
@@ -1248,7 +1245,7 @@ PassRefPtr<Frame> FrameLoaderClientQt::createFrame(const KURL& url, const String
return frameData.frame.release();
}
-void FrameLoaderClientQt::didTransferChildFrameToNewDocument()
+void FrameLoaderClientQt::didTransferChildFrameToNewDocument(Page*)
{
ASSERT(m_frame->ownerElement());
@@ -1370,7 +1367,6 @@ private:
}
};
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
class QtPluginGraphicsWidget: public Widget
{
public:
@@ -1415,7 +1411,6 @@ private:
QGraphicsWidget* graphicsWidget;
};
-#endif
PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize, HTMLPlugInElement* element, const KURL& url, const Vector<String>& paramNames,
const Vector<String>& paramValues, const String& mimeType, bool loadManually)
@@ -1456,7 +1451,7 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize,
for (unsigned i = 0; i < numqStyleSheetProperties; ++i) {
CSSPropertyID property = qstyleSheetProperties[i];
- styleSheet += QString::fromLatin1(::getPropertyName(property));
+ styleSheet += QString::fromLatin1(getPropertyName(property));
styleSheet += QLatin1Char(':');
styleSheet += computedStyle(element)->getPropertyValue(property);
styleSheet += QLatin1Char(';');
@@ -1488,7 +1483,7 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize,
w->setFrameRect(IntRect(0, 0, 0, 0));
return w;
}
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
+
QGraphicsWidget* graphicsWidget = qobject_cast<QGraphicsWidget*>(object);
if (graphicsWidget) {
QGraphicsObject* parentWidget = 0;
@@ -1502,7 +1497,7 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize,
w->setFrameRect(IntRect(0, 0, 0, 0));
return w;
}
-#endif
+
// FIXME: make things work for widgetless plugins as well
delete object;
}
@@ -1513,7 +1508,7 @@ PassRefPtr<Widget> FrameLoaderClientQt::createPlugin(const IntSize& pluginSize,
if (mimeType == "application/x-shockwave-flash") {
QWebPageClient* client = m_webFrame->page()->d->client;
const bool isQWebView = client && qobject_cast<QWidget*>(client->pluginParent());
-#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
+#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
size_t wmodeIndex = params.find("wmode");
if (wmodeIndex == -1) {
// Disable XEmbed mode and force it to opaque mode
diff --git a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
index fffda58..ec6a3b6 100644
--- a/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
+++ b/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
@@ -198,7 +198,7 @@ public:
virtual PassRefPtr<Frame> createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
- virtual void didTransferChildFrameToNewDocument();
+ virtual void didTransferChildFrameToNewDocument(WebCore::Page*);
virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool);
virtual void redirectDataToPlugin(Widget* pluginWidget);
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
index e6e6fde..b6673e6 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.cpp
@@ -32,7 +32,10 @@
#include "InspectorClientQt.h"
#include "Frame.h"
+#include "InspectorBackendDispatcher.h"
#include "InspectorController.h"
+#include "InspectorFrontend.h"
+#include "InspectorServerQt.h"
#include "NotImplemented.h"
#include "Page.h"
#include "PlatformString.h"
@@ -115,17 +118,26 @@ InspectorClientQt::InspectorClientQt(QWebPage* page)
: m_inspectedWebPage(page)
, m_frontendWebPage(0)
, m_frontendClient(0)
-{}
+{
+ InspectorServerQt* webInspectorServer = InspectorServerQt::server();
+ if (webInspectorServer)
+ webInspectorServer->registerClient(this);
+}
void InspectorClientQt::inspectorDestroyed()
{
if (m_frontendClient)
m_frontendClient->inspectorClientDestroyed();
+
+ InspectorServerQt* webInspectorServer = InspectorServerQt::server();
+ if (webInspectorServer)
+ webInspectorServer->unregisterClient(this);
+
delete this;
}
-void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*)
+void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController* inspectorController)
{
#if USE(V8)
ensureDebuggerScriptLoaded();
@@ -136,6 +148,10 @@ void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*)
inspectorView->setPage(inspectorPage);
QWebInspector* inspector = m_inspectedWebPage->d->getOrCreateInspector();
+ // Remote frontend was attached.
+ if (m_inspectedWebPage->d->inspector->d->remoteFrontend)
+ return;
+
// This is a known hook that allows changing the default URL for the
// Web inspector. This is used for SDK purposes. Please keep this hook
// around and don't remove it.
@@ -167,6 +183,23 @@ void InspectorClientQt::releaseFrontendPage()
m_frontendClient = 0;
}
+void InspectorClientQt::attachAndReplaceRemoteFrontend(RemoteFrontendChannel* channel)
+{
+#if ENABLE(INSPECTOR)
+ // Channel was allocated by InspectorServerQt. Here we transfer ownership to inspector.
+ m_inspectedWebPage->d->inspector->d->attachAndReplaceRemoteFrontend(channel);
+ m_inspectedWebPage->d->inspectorController()->connectFrontend();
+#endif
+}
+
+void InspectorClientQt::detachRemoteFrontend()
+{
+#if ENABLE(INSPECTOR)
+ m_inspectedWebPage->d->inspector->d->detachRemoteFrontend();
+ m_inspectedWebPage->d->inspectorController()->disconnectFrontend();
+#endif
+}
+
void InspectorClientQt::highlight(Node*)
{
notImplemented();
@@ -223,6 +256,12 @@ void InspectorClientQt::storeSetting(const String& key, const String& setting)
bool InspectorClientQt::sendMessageToFrontend(const String& message)
{
+ if (m_inspectedWebPage->d->inspector->d->remoteFrontend) {
+ RemoteFrontendChannel* session = qobject_cast<RemoteFrontendChannel*>(m_inspectedWebPage->d->inspector->d->remoteFrontend);
+ if (session)
+ session->sendMessageToFrontend(message);
+ return true;
+ }
if (!m_frontendWebPage)
return false;
diff --git a/WebKit/qt/WebCoreSupport/InspectorClientQt.h b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
index 0074159..64a2d0c 100644
--- a/WebKit/qt/WebCoreSupport/InspectorClientQt.h
+++ b/WebKit/qt/WebCoreSupport/InspectorClientQt.h
@@ -42,8 +42,10 @@ class QWebView;
namespace WebCore {
class InspectorFrontendClientQt;
+class InspectorServerRequestHandlerQt;
class Node;
class Page;
+class RemoteFrontendChannel;
class InspectorClientQt : public InspectorClient {
public:
@@ -63,10 +65,16 @@ public:
void releaseFrontendPage();
+ void attachAndReplaceRemoteFrontend(RemoteFrontendChannel *channel);
+ void detachRemoteFrontend();
+
private:
QWebPage* m_inspectedWebPage;
QWebPage* m_frontendWebPage;
InspectorFrontendClientQt* m_frontendClient;
+ bool m_remoteInspector;
+
+ friend class InspectorServerRequestHandlerQt;
};
class InspectorFrontendClientQt : public InspectorFrontendClientLocal {
diff --git a/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp b/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
new file mode 100644
index 0000000..fad7247
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/InspectorServerQt.cpp
@@ -0,0 +1,386 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "InspectorServerQt.h"
+
+#include "InspectorBackendDispatcher.h"
+#include "InspectorClientQt.h"
+#include "MD5.h"
+#include "Page.h"
+#include "qwebpage.h"
+#include "qwebpage_p.h"
+#include <QFile>
+#include <QHttpHeader>
+#include <QHttpRequestHeader>
+#include <QHttpResponseHeader>
+#include <QString>
+#include <QStringList>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QUrl>
+#include <QWidget>
+#include <qendian.h>
+
+namespace WebCore {
+
+/*!
+ Computes the WebSocket handshake response given the two challenge numbers and key3.
+ */
+static void generateWebSocketChallengeResponse(uint32_t number1, uint32_t number2, const unsigned char key3[8], unsigned char response[16])
+{
+ uint8_t challenge[16];
+ qToBigEndian<qint32>(number1, &challenge[0]);
+ qToBigEndian<qint32>(number2, &challenge[4]);
+ memcpy(&challenge[8], key3, 8);
+ MD5 md5;
+ md5.addBytes(challenge, sizeof(challenge));
+ Vector<uint8_t, 16> digest;
+ md5.checksum(digest);
+ memcpy(response, digest.data(), 16);
+}
+
+/*!
+ Parses and returns a WebSocket challenge number according to the
+ method specified in the WebSocket protocol.
+
+ The field contains numeric digits interspersed with spaces and
+ non-numeric digits. The protocol ignores the characters that are
+ neither digits nor spaces. The digits are concatenated and
+ interpreted as a long int. The result is this number divided by
+ the number of spaces.
+ */
+static quint32 parseWebSocketChallengeNumber(QString field)
+{
+ QString nString;
+ int numSpaces = 0;
+ for (int i = 0; i < field.size(); i++) {
+ QChar c = field[i];
+ if (c == (QChar)' ') {
+ numSpaces++;
+ } else if ((c >= (QChar)'0') && (c <= (QChar)'9')) {
+ nString.append((QChar)c);
+ }
+ }
+ quint32 num = nString.toLong();
+ quint32 result = (numSpaces ? (num / numSpaces) : num);
+ return result;
+}
+
+static InspectorServerQt* s_inspectorServer;
+
+InspectorServerQt* InspectorServerQt::server()
+{
+ // s_inspectorServer is deleted in unregisterClient() when the last client is unregistered.
+ if (!s_inspectorServer)
+ s_inspectorServer = new InspectorServerQt();
+
+ return s_inspectorServer;
+}
+
+InspectorServerQt::InspectorServerQt()
+ : QObject()
+ , m_tcpServer(0)
+ , m_pageNumber(1)
+{
+}
+
+InspectorServerQt::~InspectorServerQt()
+{
+ close();
+}
+
+void InspectorServerQt::listen(quint16 port)
+{
+ if (m_tcpServer)
+ return;
+
+ m_tcpServer = new QTcpServer();
+ m_tcpServer->listen(QHostAddress::Any, port);
+ connect(m_tcpServer, SIGNAL(newConnection()), SLOT(newConnection()));
+}
+
+void InspectorServerQt::close()
+{
+ if (m_tcpServer) {
+ m_tcpServer->close();
+ delete m_tcpServer;
+ }
+ m_tcpServer = 0;
+}
+
+InspectorClientQt* InspectorServerQt::inspectorClientForPage(int pageNum)
+{
+ InspectorClientQt* client = m_inspectorClients.value(pageNum);
+ return client;
+}
+
+void InspectorServerQt::registerClient(InspectorClientQt* client)
+{
+ if (!m_inspectorClients.key(client))
+ m_inspectorClients.insert(m_pageNumber++, client);
+}
+
+void InspectorServerQt::unregisterClient(InspectorClientQt* client)
+{
+ int pageNum = m_inspectorClients.key(client, -1);
+ if (pageNum >= 0)
+ m_inspectorClients.remove(pageNum);
+ if (!m_inspectorClients.size()) {
+ // s_inspectorServer points to this.
+ s_inspectorServer = 0;
+ close();
+ deleteLater();
+ }
+}
+
+void InspectorServerQt::newConnection()
+{
+ QTcpSocket* tcpConnection = m_tcpServer->nextPendingConnection();
+ InspectorServerRequestHandlerQt* handler = new InspectorServerRequestHandlerQt(tcpConnection, this);
+ handler->setParent(this);
+}
+
+InspectorServerRequestHandlerQt::InspectorServerRequestHandlerQt(QTcpSocket* tcpConnection, InspectorServerQt* server)
+ : QObject(server)
+ , m_tcpConnection(tcpConnection)
+ , m_server(server)
+ , m_inspectorClient(0)
+{
+ m_endOfHeaders = false;
+ m_contentLength = 0;
+
+ connect(m_tcpConnection, SIGNAL(readyRead()), SLOT(tcpReadyRead()));
+ connect(m_tcpConnection, SIGNAL(disconnected()), SLOT(tcpConnectionDisconnected()));
+}
+
+InspectorServerRequestHandlerQt::~InspectorServerRequestHandlerQt()
+{
+}
+
+void InspectorServerRequestHandlerQt::tcpReadyRead()
+{
+ QHttpRequestHeader header;
+ bool isWebSocket = false;
+ if (!m_tcpConnection)
+ return;
+
+ if (!m_endOfHeaders) {
+ while (m_tcpConnection->bytesAvailable() && !m_endOfHeaders) {
+ QByteArray line = m_tcpConnection->readLine();
+ m_data.append(line);
+ if (line == "\r\n")
+ m_endOfHeaders = true;
+ }
+ if (m_endOfHeaders) {
+ header = QHttpRequestHeader(QString::fromLatin1(m_data));
+ if (header.isValid()) {
+ m_path = header.path();
+ m_contentType = header.contentType().toLatin1();
+ m_contentLength = header.contentLength();
+ if (header.hasKey("Upgrade") && (header.value("Upgrade") == QLatin1String("WebSocket")))
+ isWebSocket = true;
+
+ m_data.clear();
+ }
+ }
+ }
+
+ if (m_endOfHeaders) {
+ QStringList pathAndQuery = m_path.split("?");
+ m_path = pathAndQuery[0];
+ QStringList words = m_path.split(QString::fromLatin1("/"));
+
+ if (isWebSocket) {
+ // switch to websocket-style WebSocketService messaging
+ if (m_tcpConnection) {
+ m_tcpConnection->disconnect(SIGNAL(readyRead()));
+ connect(m_tcpConnection, SIGNAL(readyRead()), SLOT(webSocketReadyRead()));
+
+ QByteArray key3 = m_tcpConnection->read(8);
+
+ quint32 number1 = parseWebSocketChallengeNumber(header.value("Sec-WebSocket-Key1"));
+ quint32 number2 = parseWebSocketChallengeNumber(header.value("Sec-WebSocket-Key2"));
+
+ char responseData[16];
+ generateWebSocketChallengeResponse(number1, number2, (unsigned char*)key3.data(), (unsigned char*)responseData);
+ QByteArray response(responseData, sizeof(responseData));
+
+ QHttpResponseHeader responseHeader(101, "WebSocket Protocol Handshake", 1, 1);
+ responseHeader.setValue("Upgrade", header.value("Upgrade"));
+ responseHeader.setValue("Connection", header.value("Connection"));
+ responseHeader.setValue("Sec-WebSocket-Origin", header.value("Origin"));
+ responseHeader.setValue("Sec-WebSocket-Location", ("ws://" + header.value("Host") + m_path));
+ responseHeader.setContentLength(response.size());
+ m_tcpConnection->write(responseHeader.toString().toLatin1());
+ m_tcpConnection->write(response);
+ m_tcpConnection->flush();
+
+ if ((words.size() == 4)
+ && (words[1] == QString::fromLatin1("devtools"))
+ && (words[2] == QString::fromLatin1("page"))) {
+ int pageNum = words[3].toInt();
+
+ m_inspectorClient = m_server->inspectorClientForPage(pageNum);
+ // Attach remoteFrontendChannel to inspector, also transferring ownership.
+ if (m_inspectorClient)
+ m_inspectorClient->attachAndReplaceRemoteFrontend(new RemoteFrontendChannel(this));
+ }
+
+ }
+
+ return;
+ }
+ if (m_contentLength && (m_tcpConnection->bytesAvailable() < m_contentLength))
+ return;
+
+ QByteArray content = m_tcpConnection->read(m_contentLength);
+ m_endOfHeaders = false;
+
+ QByteArray response;
+ int code = 200;
+ QString text = QString::fromLatin1("OK");
+
+ // If no path is specified, generate an index page.
+ if ((m_path == "") || (m_path == "/")) {
+ QString indexHtml = "<html><head><title>Remote Web Inspector</title></head><body><ul>\n";
+ for (QMap<int, InspectorClientQt* >::const_iterator it = m_server->m_inspectorClients.begin();
+ it != m_server->m_inspectorClients.end();
+ ++it) {
+ indexHtml.append(QString("<li><a href=\"/webkit/inspector/inspector.html?page=%1\">%2</li>\n")
+ .arg(it.key())
+ .arg(it.value()->m_inspectedWebPage->mainFrame()->url().toString()));
+ }
+ indexHtml.append("</ul></body></html>");
+ response = indexHtml.toLatin1();
+ } else {
+ QString path = QString(":%1").arg(m_path);
+ QFile file(path);
+ // It seems that there should be an enum or define for these status codes somewhere in Qt or WebKit,
+ // but grep fails to turn one up.
+ // QNetwork uses the numeric values directly.
+ if (file.exists()) {
+ file.open(QIODevice::ReadOnly);
+ response = file.readAll();
+ } else {
+ code = 404;
+ text = QString::fromLatin1("Not OK");
+ }
+ }
+
+ QHttpResponseHeader responseHeader(code, text, 1, 0);
+ responseHeader.setContentLength(response.size());
+ if (!m_contentType.isEmpty())
+ responseHeader.setContentType(QString::fromLatin1(m_contentType));
+
+ QByteArray asciiHeader = responseHeader.toString().toAscii();
+ m_tcpConnection->write(asciiHeader);
+
+ m_tcpConnection->write(response);
+ m_tcpConnection->flush();
+ m_tcpConnection->close();
+
+ return;
+ }
+}
+
+void InspectorServerRequestHandlerQt::tcpConnectionDisconnected()
+{
+ if (m_inspectorClient)
+ m_inspectorClient->detachRemoteFrontend();
+ m_tcpConnection->deleteLater();
+ m_tcpConnection = 0;
+}
+
+int InspectorServerRequestHandlerQt::webSocketSend(QByteArray payload)
+{
+ Q_ASSERT(m_tcpConnection);
+ m_tcpConnection->putChar(0x00);
+ int nBytes = m_tcpConnection->write(payload);
+ m_tcpConnection->putChar(0xFF);
+ m_tcpConnection->flush();
+ return nBytes;
+}
+
+int InspectorServerRequestHandlerQt::webSocketSend(const char* data, size_t length)
+{
+ Q_ASSERT(m_tcpConnection);
+ m_tcpConnection->putChar(0x00);
+ int nBytes = m_tcpConnection->write(data, length);
+ m_tcpConnection->putChar(0xFF);
+ m_tcpConnection->flush();
+ return nBytes;
+}
+
+void InspectorServerRequestHandlerQt::webSocketReadyRead()
+{
+ Q_ASSERT(m_tcpConnection);
+ if (!m_tcpConnection->bytesAvailable())
+ return;
+ QByteArray content = m_tcpConnection->read(m_tcpConnection->bytesAvailable());
+ m_data.append(content);
+ while (m_data.size() > 0) {
+ // first byte in websocket frame should be 0
+ Q_ASSERT(!m_data[0]);
+
+ // Start of WebSocket frame is indicated by 0
+ if (m_data[0]) {
+ qCritical() << "webSocketReadyRead: unknown frame type" << m_data[0];
+ m_data.clear();
+ m_tcpConnection->close();
+ return;
+ }
+
+ // End of WebSocket frame indicated by 0xff.
+ int pos = m_data.indexOf(0xff, 1);
+ if (pos < 1)
+ return;
+
+ // After above checks, length will be >= 0.
+ size_t length = pos - 1;
+ if (length <= 0)
+ return;
+
+ QByteArray payload = m_data.mid(1, length);
+
+ if (m_inspectorClient) {
+ InspectorController* inspectorController = m_inspectorClient->m_inspectedWebPage->d->page->inspectorController();
+ inspectorController->inspectorBackendDispatcher()->dispatch(QString::fromUtf8(payload));
+ }
+
+ // Remove this WebSocket message from m_data (payload, start-of-frame byte, end-of-frame byte).
+ m_data = m_data.mid(length + 2);
+ }
+}
+
+RemoteFrontendChannel::RemoteFrontendChannel(InspectorServerRequestHandlerQt* requestHandler)
+ : QObject(requestHandler)
+ , m_requestHandler(requestHandler)
+{
+}
+
+bool RemoteFrontendChannel::sendMessageToFrontend(const String& message)
+{
+ if (!m_requestHandler)
+ return false;
+ CString cstr = message.utf8();
+ return m_requestHandler->webSocketSend(cstr.data(), cstr.length());
+}
+
+}
diff --git a/WebKit/qt/WebCoreSupport/InspectorServerQt.h b/WebKit/qt/WebCoreSupport/InspectorServerQt.h
new file mode 100644
index 0000000..74e8c2f
--- /dev/null
+++ b/WebKit/qt/WebCoreSupport/InspectorServerQt.h
@@ -0,0 +1,110 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef InspectorServerQt_h
+#define InspectorServerQt_h
+
+#include <QList>
+#include <QMap>
+#include <QObject>
+#include <QPair>
+#include <QString>
+#include <wtf/Forward.h>
+
+class QTcpServer;
+class QTcpSocket;
+class QWebPage;
+
+namespace WebCore {
+class InspectorServerRequestHandlerQt;
+class InspectorClientQt;
+
+class InspectorServerQt : public QObject {
+ Q_OBJECT
+public:
+
+ static InspectorServerQt* server();
+
+ void listen(quint16 port);
+
+ void registerClient(InspectorClientQt* client);
+ void unregisterClient(InspectorClientQt* client);
+
+ void close();
+ InspectorClientQt* inspectorClientForPage(int pageNum);
+
+protected:
+ InspectorServerQt();
+ virtual ~InspectorServerQt();
+
+private slots:
+ void newConnection();
+
+private:
+ QTcpServer* m_tcpServer;
+ QMap<int, InspectorClientQt*> m_inspectorClients;
+ int m_pageNumber;
+
+ friend class InspectorServerRequestHandlerQt;
+};
+
+class RemoteFrontendChannel : public QObject {
+ Q_OBJECT
+public:
+
+ RemoteFrontendChannel(InspectorServerRequestHandlerQt* requestHandler);
+ bool sendMessageToFrontend(const String& message);
+
+private:
+ InspectorServerRequestHandlerQt* m_requestHandler;
+};
+
+class InspectorServerRequestHandlerQt : public QObject {
+ Q_OBJECT
+public:
+
+ InspectorServerRequestHandlerQt(QTcpSocket *tcpConnection, InspectorServerQt *server);
+ virtual ~InspectorServerRequestHandlerQt();
+ virtual int webSocketSend(QByteArray payload);
+ virtual int webSocketSend(const char *payload, size_t length);
+
+private slots:
+ void tcpReadyRead();
+ void tcpConnectionDisconnected();
+ void webSocketReadyRead();
+
+private:
+ QTcpSocket* m_tcpConnection;
+ InspectorServerQt* m_server;
+
+ QString m_path;
+ QByteArray m_contentType;
+ int m_contentLength;
+ bool m_endOfHeaders;
+ QByteArray m_data;
+ InspectorClientQt* m_inspectorClient;
+
+ void handleInspectorRequest(QStringList words);
+ void handleFromFrontendRequest();
+ void handleResourceRequest(QStringList words);
+
+};
+
+}
+#endif
diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.cpp b/WebKit/qt/WebCoreSupport/PageClientQt.cpp
index 62f48ff..ea209d9 100644
--- a/WebKit/qt/WebCoreSupport/PageClientQt.cpp
+++ b/WebKit/qt/WebCoreSupport/PageClientQt.cpp
@@ -48,12 +48,10 @@ bool PageClientQWidget::inputMethodEnabled() const
return view->testAttribute(Qt::WA_InputMethodEnabled);
}
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
void PageClientQWidget::setInputMethodHints(Qt::InputMethodHints hints)
{
view->setInputMethodHints(hints);
}
-#endif
#ifndef QT_NO_CURSOR
QCursor PageClientQWidget::cursor() const
@@ -215,26 +213,18 @@ void PageClientQGraphicsWidget::updateTiledBackingStoreScale()
void PageClientQGraphicsWidget::setInputMethodEnabled(bool enable)
{
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
view->setFlag(QGraphicsItem::ItemAcceptsInputMethod, enable);
-#endif
}
bool PageClientQGraphicsWidget::inputMethodEnabled() const
{
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
return view->flags() & QGraphicsItem::ItemAcceptsInputMethod;
-#else
- return false;
-#endif
}
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
void PageClientQGraphicsWidget::setInputMethodHints(Qt::InputMethodHints hints)
{
view->setInputMethodHints(hints);
}
-#endif
#ifndef QT_NO_CURSOR
QCursor PageClientQGraphicsWidget::cursor() const
@@ -318,9 +308,6 @@ QStyle* PageClientQGraphicsWidget::style() const
QRectF PageClientQGraphicsWidget::windowRect() const
{
- if (!view->deviceSize().isEmpty())
- return QRectF(QRect(QPoint(0, 0), view->deviceSize()));
-
if (!view->scene())
return QRectF();
diff --git a/WebKit/qt/WebCoreSupport/PageClientQt.h b/WebKit/qt/WebCoreSupport/PageClientQt.h
index 65ee849..eea7f40 100644
--- a/WebKit/qt/WebCoreSupport/PageClientQt.h
+++ b/WebKit/qt/WebCoreSupport/PageClientQt.h
@@ -58,9 +58,7 @@ public:
virtual void update(const QRect& dirtyRect);
virtual void setInputMethodEnabled(bool enable);
virtual bool inputMethodEnabled() const;
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
virtual void setInputMethodHints(Qt::InputMethodHints hints);
-#endif
#ifndef QT_NO_CURSOR
virtual QCursor cursor() const;
@@ -93,9 +91,7 @@ class QGraphicsItemOverlay : public QGraphicsItem {
, page(p)
{
setPos(0, 0);
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
-#endif
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
@@ -146,9 +142,7 @@ public:
virtual void update(const QRect& dirtyRect);
virtual void setInputMethodEnabled(bool enable);
virtual bool inputMethodEnabled() const;
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
virtual void setInputMethodHints(Qt::InputMethodHints hints);
-#endif
#ifndef QT_NO_CURSOR
virtual QCursor cursor() const;
diff --git a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
index fd86e91..1f91d8c 100644
--- a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
+++ b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.cpp
@@ -91,16 +91,20 @@ QWebKitPlatformPlugin* QtPlatformPlugin::plugin()
QWebSelectMethod* QtPlatformPlugin::createSelectInputMethod()
{
QWebKitPlatformPlugin* p = plugin();
- return p ? p->createSelectInputMethod() : 0;
+ return p ? qobject_cast<QWebSelectMethod*>(p->createExtension(QWebKitPlatformPlugin::MultipleSelections)) : 0;
}
QWebNotificationPresenter* QtPlatformPlugin::createNotificationPresenter()
{
QWebKitPlatformPlugin* p = plugin();
- if (!p)
- return 0;
- return p->createNotificationPresenter();
+ return p ? qobject_cast<QWebNotificationPresenter*>(p->createExtension(QWebKitPlatformPlugin::Notifications)) : 0;
+}
+
+QWebHapticFeedbackPlayer* QtPlatformPlugin::createHapticFeedbackPlayer()
+{
+ QWebKitPlatformPlugin* p = plugin();
+ return p ? qobject_cast<QWebHapticFeedbackPlayer*>(p->createExtension(QWebKitPlatformPlugin::Haptics)) : 0;
}
}
diff --git a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
index 9bdab75..a3e50c2 100644
--- a/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
+++ b/WebKit/qt/WebCoreSupport/QtPlatformPlugin.h
@@ -26,6 +26,7 @@
class QWebSelectMethod;
class QWebKitPlatformPlugin;
class QWebNotificationPresenter;
+class QWebHapticFeedbackPlayer;
class QWebSelectData;
namespace WebCore {
@@ -37,6 +38,7 @@ public:
QWebSelectMethod* createSelectInputMethod();
QWebNotificationPresenter* createNotificationPresenter();
+ QWebHapticFeedbackPlayer* createHapticFeedbackPlayer();
QWebKitPlatformPlugin* plugin();
diff --git a/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp
index 948e0cd..7cd255f 100644
--- a/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp
+++ b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.cpp
@@ -30,8 +30,10 @@
#include "config.h"
#include "WebPlatformStrategies.h"
-#include "NotImplemented.h"
+#include "Chrome.h"
+#include "ChromeClientQt.h"
#include <IntSize.h>
+#include "NotImplemented.h"
#include <Page.h>
#include <PageGroup.h>
#include <PluginDatabase.h>
@@ -43,14 +45,13 @@
using namespace WebCore;
-void WebPlatformStrategies::initialize(QWebPage* webPage)
+void WebPlatformStrategies::initialize()
{
- DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, (webPage));
+ DEFINE_STATIC_LOCAL(WebPlatformStrategies, platformStrategies, ());
Q_UNUSED(platformStrategies);
}
-WebPlatformStrategies::WebPlatformStrategies(QWebPage* webPage)
- : m_page(webPage)
+WebPlatformStrategies::WebPlatformStrategies()
{
setPlatformStrategies(this);
}
@@ -78,10 +79,11 @@ void WebPlatformStrategies::refreshPlugins()
PluginDatabase::installedPlugins()->refresh();
}
-void WebPlatformStrategies::getPluginInfo(Vector<WebCore::PluginInfo>& outPlugins)
+void WebPlatformStrategies::getPluginInfo(const WebCore::Page* page, Vector<WebCore::PluginInfo>& outPlugins)
{
- QWebPluginFactory* factory = m_page->pluginFactory();
- if (factory) {
+ QWebPage* qPage = static_cast<ChromeClientQt*>(page->chrome()->client())->m_webPage;
+ QWebPluginFactory* factory;
+ if (qPage && (factory = qPage->pluginFactory())) {
QList<QWebPluginFactory::Plugin> qplugins = factory->plugins();
for (int i = 0; i < qplugins.count(); ++i) {
@@ -198,6 +200,56 @@ String WebPlatformStrategies::contextMenuItemTagCopyImageToClipboard()
return QCoreApplication::translate("QWebPage", "Copy Image", "Copy Link context menu item");
}
+String WebPlatformStrategies::contextMenuItemTagOpenVideoInNewWindow()
+{
+ return QCoreApplication::translate("QWebPage", "Open Video", "Open Video in New Window");
+}
+
+String WebPlatformStrategies::contextMenuItemTagOpenAudioInNewWindow()
+{
+ return QCoreApplication::translate("QWebPage", "Open Audio", "Open Audio in New Window");
+}
+
+String WebPlatformStrategies::contextMenuItemTagCopyVideoLinkToClipboard()
+{
+ return QCoreApplication::translate("QWebPage", "Copy Video", "Copy Video Link Location");
+}
+
+String WebPlatformStrategies::contextMenuItemTagCopyAudioLinkToClipboard()
+{
+ return QCoreApplication::translate("QWebPage", "Copy Audio", "Copy Audio Link Location");
+}
+
+String WebPlatformStrategies::contextMenuItemTagToggleMediaControls()
+{
+ return QCoreApplication::translate("QWebPage", "Toggle Controls", "Toggle Media Controls");
+}
+
+String WebPlatformStrategies::contextMenuItemTagToggleMediaLoop()
+{
+ return QCoreApplication::translate("QWebPage", "Toggle Loop", "Toggle Media Loop Playback");
+}
+
+String WebPlatformStrategies::contextMenuItemTagEnterVideoFullscreen()
+{
+ return QCoreApplication::translate("QWebPage", "Enter Fullscreen", "Switch Video to Fullscreen");
+}
+
+String WebPlatformStrategies::contextMenuItemTagMediaPlay()
+{
+ return QCoreApplication::translate("QWebPage", "Play", "Play");
+}
+
+String WebPlatformStrategies::contextMenuItemTagMediaPause()
+{
+ return QCoreApplication::translate("QWebPage", "Pause", "Pause");
+}
+
+String WebPlatformStrategies::contextMenuItemTagMediaMute()
+{
+ return QCoreApplication::translate("QWebPage", "Mute", "Mute");
+}
+
String WebPlatformStrategies::contextMenuItemTagOpenFrameInNewWindow()
{
return QCoreApplication::translate("QWebPage", "Open Frame", "Open Frame in New Window context menu item");
diff --git a/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h
index 8ea60d9..ea366e0 100644
--- a/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h
+++ b/WebKit/qt/WebCoreSupport/WebPlatformStrategies.h
@@ -33,14 +33,16 @@
#include <PluginStrategy.h>
#include <VisitedLinkStrategy.h>
-class QWebPage;
+namespace WebCore {
+class Page;
+}
class WebPlatformStrategies : public WebCore::PlatformStrategies, private WebCore::PluginStrategy, private WebCore::LocalizationStrategy, private WebCore::VisitedLinkStrategy {
public:
- static void initialize(QWebPage* webPage);
+ static void initialize();
private:
- WebPlatformStrategies(QWebPage* webPage);
+ WebPlatformStrategies();
// WebCore::PlatformStrategies
virtual WebCore::PluginStrategy* createPluginStrategy();
@@ -49,7 +51,7 @@ private:
// WebCore::PluginStrategy
virtual void refreshPlugins();
- virtual void getPluginInfo(Vector<WebCore::PluginInfo>&);
+ virtual void getPluginInfo(const WebCore::Page*, Vector<WebCore::PluginInfo>&);
// WebCore::LocalizationStrategy
virtual WTF::String inputElementAltText();
@@ -95,6 +97,16 @@ private:
virtual WTF::String contextMenuItemTagLeftToRight();
virtual WTF::String contextMenuItemTagRightToLeft();
virtual WTF::String contextMenuItemTagInspectElement();
+ virtual WTF::String contextMenuItemTagOpenVideoInNewWindow();
+ virtual WTF::String contextMenuItemTagOpenAudioInNewWindow();
+ virtual WTF::String contextMenuItemTagCopyVideoLinkToClipboard();
+ virtual WTF::String contextMenuItemTagCopyAudioLinkToClipboard();
+ virtual WTF::String contextMenuItemTagToggleMediaControls();
+ virtual WTF::String contextMenuItemTagToggleMediaLoop();
+ virtual WTF::String contextMenuItemTagEnterVideoFullscreen();
+ virtual WTF::String contextMenuItemTagMediaPlay();
+ virtual WTF::String contextMenuItemTagMediaPause();
+ virtual WTF::String contextMenuItemTagMediaMute();
virtual WTF::String searchMenuNoRecentSearchesText();
virtual WTF::String searchMenuRecentSearchesText();
virtual WTF::String searchMenuClearRecentSearchesText();
@@ -134,8 +146,6 @@ private:
// WebCore::VisitedLinkStrategy
virtual bool isLinkVisited(WebCore::Page*, WebCore::LinkHash);
virtual void addVisitedLink(WebCore::Page*, WebCore::LinkHash);
-
- QWebPage* m_page;
};
#endif // WebPlatformStrategies_h