Diff
Modified: trunk/Source/WebKit2/ChangeLog (218318 => 218319)
--- trunk/Source/WebKit2/ChangeLog 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-15 07:02:38 UTC (rev 218319)
@@ -1,5 +1,48 @@
2017-06-14 Carlos Garcia Campos <cgar...@igalia.com>
+ Add API::InjectedBundle::Client
+ https://bugs.webkit.org/show_bug.cgi?id=173357
+
+ Reviewed by Alex Christensen.
+
+ It will be used by the GTK+ port instead of the C API.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ * WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h: Copied from Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.h.
+ (API::InjectedBundle::Client::didCreatePage):
+ (API::InjectedBundle::Client::willDestroyPage):
+ (API::InjectedBundle::Client::didInitializePageGroup):
+ (API::InjectedBundle::Client::didReceiveMessage):
+ (API::InjectedBundle::Client::didReceiveMessageToPage):
+ * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+ (WKBundleSetClient):
+ * WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:
+ (webkitWebExtensionPageCreated): Deleted.
+ (webkitWebExtensionPageDestroy): Deleted.
+ (webkitWebExtensionDidReceiveMessage): Deleted.
+ (didCreatePage): Deleted.
+ (willDestroyPage): Deleted.
+ (didReceiveMessage): Deleted.
+ (didReceiveMessageToPage): Deleted.
+ * WebProcess/InjectedBundle/InjectedBundle.cpp:
+ (WebKit::InjectedBundle::setClient):
+ (WebKit::InjectedBundle::didCreatePage):
+ (WebKit::InjectedBundle::willDestroyPage):
+ (WebKit::InjectedBundle::didInitializePageGroup):
+ (WebKit::InjectedBundle::didReceiveMessage):
+ (WebKit::InjectedBundle::didReceiveMessageToPage):
+ * WebProcess/InjectedBundle/InjectedBundle.h:
+ * WebProcess/InjectedBundle/InjectedBundleClient.cpp:
+ (WebKit::InjectedBundleClient::InjectedBundleClient):
+ (WebKit::InjectedBundleClient::didCreatePage):
+ (WebKit::InjectedBundleClient::willDestroyPage):
+ (WebKit::InjectedBundleClient::didInitializePageGroup):
+ (WebKit::InjectedBundleClient::didReceiveMessage):
+ (WebKit::InjectedBundleClient::didReceiveMessageToPage):
+ * WebProcess/InjectedBundle/InjectedBundleClient.h:
+
+2017-06-14 Carlos Garcia Campos <cgar...@igalia.com>
+
WKErrorGetErrorCode should not return the API::Error enum values directly
https://bugs.webkit.org/show_bug.cgi?id=173367
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (218318 => 218319)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2017-06-15 07:02:38 UTC (rev 218319)
@@ -1218,6 +1218,7 @@
7A821F4E1E2F67A800604577 /* LegacyCustomProtocolManagerClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7A821F4D1E2F679E00604577 /* LegacyCustomProtocolManagerClient.mm */; };
7A821F501E2F7A7500604577 /* APICustomProtocolManagerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */; };
7A8A9D581EF119B0009801AE /* APIInjectedBundleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A8A9D571EF119AA009801AE /* APIInjectedBundleClient.h */; };
+ 7A8A9D5A1EF13029009801AE /* APIInjectedBundleBundleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A8A9D591EF13020009801AE /* APIInjectedBundleBundleClient.h */; };
7AAD175F1EA6AF99003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7AAD175E1EA6AF37003B0894 /* WebResourceLoadStatisticsStoreCocoa.mm */; };
7AB6EA451EEAAE3800037B2B /* APIIconDatabaseClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB6EA441EEAAE2300037B2B /* APIIconDatabaseClient.h */; };
7AB6EA471EEAB6B800037B2B /* APIGeolocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB6EA461EEAB6B000037B2B /* APIGeolocationProvider.h */; };
@@ -3506,6 +3507,7 @@
7A821F4D1E2F679E00604577 /* LegacyCustomProtocolManagerClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyCustomProtocolManagerClient.mm; sourceTree = "<group>"; };
7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICustomProtocolManagerClient.h; sourceTree = "<group>"; };
7A8A9D571EF119AA009801AE /* APIInjectedBundleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIInjectedBundleClient.h; sourceTree = "<group>"; };
+ 7A8A9D591EF13020009801AE /* APIInjectedBundleBundleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIInjectedBundleBundleClient.h; sourceTree = "<group>"; };
7A9CD8C01C77984900D9F6C7 /* WebResourceLoadStatisticsStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadStatisticsStore.cpp; sourceTree = "<group>"; };
7A9CD8C11C77984900D9F6C7 /* WebResourceLoadStatisticsStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadStatisticsStore.h; sourceTree = "<group>"; };
7A9CD8C21C779AD600D9F6C7 /* WebResourceLoadStatisticsStore.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebResourceLoadStatisticsStore.messages.in; sourceTree = "<group>"; };
@@ -7253,6 +7255,7 @@
1F0181681858DC1500F92884 /* Cocoa */,
BC989D4516181691000D46D3 /* mac */,
377512301DF0DEE2008A351C /* APIInjectedBundleEditorClient.h */,
+ 7A8A9D591EF13020009801AE /* APIInjectedBundleBundleClient.h */,
076E884F1A13CBC6005E90FC /* APIInjectedBundlePageContextMenuClient.h */,
7A3ACE1A1EEEF78C00A864A4 /* APIInjectedBundlePageLoaderClient.h */,
);
@@ -8855,6 +8858,7 @@
51EFC1CF1524E62500C9A938 /* WKBundleDOMWindowExtension.h in Headers */,
7CBB81211AA0F970006B1942 /* WKBundleFileHandleRef.h in Headers */,
BCD25F1711D6BDE100169B0E /* WKBundleFrame.h in Headers */,
+ 7A8A9D5A1EF13029009801AE /* APIInjectedBundleBundleClient.h in Headers */,
BCF049E611FE20F600F86A58 /* WKBundleFramePrivate.h in Headers */,
BC49862F124D18C100D834E1 /* WKBundleHitTestResult.h in Headers */,
BC204EF211C83EC8008F3375 /* WKBundleInitialize.h in Headers */,
Copied: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h (from rev 218315, trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.h) (0 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h 2017-06-15 07:02:38 UTC (rev 218319)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include <wtf/Forward.h>
+
+namespace WebKit {
+class InjectedBundle;
+class WebPage;
+class WebPageGroupProxy;
+}
+
+namespace API {
+class Object;
+
+namespace InjectedBundle {
+
+class Client {
+public:
+ virtual ~Client() = default;
+
+ virtual void didCreatePage(WebKit::InjectedBundle&, WebKit::WebPage&) { }
+ virtual void willDestroyPage(WebKit::InjectedBundle&, WebKit::WebPage&) { }
+ virtual void didInitializePageGroup(WebKit::InjectedBundle&, WebKit::WebPageGroupProxy&) { }
+ virtual void didReceiveMessage(WebKit::InjectedBundle&, const WTF::String&, API::Object*) { }
+ virtual void didReceiveMessageToPage(WebKit::InjectedBundle&, WebKit::WebPage&, const WTF::String&, API::Object*) { }
+};
+
+} // namespace InjectedBundle
+
+} // namespace API
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp 2017-06-15 07:02:38 UTC (rev 218319)
@@ -29,6 +29,7 @@
#include "APIArray.h"
#include "APIData.h"
#include "InjectedBundle.h"
+#include "InjectedBundleClient.h"
#include "InjectedBundleScriptWorld.h"
#include "WKAPICast.h"
#include "WKBundleAPICast.h"
@@ -49,7 +50,7 @@
void WKBundleSetClient(WKBundleRef bundleRef, WKBundleClientBase *wkClient)
{
- toImpl(bundleRef)->initializeClient(wkClient);
+ toImpl(bundleRef)->setClient(std::make_unique<InjectedBundleClient>(wkClient));
}
void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp 2017-06-15 07:02:38 UTC (rev 218319)
@@ -22,6 +22,7 @@
#include "APIDictionary.h"
#include "APIString.h"
+#include "WKBundle.h"
#include "WKBundleAPICast.h"
#include "WKBundlePage.h"
#include "WebKitPrivate.h"
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugIn.mm 2017-06-15 07:02:38 UTC (rev 218319)
@@ -80,7 +80,7 @@
bundleClient.didCreatePage = didCreatePage;
bundleClient.willDestroyPage = willDestroyPage;
- bundle.initializeClient(&bundleClient.base);
+ WKBundleSetClient(toAPI(&bundle), &bundleClient.base);
}
- (void)_setPrincipalClassInstance:(id <WKWebProcessPlugIn>)principalClassInstance
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp 2017-06-15 07:02:38 UTC (rev 218319)
@@ -32,8 +32,6 @@
#include "NotificationPermissionRequestManager.h"
#include "SessionTracker.h"
#include "UserData.h"
-#include "WKAPICast.h"
-#include "WKBundleAPICast.h"
#include "WebConnectionToUIProcess.h"
#include "WebCookieManager.h"
#include "WebCoreArgumentCoders.h"
@@ -102,6 +100,7 @@
InjectedBundle::InjectedBundle(const WebProcessCreationParameters& parameters)
: m_path(parameters.injectedBundlePath)
, m_platformBundle(0)
+ , m_client(std::make_unique<API::InjectedBundle::Client>())
{
}
@@ -109,9 +108,12 @@
{
}
-void InjectedBundle::initializeClient(const WKBundleClientBase* client)
+void InjectedBundle::setClient(std::unique_ptr<API::InjectedBundle::Client>&& client)
{
- m_client.initialize(client);
+ if (!client)
+ m_client = std::make_unique<API::InjectedBundle::Client>();
+ else
+ m_client = WTFMove(client);
}
void InjectedBundle::postMessage(const String& messageName, API::Object* messageBody)
@@ -507,27 +509,27 @@
void InjectedBundle::didCreatePage(WebPage* page)
{
- m_client.didCreatePage(this, page);
+ m_client->didCreatePage(*this, *page);
}
void InjectedBundle::willDestroyPage(WebPage* page)
{
- m_client.willDestroyPage(this, page);
+ m_client->willDestroyPage(*this, *page);
}
void InjectedBundle::didInitializePageGroup(WebPageGroupProxy* pageGroup)
{
- m_client.didInitializePageGroup(this, pageGroup);
+ m_client->didInitializePageGroup(*this, *pageGroup);
}
void InjectedBundle::didReceiveMessage(const String& messageName, API::Object* messageBody)
{
- m_client.didReceiveMessage(this, messageName, messageBody);
+ m_client->didReceiveMessage(*this, messageName, messageBody);
}
void InjectedBundle::didReceiveMessageToPage(WebPage* page, const String& messageName, API::Object* messageBody)
{
- m_client.didReceiveMessageToPage(this, page, messageName, messageBody);
+ m_client->didReceiveMessageToPage(*this, *page, messageName, messageBody);
}
void InjectedBundle::setUserStyleSheetLocation(WebPageGroupProxy* pageGroup, const String& location)
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h 2017-06-15 07:02:38 UTC (rev 218319)
@@ -25,10 +25,10 @@
#pragma once
+#include "APIInjectedBundleBundleClient.h"
#include "APIObject.h"
-#include "InjectedBundleClient.h"
#include "SandboxExtension.h"
-#include "WKBundle.h"
+#include <_javascript_Core/_javascript_.h>
#include <WebCore/UserContentTypes.h>
#include <WebCore/UserScriptTypes.h>
#include <wtf/RefPtr.h>
@@ -84,7 +84,7 @@
void setBundleParameters(const IPC::DataReference&);
// API
- void initializeClient(const WKBundleClientBase*);
+ void setClient(std::unique_ptr<API::InjectedBundle::Client>&&);
void postMessage(const String&, API::Object*);
void postSynchronousMessage(const String&, API::Object*, RefPtr<API::Object>& returnData);
@@ -161,7 +161,7 @@
RefPtr<SandboxExtension> m_sandboxExtension;
- InjectedBundleClient m_client;
+ std::unique_ptr<API::InjectedBundle::Client> m_client;
#if PLATFORM(COCOA) && WK_API_ENABLED
RetainPtr<WKWebProcessBundleParameters> m_bundleParameters;
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.cpp 2017-06-15 07:02:38 UTC (rev 218319)
@@ -33,44 +33,49 @@
namespace WebKit {
-void InjectedBundleClient::didCreatePage(InjectedBundle* bundle, WebPage* page)
+InjectedBundleClient::InjectedBundleClient(const WKBundleClientBase* client)
{
+ initialize(client);
+}
+
+void InjectedBundleClient::didCreatePage(InjectedBundle& bundle, WebPage& page)
+{
if (!m_client.didCreatePage)
return;
- m_client.didCreatePage(toAPI(bundle), toAPI(page), m_client.base.clientInfo);
+ m_client.didCreatePage(toAPI(&bundle), toAPI(&page), m_client.base.clientInfo);
}
-void InjectedBundleClient::willDestroyPage(InjectedBundle* bundle, WebPage* page)
+void InjectedBundleClient::willDestroyPage(InjectedBundle& bundle, WebPage& page)
{
if (!m_client.willDestroyPage)
return;
- m_client.willDestroyPage(toAPI(bundle), toAPI(page), m_client.base.clientInfo);
+ m_client.willDestroyPage(toAPI(&bundle), toAPI(&page), m_client.base.clientInfo);
}
-void InjectedBundleClient::didInitializePageGroup(InjectedBundle* bundle, WebPageGroupProxy* pageGroup)
+void InjectedBundleClient::didInitializePageGroup(InjectedBundle& bundle, WebPageGroupProxy& pageGroup)
{
if (!m_client.didInitializePageGroup)
return;
- m_client.didInitializePageGroup(toAPI(bundle), toAPI(pageGroup), m_client.base.clientInfo);
+ m_client.didInitializePageGroup(toAPI(&bundle), toAPI(&pageGroup), m_client.base.clientInfo);
}
-void InjectedBundleClient::didReceiveMessage(InjectedBundle* bundle, const String& messageName, API::Object* messageBody)
+void InjectedBundleClient::didReceiveMessage(InjectedBundle& bundle, const String& messageName, API::Object* messageBody)
{
if (!m_client.didReceiveMessage)
return;
- m_client.didReceiveMessage(toAPI(bundle), toAPI(messageName.impl()), toAPI(messageBody), m_client.base.clientInfo);
+ m_client.didReceiveMessage(toAPI(&bundle), toAPI(messageName.impl()), toAPI(messageBody), m_client.base.clientInfo);
}
-void InjectedBundleClient::didReceiveMessageToPage(InjectedBundle* bundle, WebPage* page, const String& messageName, API::Object* messageBody)
+void InjectedBundleClient::didReceiveMessageToPage(InjectedBundle& bundle, WebPage& page, const String& messageName, API::Object* messageBody)
{
if (!m_client.didReceiveMessageToPage)
return;
- m_client.didReceiveMessageToPage(toAPI(bundle), toAPI(page), toAPI(messageName.impl()), toAPI(messageBody), m_client.base.clientInfo);
+ m_client.didReceiveMessageToPage(toAPI(&bundle), toAPI(&page), toAPI(messageName.impl()), toAPI(messageBody), m_client.base.clientInfo);
}
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.h (218318 => 218319)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.h 2017-06-15 06:58:02 UTC (rev 218318)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleClient.h 2017-06-15 07:02:38 UTC (rev 218319)
@@ -27,6 +27,7 @@
#define InjectedBundleClient_h
#include "APIClient.h"
+#include "APIInjectedBundleBundleClient.h"
#include "WKBundle.h"
#include <wtf/Forward.h>
@@ -44,16 +45,17 @@
class WebPage;
class WebPageGroupProxy;
-class InjectedBundleClient : public API::Client<WKBundleClientBase> {
+class InjectedBundleClient : public API::InjectedBundle::Client, public API::Client<WKBundleClientBase> {
public:
- void didCreatePage(InjectedBundle*, WebPage*);
- void willDestroyPage(InjectedBundle*, WebPage*);
- void didInitializePageGroup(InjectedBundle*, WebPageGroupProxy*);
- void didReceiveMessage(InjectedBundle*, const String& messageName, API::Object* messageBody);
- void didReceiveMessageToPage(InjectedBundle*, WebPage*, const String& messageName, API::Object* messageBody);
+ explicit InjectedBundleClient(const WKBundleClientBase*);
+
+ void didCreatePage(InjectedBundle&, WebPage&) override;
+ void willDestroyPage(InjectedBundle&, WebPage&) override;
+ void didInitializePageGroup(InjectedBundle&, WebPageGroupProxy&) override;
+ void didReceiveMessage(InjectedBundle&, const WTF::String&, API::Object*) override;
+ void didReceiveMessageToPage(InjectedBundle&, WebPage&, const WTF::String&, API::Object*) override;
};
} // namespace WebKit
-
#endif // InjectedBundleClient_h