[WK2] Create a context client
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2012 02:11:13 +0000 (02:11 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Dec 2012 02:11:13 +0000 (02:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105316
<rdar://problem/12901762>

Reviewed by Brady Eidson.

Web contexts already have clients related to downloads or history.
Miscellaneous callbacks can be grouped into a generic client for the
web context.

* UIProcess/API/C/WKContext.cpp:
(WKContextSetClient): Set the client for the context.
* UIProcess/API/C/WKContext.h: Define a new, empty WKContextClient.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::initializeClient):
* UIProcess/WebContext.h: Add a variable for the new client. Move the
download client so that all the clients are grouped together.
(WebKit::WebContext::client): Returns the context client.
* UIProcess/WebContextClient.cpp: Added. Currently empty, but will be
filled out in a pending patch.
* UIProcess/WebContextClient.h: Added.

Add WebContextClient.{h,cpp}.
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:

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

12 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.list.am
Source/WebKit2/Target.pri
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContext.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebContextClient.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebContextClient.h [new file with mode: 0644]
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/win/WebKit2.vcproj

index 1911bbd..95f9acb 100644 (file)
@@ -254,6 +254,7 @@ set(WebKit2_SOURCES
     UIProcess/WebColorPickerResultListenerProxy.cpp
     UIProcess/WebConnectionToWebProcess.cpp
     UIProcess/WebContext.cpp
+    UIProcess/WebContextClient.cpp
     UIProcess/WebContextConnectionClient.cpp
     UIProcess/WebContextInjectedBundleClient.cpp
     UIProcess/WebContextMenuProxy.cpp
index 9ce567e..0fcb7fb 100644 (file)
@@ -1,3 +1,35 @@
+2012-12-18  Jon Lee  <jonlee@apple.com>
+
+        [WK2] Create a context client
+        https://bugs.webkit.org/show_bug.cgi?id=105316
+        <rdar://problem/12901762>
+
+        Reviewed by Brady Eidson.
+
+        Web contexts already have clients related to downloads or history.
+        Miscellaneous callbacks can be grouped into a generic client for the
+        web context.
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetClient): Set the client for the context.
+        * UIProcess/API/C/WKContext.h: Define a new, empty WKContextClient.
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::initializeClient):
+        * UIProcess/WebContext.h: Add a variable for the new client. Move the
+        download client so that all the clients are grouped together.
+        (WebKit::WebContext::client): Returns the context client.
+        * UIProcess/WebContextClient.cpp: Added. Currently empty, but will be
+        filled out in a pending patch.
+        * UIProcess/WebContextClient.h: Added.
+
+        Add WebContextClient.{h,cpp}.
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * win/WebKit2.vcproj:
+
 2012-12-18  Ivan Krstić  <ike@apple.com>
 
         <rdar://problem/12720539> per-pid private temporary directories for sandboxed webkit2 plugins
index dc9766d..1734bc8 100644 (file)
@@ -858,6 +858,8 @@ webkit2_sources += \
        Source/WebKit2/UIProcess/WebConnectionToWebProcess.h \
        Source/WebKit2/UIProcess/WebContext.cpp \
        Source/WebKit2/UIProcess/WebContext.h \
+       Source/WebKit2/UIProcess/WebContextClient.cpp \
+       Source/WebKit2/UIProcess/WebContextClient.h \
        Source/WebKit2/UIProcess/WebContextConnectionClient.cpp \
        Source/WebKit2/UIProcess/WebContextConnectionClient.h \
        Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp \
index 0c06700..bcc219a 100644 (file)
@@ -245,6 +245,7 @@ HEADERS += \
     UIProcess/WebColorPickerResultListenerProxy.h \
     UIProcess/WebConnectionToWebProcess.h \
     UIProcess/WebContext.h \
+    UIProcess/WebContextClient.h \
     UIProcess/WebContextConnectionClient.h \
     UIProcess/WebContextInjectedBundleClient.h \
     UIProcess/WebContextMenuProxy.h \
@@ -607,6 +608,7 @@ SOURCES += \
     UIProcess/WebColorPickerResultListenerProxy.cpp \
     UIProcess/WebConnectionToWebProcess.cpp \
     UIProcess/WebContext.cpp \
+    UIProcess/WebContextClient.cpp \
     UIProcess/WebContextConnectionClient.cpp \
     UIProcess/WebContextInjectedBundleClient.cpp \
     UIProcess/WebContextMenuProxy.cpp \
index 4b55408..51082dc 100644 (file)
@@ -62,6 +62,11 @@ WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef)
     return toAPI(context.release().leakRef());
 }
 
+void WKContextSetClient(WKContextRef contextRef, const WKContextClient* wkClient)
+{
+    toImpl(contextRef)->initializeClient(wkClient);
+}
+
 void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient)
 {
     toImpl(contextRef)->initializeInjectedBundleClient(wkClient);
index edde51f..61736fa 100644 (file)
@@ -39,6 +39,15 @@ enum {
 };
 typedef uint32_t WKCacheModel;
 
+// Context Client
+struct WKContextClient {
+    int                                                                 version;
+    const void *                                                        clientInfo;
+};
+typedef struct WKContextClient WKContextClient;
+
+enum { kWKContextClientCurrentVersion = 0 };
+
 // Injected Bundle Client
 typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
 typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo);
@@ -134,6 +143,7 @@ WK_EXPORT WKTypeID WKContextGetTypeID();
 WK_EXPORT WKContextRef WKContextCreate();
 WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path);
 
+WK_EXPORT void WKContextSetClient(WKContextRef context, const WKContextClient* client);
 WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client);
 WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client);
 WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClient* client);
index ee885a2..6fcf9ac 100644 (file)
@@ -260,6 +260,11 @@ WebContext::~WebContext()
 #endif
 }
 
+void WebContext::initializeClient(const WKContextClient* client)
+{
+    m_client.initialize(client);
+}
+
 void WebContext::initializeInjectedBundleClient(const WKContextInjectedBundleClient* client)
 {
     m_injectedBundleClient.initialize(client);
index 04a11b1..a94bce6 100644 (file)
@@ -35,6 +35,7 @@
 #include "PluginInfoStore.h"
 #include "ProcessModel.h"
 #include "VisitedLinkProvider.h"
+#include "WebContextClient.h"
 #include "WebContextConnectionClient.h"
 #include "WebContextInjectedBundleClient.h"
 #include "WebDownloadClient.h"
@@ -102,6 +103,7 @@ public:
     bool dispatchMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
     bool dispatchSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
 
+    void initializeClient(const WKContextClient*);
     void initializeInjectedBundleClient(const WKContextInjectedBundleClient*);
     void initializeConnectionClient(const WKContextConnectionClient*);
     void initializeHistoryClient(const WKContextHistoryClient*);
@@ -186,6 +188,7 @@ public:
     WebDownloadClient& downloadClient() { return m_downloadClient; }
 
     WebHistoryClient& historyClient() { return m_historyClient; }
+    WebContextClient& client() { return m_client; }
 
     static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
 
@@ -367,8 +370,9 @@ private:
     String m_injectedBundlePath;
     WebContextInjectedBundleClient m_injectedBundleClient;
 
+    WebContextClient m_client;
     WebContextConnectionClient m_connectionClient;
-
+    WebDownloadClient m_downloadClient;
     WebHistoryClient m_historyClient;
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
@@ -398,8 +402,6 @@ private:
 
     CacheModel m_cacheModel;
 
-    WebDownloadClient m_downloadClient;
-    
     bool m_memorySamplerEnabled;
     double m_memorySamplerInterval;
 
diff --git a/Source/WebKit2/UIProcess/WebContextClient.cpp b/Source/WebKit2/UIProcess/WebContextClient.cpp
new file mode 100644 (file)
index 0000000..d9ed7bb
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "WebContextClient.h"
+
+namespace WebKit {
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebContextClient.h b/Source/WebKit2/UIProcess/WebContextClient.h
new file mode 100644 (file)
index 0000000..c3e0e4f
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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 WebContextClient_h
+#define WebContextClient_h
+
+#include "APIClient.h"
+#include "WKContext.h"
+
+namespace WebKit {
+
+class WebContextClient : public APIClient<WKContextClient, kWKContextClientCurrentVersion> {
+};
+
+} // namespace WebKit
+
+#endif // WebContextClient_h
index 16d6af5..00381e4 100644 (file)
                31A2EC5614899C0900810D71 /* NotificationPermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A2EC531489982500810D71 /* NotificationPermissionRequest.h */; };
                31A2EC74148D59CA00810D71 /* WKNotificationPermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A2EC72148D59BB00810D71 /* WKNotificationPermissionRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
                31A2EC77148D662E00810D71 /* WKNotificationPermissionRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A2EC75148D65BB00810D71 /* WKNotificationPermissionRequest.cpp */; };
+               31A505F91680025500A930EB /* WebContextClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A505F71680025500A930EB /* WebContextClient.cpp */; };
+               31A505FA1680025500A930EB /* WebContextClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A505F81680025500A930EB /* WebContextClient.h */; };
                31A67E0C165B2A99006CBA66 /* PlugInAutoStartProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A67E0A165B2A99006CBA66 /* PlugInAutoStartProvider.cpp */; };
                31A67E0D165B2A99006CBA66 /* PlugInAutoStartProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A67E0B165B2A99006CBA66 /* PlugInAutoStartProvider.h */; };
                31BA924D148831260062EDB5 /* WebNotificationManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31BA9248148830810062EDB5 /* WebNotificationManagerMessageReceiver.cpp */; };
                31A2EC541489982E00810D71 /* NotificationPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NotificationPermissionRequest.cpp; sourceTree = "<group>"; };
                31A2EC72148D59BB00810D71 /* WKNotificationPermissionRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKNotificationPermissionRequest.h; sourceTree = "<group>"; };
                31A2EC75148D65BB00810D71 /* WKNotificationPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKNotificationPermissionRequest.cpp; sourceTree = "<group>"; };
+               31A505F71680025500A930EB /* WebContextClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextClient.cpp; sourceTree = "<group>"; };
+               31A505F81680025500A930EB /* WebContextClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextClient.h; sourceTree = "<group>"; };
                31A67E0A165B2A99006CBA66 /* PlugInAutoStartProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlugInAutoStartProvider.cpp; sourceTree = "<group>"; };
                31A67E0B165B2A99006CBA66 /* PlugInAutoStartProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInAutoStartProvider.h; sourceTree = "<group>"; };
                31BA9248148830810062EDB5 /* WebNotificationManagerMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebNotificationManagerMessageReceiver.cpp; sourceTree = "<group>"; };
                                BCB9E2421120DACA00A137E0 /* WebContext.cpp */,
                                BCB9E2411120DACA00A137E0 /* WebContext.h */,
                                BCEE7D0912846AED009827DA /* WebContext.messages.in */,
+                               31A505F71680025500A930EB /* WebContextClient.cpp */,
+                               31A505F81680025500A930EB /* WebContextClient.h */,
                                BC09B8F6147460F7005F5625 /* WebContextConnectionClient.cpp */,
                                BC09B8F7147460F7005F5625 /* WebContextConnectionClient.h */,
                                BCDE059A11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp */,
                                31D5929F166E060000E6BF02 /* WebPlugInClient.h in Headers */,
                                1AD25E96167AB08100EA9BCD /* DownloadProxyMap.h in Headers */,
                                2989A414167D184B004F96D2 /* CustomProtocolManager.h in Headers */,
+                               31A505FA1680025500A930EB /* WebContextClient.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1AD25E95167AB08100EA9BCD /* DownloadProxyMap.cpp in Sources */,
                                BCF18638167D071E00A1A85A /* CacheModel.cpp in Sources */,
                                2989A411167D1834004F96D2 /* CustomProtocolManagerMac.mm in Sources */,
+                               31A505F91680025500A930EB /* WebContextClient.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 4d1f97e..dd676ca 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\UIProcess\WebContextClient.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\UIProcess\WebContextClient.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\UIProcess\WebContextConnectionClient.cpp"
                                >
                        </File>