summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/InspectorServer
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebKit2/UIProcess/InspectorServer
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebKit2/UIProcess/InspectorServer')
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp13
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h14
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp13
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h6
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.cpp9
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.h8
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp11
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp109
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp125
-rw-r--r--Source/WebKit2/UIProcess/InspectorServer/soup/WebSocketServerSoup.cpp79
10 files changed, 39 insertions, 348 deletions
diff --git a/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp b/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp
index 734926c6c..5be2e9d2f 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp
+++ b/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.cpp
@@ -74,7 +74,7 @@ size_t HTTPRequest::parseRequestLine(const char* data, size_t length, String& fa
{
String url;
size_t result = parseHTTPRequestLine(data, length, failureReason, m_requestMethod, url, m_httpVersion);
- m_url = KURL(KURL(), url);
+ m_url = URL(URL(), url);
return result;
}
@@ -82,7 +82,7 @@ size_t HTTPRequest::parseHeaders(const char* data, size_t length, String& failur
{
const char* p = data;
const char* end = data + length;
- AtomicString name;
+ String name;
String value;
for (; p < data + length; p++) {
size_t consumedLength = parseHTTPHeader(p, end - p, failureReason, name, value);
@@ -93,6 +93,13 @@ size_t HTTPRequest::parseHeaders(const char* data, size_t length, String& failur
break;
m_headerFields.add(name, value);
}
+
+ // If we got here and "name" is empty, it means the headers are valid and ended with a
+ // blank line (parseHTTPHeader returns "name" as empty if parsing a blank line), otherwise
+ // the headers didn't end with a blank line and we have an invalid request.
+ // See also http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
+ if (!name.isEmpty())
+ return 0;
return p - data;
}
@@ -106,7 +113,7 @@ HTTPRequest::HTTPRequest()
{
}
-HTTPRequest::HTTPRequest(const String& requestMethod, const KURL& url, HTTPVersion version)
+HTTPRequest::HTTPRequest(const String& requestMethod, const URL& url, HTTPVersion version)
: m_url(url)
, m_httpVersion(version)
, m_requestMethod(requestMethod)
diff --git a/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h b/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h
index 719e24114..ffb317ec8 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h
+++ b/Source/WebKit2/UIProcess/InspectorServer/HTTPRequest.h
@@ -34,7 +34,7 @@
#include <WebCore/HTTPHeaderMap.h>
#include <WebCore/HTTPParsers.h>
-#include <WebCore/KURL.h>
+#include <WebCore/URL.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
@@ -43,16 +43,16 @@ namespace WebKit {
class HTTPRequest : public RefCounted<HTTPRequest> {
public:
- static PassRefPtr<HTTPRequest> create() { return adoptRef(new HTTPRequest()); }
- static PassRefPtr<HTTPRequest> create(const String& requestMethod, const WebCore::KURL& url, WebCore::HTTPVersion version) { return adoptRef(new HTTPRequest(requestMethod, url, version)); }
+ static Ref<HTTPRequest> create() { return adoptRef(*new HTTPRequest()); }
+ static Ref<HTTPRequest> create(const String& requestMethod, const WebCore::URL& url, WebCore::HTTPVersion version) { return adoptRef(*new HTTPRequest(requestMethod, url, version)); }
static PassRefPtr<HTTPRequest> parseHTTPRequestFromBuffer(const char* data, size_t length, String& failureReason);
virtual ~HTTPRequest();
String requestMethod() const { return m_requestMethod; }
void setRequestMethod(const String& method) { m_requestMethod = method; }
- WebCore::KURL url() const { return m_url; }
- void setURL(const WebCore::KURL& url) { m_url = url; }
+ WebCore::URL url() const { return m_url; }
+ void setURL(const WebCore::URL& url) { m_url = url; }
const Vector<unsigned char>& body() const { return m_body; }
@@ -62,14 +62,14 @@ public:
protected:
HTTPRequest();
- HTTPRequest(const String& requestMethod, const WebCore::KURL&, WebCore::HTTPVersion);
+ HTTPRequest(const String& requestMethod, const WebCore::URL&, WebCore::HTTPVersion);
// Parsing helpers.
size_t parseRequestLine(const char* data, size_t length, String& failureReason);
size_t parseHeaders(const char* data, size_t length, String& failureReason);
size_t parseRequestBody(const char* data, size_t length);
- WebCore::KURL m_url;
+ WebCore::URL m_url;
WebCore::HTTPVersion m_httpVersion;
String m_requestMethod;
WebCore::HTTPHeaderMap m_headerFields;
diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp b/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp
index cbbd73f66..6374d5159 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp
+++ b/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.cpp
@@ -30,6 +30,7 @@
#include "WebInspectorServer.h"
+#include "HTTPHeaderNames.h"
#include "HTTPRequest.h"
#include "WebInspectorProxy.h"
#include "WebSocketServerConnection.h"
@@ -50,7 +51,7 @@ static unsigned pageIdFromRequestPath(const String& path)
return number;
}
-WebInspectorServer& WebInspectorServer::shared()
+WebInspectorServer& WebInspectorServer::singleton()
{
static WebInspectorServer& server = *new WebInspectorServer;
return server;
@@ -111,7 +112,7 @@ void WebInspectorServer::sendMessageOverConnection(unsigned pageIdForConnection,
void WebInspectorServer::didReceiveUnrecognizedHTTPRequest(WebSocketServerConnection* connection, PassRefPtr<HTTPRequest> request)
{
// request->url() contains only the path extracted from the HTTP request line
- // and KURL is poor at parsing incomplete URLs, so extract the interesting parts manually.
+ // and URL is poor at parsing incomplete URLs, so extract the interesting parts manually.
String path = request->url();
size_t pathEnd = path.find('?');
if (pathEnd == notFound)
@@ -126,10 +127,10 @@ void WebInspectorServer::didReceiveUnrecognizedHTTPRequest(WebSocketServerConnec
bool found = platformResourceForPath(path, body, contentType);
HTTPHeaderMap headerFields;
- headerFields.set("Connection", "close");
- headerFields.set("Content-Length", String::number(body.size()));
+ headerFields.set(HTTPHeaderName::Connection, "close");
+ headerFields.set(HTTPHeaderName::ContentLength, String::number(body.size()));
if (found)
- headerFields.set("Content-Type", contentType);
+ headerFields.set(HTTPHeaderName::ContentType, contentType);
// Send when ready and close immediately afterwards.
connection->sendHTTPResponseHeader(found ? 200 : 404, found ? "OK" : "Not Found", headerFields);
@@ -142,7 +143,7 @@ bool WebInspectorServer::didReceiveWebSocketUpgradeHTTPRequest(WebSocketServerCo
String path = request->url();
// NOTE: Keep this in sync with WebCore/inspector/front-end/inspector.js.
- DEFINE_STATIC_LOCAL(const String, inspectorWebSocketConnectionPathPrefix, (ASCIILiteral("/devtools/page/")));
+ DEPRECATED_DEFINE_STATIC_LOCAL(const String, inspectorWebSocketConnectionPathPrefix, (ASCIILiteral("/devtools/page/")));
// Unknown path requested.
if (!path.startsWith(inspectorWebSocketConnectionPathPrefix))
diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h b/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h
index fc8ddf485..4df55898f 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h
+++ b/Source/WebKit2/UIProcess/InspectorServer/WebInspectorServer.h
@@ -41,7 +41,7 @@ class WebInspectorProxy;
class WebInspectorServer : public WebSocketServer, public WebSocketServerClient {
public:
typedef HashMap<unsigned, WebInspectorProxy*> ClientMap;
- static WebInspectorServer& shared();
+ static WebInspectorServer& singleton();
// Page registry to manage known pages.
int registerPage(WebInspectorProxy* client);
@@ -67,10 +67,6 @@ private:
void closeConnection(WebInspectorProxy*, WebSocketServerConnection*);
-#if PLATFORM(GTK)
- String inspectorServerFilesPath();
- String m_inspectorServerFilesPath;
-#endif
unsigned m_nextAvailablePageId;
ClientMap m_clientMap;
HashMap<unsigned, WebSocketServerConnection*> m_connectionMap;
diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.cpp b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.cpp
index cf4ee1305..fd8a930a5 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.cpp
+++ b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.cpp
@@ -32,7 +32,6 @@
#include "WebSocketServerConnection.h"
#include <WebCore/SocketStreamHandle.h>
-#include <wtf/PassOwnPtr.h>
#if PLATFORM(QT)
#include "WebSocketServerQt.h"
@@ -82,20 +81,20 @@ void WebSocketServer::close()
m_bindAddress = String();
}
-void WebSocketServer::didAcceptConnection(PassOwnPtr<WebSocketServerConnection> connection)
+void WebSocketServer::didAcceptConnection(std::unique_ptr<WebSocketServerConnection> connection)
{
- m_connections.append(connection);
+ m_connections.append(WTFMove(connection));
}
void WebSocketServer::didCloseWebSocketServerConnection(WebSocketServerConnection* connection)
{
- Deque<OwnPtr<WebSocketServerConnection> >::iterator end = m_connections.end();
- for (Deque<OwnPtr<WebSocketServerConnection> >::iterator it = m_connections.begin(); it != end; ++it) {
+ for (auto it = m_connections.begin(), end = m_connections.end(); it != end; ++it) {
if (it->get() == connection) {
m_connections.remove(it);
return;
}
}
+
ASSERT_NOT_REACHED();
}
diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.h b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.h
index 68ed64f7c..8472eefb5 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.h
+++ b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServer.h
@@ -29,13 +29,13 @@
#if ENABLE(INSPECTOR_SERVER)
+#include <memory>
#include <wtf/Deque.h>
-#include <wtf/OwnPtr.h>
#include <wtf/text/WTFString.h>
#if USE(SOUP)
#include <gio/gio.h>
-#include <wtf/gobject/GRefPtr.h>
+#include <wtf/glib/GRefPtr.h>
#endif
#if PLATFORM(QT)
@@ -67,7 +67,7 @@ public:
void close();
WebSocketServerClient* client() const { return m_client; }
- void didAcceptConnection(PassOwnPtr<WebSocketServerConnection>);
+ void didAcceptConnection(std::unique_ptr<WebSocketServerConnection>);
private:
void didCloseWebSocketServerConnection(WebSocketServerConnection*);
@@ -77,7 +77,7 @@ private:
void platformClose();
ServerState m_state;
- Deque<OwnPtr<WebSocketServerConnection> > m_connections;
+ Deque<std::unique_ptr<WebSocketServerConnection>> m_connections;
WebSocketServerClient* m_client;
String m_bindAddress;
unsigned short m_port;
diff --git a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp
index a33855546..94a24c90c 100644
--- a/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp
+++ b/Source/WebKit2/UIProcess/InspectorServer/WebSocketServerConnection.cpp
@@ -30,6 +30,7 @@
#include "WebSocketServerConnection.h"
+#include "HTTPHeaderNames.h"
#include "HTTPRequest.h"
#include "WebSocketServer.h"
#include "WebSocketServerClient.h"
@@ -125,7 +126,7 @@ void WebSocketServerConnection::sendRawData(const char* data, size_t length)
void WebSocketServerConnection::didCloseSocketStream(SocketStreamHandle*)
{
// Destroy the SocketStreamHandle now to prevent closing an already closed socket later.
- m_socket.clear();
+ m_socket = nullptr;
// Web Socket Mode.
if (m_mode == WebSocket)
@@ -177,7 +178,7 @@ void WebSocketServerConnection::readHTTPMessage()
// If this is a WebSocket request, perform the WebSocket Handshake.
const HTTPHeaderMap& headers = request->headerFields();
- String upgradeHeaderValue = headers.get("Upgrade");
+ String upgradeHeaderValue = headers.get(HTTPHeaderName::Upgrade);
if (upgradeHeaderValue == "websocket") {
upgradeToWebSocketServerConnection(request);
return;
@@ -206,10 +207,10 @@ void WebSocketServerConnection::upgradeToWebSocketServerConnection(PassRefPtr<HT
// Build and send the WebSocket handshake response.
const HTTPHeaderMap& requestHeaders = protectedRequest->headerFields();
- String accept = WebSocketHandshake::getExpectedWebSocketAccept(requestHeaders.get("Sec-WebSocket-Key"));
+ String accept = WebSocketHandshake::getExpectedWebSocketAccept(requestHeaders.get(HTTPHeaderName::SecWebSocketKey));
HTTPHeaderMap responseHeaders;
- responseHeaders.add("Upgrade", requestHeaders.get("Upgrade"));
- responseHeaders.add("Connection", requestHeaders.get("Connection"));
+ responseHeaders.add("Upgrade", requestHeaders.get(HTTPHeaderName::Upgrade));
+ responseHeaders.add("Connection", requestHeaders.get(HTTPHeaderName::Connection));
responseHeaders.add("Sec-WebSocket-Accept", accept);
sendHTTPResponseHeader(101, "WebSocket Protocol Handshake", responseHeaders);
diff --git a/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp b/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp
deleted file mode 100644
index 0d94c5340..000000000
--- a/Source/WebKit2/UIProcess/InspectorServer/efl/WebInspectorServerEfl.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2012 Seokju Kwon (seokju.kwon@gmail.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(INSPECTOR_SERVER)
-#include "WebInspectorServer.h"
-
-#include "WebInspectorProxy.h"
-#include "WebPageProxy.h"
-#include <WebCore/EflInspectorUtilities.h>
-#include <WebCore/MIMETypeRegistry.h>
-#include <sys/stat.h>
-#include <wtf/text/StringBuilder.h>
-
-namespace WebKit {
-
-bool WebInspectorServer::platformResourceForPath(const String& path, Vector<char>& data, String& contentType)
-{
- // The page list contains an unformated list of pages that can be inspected with a link to open a session.
- if (path == "/pagelist.json") {
- buildPageList(data, contentType);
- return true;
- }
-
- // Point the default path to a formatted page that queries the page list and display them.
- String localPath = WebCore::inspectorResourcePath() + ((path == "/") ? ASCIILiteral("/inspectorPageIndex.html") : path);
-
- FILE* fileHandle = fopen(localPath.utf8().data(), "r");
- if (!fileHandle)
- return false;
-
- struct stat fileStat;
- if (fstat(fileno(fileHandle), &fileStat)) {
- fclose(fileHandle);
- return false;
- }
-
- data.grow(fileStat.st_size);
- int bytesRead = fread(data.data(), 1, fileStat.st_size, fileHandle);
- fclose(fileHandle);
-
- if (bytesRead < fileStat.st_size)
- return false;
-
- size_t extStart = localPath.reverseFind('.');
- if (extStart == notFound)
- return false;
-
- String ext = localPath.substring(extStart + 1);
- if (ext.isEmpty())
- return false;
-
- contentType = WebCore::MIMETypeRegistry::getMIMETypeForExtension(ext);
-
- return true;
-}
-
-void WebInspectorServer::buildPageList(Vector<char>& data, String& contentType)
-{
- StringBuilder builder;
- builder.append('[');
-
- ClientMap::iterator end = m_clientMap.end();
- for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) {
- WebPageProxy* webPage = it->value->page();
- if (it != m_clientMap.begin())
- builder.appendLiteral(", ");
- builder.appendLiteral("{ \"id\": ");
- builder.appendNumber(it->key);
- builder.appendLiteral(", \"title\": \"");
- builder.append(webPage->pageTitle());
- builder.appendLiteral("\", \"url\": \"");
- builder.append(webPage->activeURL());
- builder.appendLiteral("\", \"inspectorUrl\": \"");
- builder.appendLiteral("/inspector.html?page=");
- builder.appendNumber(it->key);
- builder.appendLiteral("\" }");
- }
-
- builder.append(']');
- CString clientList = builder.toString().utf8();
- data.append(clientList.data(), clientList.length());
- contentType = String("application/json; charset=utf-8", String::ConstructFromLiteral);
-}
-
-}
-#endif
diff --git a/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp b/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp
deleted file mode 100644
index b4cd214b1..000000000
--- a/Source/WebKit2/UIProcess/InspectorServer/gtk/WebInspectorServerGtk.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2012 Samsung Electronics Ltd. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(INSPECTOR_SERVER)
-#include "WebInspectorServer.h"
-
-#include "WebInspectorProxy.h"
-#include "WebPageProxy.h"
-#include <WebCore/FileSystem.h>
-#include <WebCore/MIMETypeRegistry.h>
-#include <gio/gio.h>
-#include <glib.h>
-#include <wtf/gobject/GOwnPtr.h>
-#include <wtf/text/CString.h>
-#include <wtf/text/StringBuilder.h>
-
-namespace WebKit {
-
-bool WebInspectorServer::platformResourceForPath(const String& path, Vector<char>& data, String& contentType)
-{
- // The page list contains an unformated list of pages that can be inspected with a link to open a session.
- if (path == "/pagelist.json") {
- buildPageList(data, contentType);
- return true;
- }
-
- // Point the default path to a formatted page that queries the page list and display them.
- CString localPath = WebCore::fileSystemRepresentation(inspectorServerFilesPath() + ((path == "/") ? "/inspectorPageIndex.html" : path));
- if (localPath.isNull())
- return false;
-
- GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(localPath.data()));
- GOwnPtr<GError> error;
- GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, 0, &error.outPtr()));
- if (!fileInfo) {
- StringBuilder builder;
- builder.appendLiteral("<!DOCTYPE html><html><head></head><body>Error: ");
- builder.appendNumber(error->code);
- builder.appendLiteral(", ");
- builder.append(error->message);
- builder.appendLiteral(" occurred during fetching webinspector resource files.<br>Make sure you ran make install or have set WEBKIT_INSPECTOR_SERVER_PATH in your environment to point to webinspector folder.</body></html>");
- CString cstr = builder.toString().utf8();
- data.append(cstr.data(), cstr.length());
- contentType = "text/html; charset=utf-8";
- g_warning("Error fetching webinspector resource files: %d, %s", error->code, error->message);
- return true;
- }
-
- GRefPtr<GFileInputStream> inputStream = adoptGRef(g_file_read(file.get(), 0, 0));
- if (!inputStream)
- return false;
-
- data.grow(g_file_info_get_size(fileInfo.get()));
- if (!g_input_stream_read_all(G_INPUT_STREAM(inputStream.get()), data.data(), data.size(), 0, 0, 0))
- return false;
-
- contentType = GOwnPtr<gchar>(g_file_info_get_attribute_as_string(fileInfo.get(), G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE)).get();
- return true;
-}
-
-void WebInspectorServer::buildPageList(Vector<char>& data, String& contentType)
-{
- StringBuilder builder;
- builder.appendLiteral("[ ");
- ClientMap::iterator end = m_clientMap.end();
- for (ClientMap::iterator it = m_clientMap.begin(); it != end; ++it) {
- WebPageProxy* webPage = it->value->page();
- if (it != m_clientMap.begin())
- builder.appendLiteral(", ");
- builder.appendLiteral("{ \"id\": ");
- builder.appendNumber(it->key);
- builder.appendLiteral(", \"title\": \"");
- builder.append(webPage->pageTitle());
- builder.appendLiteral("\", \"url\": \"");
- builder.append(webPage->activeURL());
- builder.appendLiteral("\", \"inspectorUrl\": \"");
- builder.appendLiteral("/inspector.html?page=");
- builder.appendNumber(it->key);
- builder.appendLiteral("\" }");
- }
- builder.appendLiteral(" ]");
- CString cstr = builder.toString().utf8();
- data.append(cstr.data(), cstr.length());
- contentType = "application/json; charset=utf-8";
-}
-
-String WebInspectorServer::inspectorServerFilesPath()
-{
- if (!m_inspectorServerFilesPath.isNull())
- return m_inspectorServerFilesPath;
-
- const char* environmentPath = g_getenv("WEBKIT_INSPECTOR_SERVER_PATH");
- if (environmentPath && g_file_test(environmentPath, G_FILE_TEST_IS_DIR))
- m_inspectorServerFilesPath = String(environmentPath);
- else
- m_inspectorServerFilesPath = String(WebCore::sharedResourcesPath().data()) + "/webinspector";
-
- return m_inspectorServerFilesPath;
-}
-
-}
-#endif
diff --git a/Source/WebKit2/UIProcess/InspectorServer/soup/WebSocketServerSoup.cpp b/Source/WebKit2/UIProcess/InspectorServer/soup/WebSocketServerSoup.cpp
deleted file mode 100644
index 28f4f21d4..000000000
--- a/Source/WebKit2/UIProcess/InspectorServer/soup/WebSocketServerSoup.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 Samsung Electronics Ltd. All Rights Reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(INSPECTOR_SERVER)
-#include "WebSocketServer.h"
-
-#include "Logging.h"
-#include "WebSocketServerConnection.h"
-#include <WebCore/SocketStreamHandle.h>
-#include <gio/gio.h>
-#include <glib.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/gobject/GOwnPtr.h>
-#include <wtf/text/CString.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-static gboolean connectionCallback(GSocketService* /*service*/, GSocketConnection* connection, GObject* /*sourceObject*/, WebSocketServer* server)
-{
-#if !LOG_DISABLED
- GRefPtr<GSocketAddress> socketAddress = adoptGRef(g_socket_connection_get_remote_address(connection, 0));
- GOwnPtr<gchar> addressString(g_inet_address_to_string(g_inet_socket_address_get_address(G_INET_SOCKET_ADDRESS(socketAddress.get()))));
- LOG(InspectorServer, "New Connection from %s:%d.", addressString.get(), g_inet_socket_address_get_port(G_INET_SOCKET_ADDRESS(socketAddress.get())));
-#endif
-
- OwnPtr<WebSocketServerConnection> webSocketConnection = adoptPtr(new WebSocketServerConnection(server->client(), server));
- webSocketConnection->setSocketHandle(SocketStreamHandle::create(connection, webSocketConnection.get()));
- server->didAcceptConnection(webSocketConnection.release());
-
- return TRUE;
-}
-
-void WebSocketServer::platformInitialize()
-{
- m_socketService = adoptGRef(g_socket_service_new());
- g_signal_connect(m_socketService.get(), "incoming", G_CALLBACK(connectionCallback), this);
- g_socket_service_start(m_socketService.get());
-}
-
-bool WebSocketServer::platformListen(const String& bindAddress, unsigned short port)
-{
- LOG(InspectorServer, "Listen to address=%s, port=%d.", bindAddress.utf8().data(), port);
- GRefPtr<GInetAddress> address = adoptGRef(g_inet_address_new_from_string(bindAddress.utf8().data()));
- GRefPtr<GSocketAddress> socketAddress = adoptGRef(g_inet_socket_address_new(address.get(), port));
- return g_socket_listener_add_address(G_SOCKET_LISTENER(m_socketService.get()), socketAddress.get(), G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_TCP, 0, 0, 0);
-}
-
-void WebSocketServer::platformClose()
-{
- g_socket_service_stop(m_socketService.get());
-}
-
-}
-
-#endif // ENABLE(INSPECTOR_SERVER)