diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-10-15 09:45:50 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-10-15 09:45:50 +0000 |
| commit | e15dd966d523731101f70ccf768bba12435a0208 (patch) | |
| tree | ae9cb828a24ded2585a41af3f21411523b47897d /Source/WebKit2/UIProcess/Network/CustomProtocols | |
| download | WebKitGtk-tarball-e15dd966d523731101f70ccf768bba12435a0208.tar.gz | |
webkitgtk-2.10.2webkitgtk-2.10.2
Diffstat (limited to 'Source/WebKit2/UIProcess/Network/CustomProtocols')
7 files changed, 476 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h new file mode 100644 index 000000000..6600a277f --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2012 Apple Inc. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. + */ + +#ifndef CustomProtocolManagerProxy_h +#define CustomProtocolManagerProxy_h + +#include "MessageReceiver.h" + +#if PLATFORM(COCOA) +#include <wtf/HashMap.h> +#include <wtf/RetainPtr.h> +OBJC_CLASS WKCustomProtocolLoader; +#endif + +namespace WebCore { +class ResourceRequest; +} // namespace WebCore + +namespace WebKit { + +class ChildProcessProxy; +class WebProcessPool; + +class CustomProtocolManagerProxy : public IPC::MessageReceiver { +public: + CustomProtocolManagerProxy(ChildProcessProxy*, WebProcessPool&); + ~CustomProtocolManagerProxy(); + + void startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest&); + void stopLoading(uint64_t customProtocolID); + +private: + // IPC::MessageReceiver + virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override; + + ChildProcessProxy* m_childProcessProxy; + WebProcessPool& m_processPool; + +#if PLATFORM(COCOA) + typedef HashMap<uint64_t, RetainPtr<WKCustomProtocolLoader>> LoaderMap; + LoaderMap m_loaderMap; +#endif +}; + +} // namespace WebKit + +#endif // CustomProtocolManagerProxy_h diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in new file mode 100644 index 000000000..93c0ad435 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in @@ -0,0 +1,26 @@ +# Copyright (C) 2012 Apple Inc. 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. + +messages -> CustomProtocolManagerProxy { + StartLoading(uint64_t customProtocolID, WebCore::ResourceRequest request) + StopLoading(uint64_t customProtocolID) +} diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp new file mode 100644 index 000000000..059f46583 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2013 Igalia S.L. + * + * 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 "CustomProtocolManagerProxy.h" + +#include "ChildProcessProxy.h" +#include "CustomProtocolManagerMessages.h" +#include "CustomProtocolManagerProxyMessages.h" +#include "WebProcessPool.h" +#include "WebSoupCustomProtocolRequestManager.h" +#include <WebCore/ResourceRequest.h> + +namespace WebKit { + +CustomProtocolManagerProxy::CustomProtocolManagerProxy(ChildProcessProxy* childProcessProxy, WebProcessPool& processPool) + : m_childProcessProxy(childProcessProxy) + , m_processPool(processPool) +{ + ASSERT(m_childProcessProxy); + m_childProcessProxy->addMessageReceiver(Messages::CustomProtocolManagerProxy::messageReceiverName(), *this); +} + +CustomProtocolManagerProxy::~CustomProtocolManagerProxy() +{ + m_childProcessProxy->removeMessageReceiver(Messages::CustomProtocolManagerProxy::messageReceiverName()); +} + +void CustomProtocolManagerProxy::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request) +{ + m_processPool.supplement<WebSoupCustomProtocolRequestManager>()->startLoading(customProtocolID, request); +} + +void CustomProtocolManagerProxy::stopLoading(uint64_t customProtocolID) +{ + m_processPool.supplement<WebSoupCustomProtocolRequestManager>()->stopLoading(customProtocolID); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp new file mode 100644 index 000000000..b655e4351 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2013 Igalia S.L. + * + * 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 "WebSoupCustomProtocolRequestManager.h" + +#include "APIData.h" +#include "CustomProtocolManagerMessages.h" +#include "WebProcessPool.h" +#include <WebCore/ResourceError.h> +#include <WebCore/ResourceRequest.h> +#include <WebCore/ResourceResponse.h> + +#if PLATFORM(GTK) +#include <WebCore/ErrorsGtk.h> +#elif PLATFORM(EFL) +#include <WebCore/ErrorsEfl.h> +#endif + +namespace WebKit { + +const char* WebSoupCustomProtocolRequestManager::supplementName() +{ + return "WebSoupCustomProtocolRequestManager"; +} + +Ref<WebSoupCustomProtocolRequestManager> WebSoupCustomProtocolRequestManager::create(WebProcessPool* processPool) +{ + return adoptRef(*new WebSoupCustomProtocolRequestManager(processPool)); +} + +WebSoupCustomProtocolRequestManager::WebSoupCustomProtocolRequestManager(WebProcessPool* processPool) + : WebContextSupplement(processPool) +{ +} + +WebSoupCustomProtocolRequestManager::~WebSoupCustomProtocolRequestManager() +{ +} + +void WebSoupCustomProtocolRequestManager::initializeClient(const WKSoupCustomProtocolRequestManagerClientBase* client) +{ + m_client.initialize(client); +} + +// WebContextSupplement +void WebSoupCustomProtocolRequestManager::processPoolDestroyed() +{ +} + +void WebSoupCustomProtocolRequestManager::processDidClose(WebProcessProxy*) +{ +} + +void WebSoupCustomProtocolRequestManager::refWebContextSupplement() +{ + API::Object::ref(); +} + +void WebSoupCustomProtocolRequestManager::derefWebContextSupplement() +{ + API::Object::deref(); +} + +void WebSoupCustomProtocolRequestManager::registerSchemeForCustomProtocol(const String& scheme) +{ + ASSERT(!scheme.isNull()); + if (m_registeredSchemes.contains(scheme)) + return; + + if (!processPool()) + return; + + processPool()->registerSchemeForCustomProtocol(scheme); + + m_registeredSchemes.append(scheme); +} + +void WebSoupCustomProtocolRequestManager::unregisterSchemeForCustomProtocol(const String& scheme) +{ + if (!processPool()) + return; + + processPool()->unregisterSchemeForCustomProtocol(scheme); + + bool removed = m_registeredSchemes.removeFirst(scheme); + ASSERT_UNUSED(removed, removed); +} + +void WebSoupCustomProtocolRequestManager::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request) +{ + if (!m_client.startLoading(this, customProtocolID, request)) + didFailWithError(customProtocolID, WebCore::cannotShowURLError(request)); +} + +void WebSoupCustomProtocolRequestManager::stopLoading(uint64_t customProtocolID) +{ + m_client.stopLoading(this, customProtocolID); +} + +void WebSoupCustomProtocolRequestManager::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response) +{ + if (!processPool()) + return; + + processPool()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidReceiveResponse(customProtocolID, response, 0), 0); +} + +void WebSoupCustomProtocolRequestManager::didLoadData(uint64_t customProtocolID, const API::Data* data) +{ + if (!processPool()) + return; + + processPool()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidLoadData(customProtocolID, data->dataReference()), 0); +} + +void WebSoupCustomProtocolRequestManager::didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError& error) +{ + if (!processPool()) + return; + + processPool()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidFailWithError(customProtocolID, error), 0); +} + +void WebSoupCustomProtocolRequestManager::didFinishLoading(uint64_t customProtocolID) +{ + if (!processPool()) + return; + + processPool()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidFinishLoading(customProtocolID), 0); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h new file mode 100644 index 000000000..e14306a38 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2013 Igalia S.L. + * + * 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 WebSoupCustomProtocolRequestManager_h +#define WebSoupCustomProtocolRequestManager_h + +#include "APIObject.h" +#include "WebContextSupplement.h" +#include "WebSoupCustomProtocolRequestManagerClient.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> + +namespace API { +class Data; +} + +namespace WebCore { +class ResourceError; +class ResourceRequest; +class ResourceResponse; +} + +namespace WebKit { + +class WebProcessPool; + +class WebSoupCustomProtocolRequestManager : public API::ObjectImpl<API::Object::Type::SoupCustomProtocolRequestManager>, public WebContextSupplement { +public: + static const char* supplementName(); + + static Ref<WebSoupCustomProtocolRequestManager> create(WebProcessPool*); + virtual ~WebSoupCustomProtocolRequestManager(); + + void initializeClient(const WKSoupCustomProtocolRequestManagerClientBase*); + + void registerSchemeForCustomProtocol(const String& scheme); + void unregisterSchemeForCustomProtocol(const String& scheme); + + void startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest&); + void stopLoading(uint64_t customProtocolID); + + void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&); + void didLoadData(uint64_t customProtocolID, const API::Data*); + void didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError&); + void didFinishLoading(uint64_t customProtocolID); + + const Vector<String>& registeredSchemesForCustomProtocols() const { return m_registeredSchemes; } + + using API::Object::ref; + using API::Object::deref; + +private: + WebSoupCustomProtocolRequestManager(WebProcessPool*); + + // WebContextSupplement + virtual void processPoolDestroyed() override; + virtual void processDidClose(WebProcessProxy*) override; + virtual void refWebContextSupplement() override; + virtual void derefWebContextSupplement() override; + + WebSoupCustomProtocolRequestManagerClient m_client; + Vector<String> m_registeredSchemes; +}; + +} // namespace WebKit + +#endif // WebSoupCustomProtocolRequestManager_h diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp new file mode 100644 index 000000000..c4def6287 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2013 Igalia S.L. + * + * 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 "WebSoupCustomProtocolRequestManagerClient.h" + +#include "WebSoupCustomProtocolRequestManager.h" + +namespace WebKit { + +bool WebSoupCustomProtocolRequestManagerClient::startLoading(WebSoupCustomProtocolRequestManager* soupRequestManager, uint64_t customProtocolID, const WebCore::ResourceRequest& request) +{ + if (!m_client.startLoading) + return false; + + Ref<API::URLRequest> urlRequest = API::URLRequest::create(request); + m_client.startLoading(toAPI(soupRequestManager), customProtocolID, toAPI(urlRequest.ptr()), m_client.base.clientInfo); + return true; +} + +void WebSoupCustomProtocolRequestManagerClient::stopLoading(WebSoupCustomProtocolRequestManager* soupRequestManager, uint64_t customProtocolID) +{ + if (m_client.stopLoading) + m_client.stopLoading(toAPI(soupRequestManager), customProtocolID, m_client.base.clientInfo); +} + +} // namespace WebKit diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h new file mode 100644 index 000000000..debb221f6 --- /dev/null +++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 Igalia S.L. + * + * 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 WebSoupCustomProtocolRequestManagerClient_h +#define WebSoupCustomProtocolRequestManagerClient_h + +#include "APIClient.h" +#include "WKAPICast.h" +#include "WKSoupCustomProtocolRequestManager.h" + +namespace API { + +template<> struct ClientTraits<WKSoupCustomProtocolRequestManagerClientBase> { + typedef std::tuple<WKSoupCustomProtocolRequestManagerClientV0> Versions; +}; +} + +namespace WebCore { +class ResourceRequest; +} + +namespace WebKit { + +class WebSoupCustomProtocolRequestManager; + +class WebSoupCustomProtocolRequestManagerClient : public API::Client<WKSoupCustomProtocolRequestManagerClientBase> { +public: + bool startLoading(WebSoupCustomProtocolRequestManager*, uint64_t customProtocolID, const WebCore::ResourceRequest&); + void stopLoading(WebSoupCustomProtocolRequestManager*, uint64_t customProtocolID); +}; + +} // namespace WebKit + +#endif // WebSoupCustomProtocolRequestManagerClient_h |
