Changeset 61579 in webkit
- Timestamp:
- Jun 21, 2010 2:36:44 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r61563 r61579 1 2010-06-21 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Anders Carlsson. 4 5 Patch for https://bugs.webkit.org/show_bug.cgi?id=40940 6 Add message passing support to the WebKit2 API. 7 8 Adds message passing for both InjectedBundle -> WebContext 9 and WebContext -> InjectedBundle. 10 11 * Shared/CoreIPCSupport/WebProcessMessageKinds.h: 12 (WebProcessMessage::): 13 * Shared/CoreIPCSupport/WebProcessProxyMessageKinds.h: Added. 14 (WebProcessProxyMessage::): 15 (CoreIPC::): 16 * UIProcess/API/C/WKContext.cpp: 17 (WKContextSetInjectedBundleClient): 18 (WKContextPostMessageToInjectedBundle): 19 * UIProcess/API/C/WKContext.h: 20 * UIProcess/WebContext.cpp: 21 (WebKit::WebContext::initializeInjectedBundleClient): 22 (WebKit::WebContext::forwardMessageToWebContext): 23 (WebKit::WebContext::postMessageToInjectedBundle): 24 * UIProcess/WebContext.h: 25 * UIProcess/WebContextInjectedBundleClient.cpp: Added. 26 (WebKit::WebContextInjectedBundleClient::WebContextInjectedBundleClient): 27 (WebKit::WebContextInjectedBundleClient::initialize): 28 (WebKit::WebContextInjectedBundleClient::didRecieveMessageFromInjectedBundle): 29 * UIProcess/WebContextInjectedBundleClient.h: Added. 30 * UIProcess/WebProcessManager.cpp: 31 (WebKit::WebProcessManager::processDidClose): 32 * UIProcess/WebProcessProxy.cpp: 33 (WebKit::WebProcessProxy::didReceiveInjectedBundleMessage): 34 (WebKit::WebProcessProxy::didReceiveMessage): 35 * UIProcess/WebProcessProxy.h: 36 * WebKit2.xcodeproj/project.pbxproj: 37 * WebProcess/InjectedBundle/API/c/WKBundle.cpp: 38 (WKBundlePostMessage): 39 * WebProcess/InjectedBundle/API/c/WKBundle.h: 40 * WebProcess/InjectedBundle/InjectedBundle.cpp: 41 (WebKit::InjectedBundle::postMessage): 42 (WebKit::InjectedBundle::didCreatePage): 43 (WebKit::InjectedBundle::didRecieveMessage): 44 * WebProcess/InjectedBundle/InjectedBundle.h: 45 * WebProcess/WebProcess.cpp: 46 (WebKit::WebProcess::loadInjectedBundle): 47 (WebKit::WebProcess::forwardMessageToInjectedBundle): 48 (WebKit::WebProcess::didReceiveMessage): 49 * WebProcess/WebProcess.h: 50 * mac/WebKit2.exp: 51 * win/WebKit2.vcproj: 52 1 53 2010-06-21 Anders Carlsson <andersca@apple.com> 2 54 -
trunk/WebKit2/Shared/CoreIPCSupport/WebProcessMessageKinds.h
r61222 r61579 35 35 enum Kind { 36 36 LoadInjectedBundle, 37 Create 37 Create, 38 PostMessage 38 39 }; 39 40 -
trunk/WebKit2/UIProcess/API/C/WKContext.cpp
r61500 r61579 68 68 } 69 69 70 void WKContextSetInjectedBundleClient(WKContextRef contextRef, WKContextInjectedBundleClient* wkClient) 71 { 72 if (wkClient && !wkClient->version) 73 toWK(contextRef)->initializeInjectedBundleClient(wkClient); 74 } 75 76 void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageRef) 77 { 78 toWK(contextRef)->postMessageToInjectedBundle(toWK(messageRef)); 79 } 80 70 81 void WKContextGetStatistics(WKContextRef contextRef, WKContextStatistics* statistics) 71 82 { -
trunk/WebKit2/UIProcess/API/C/WKContext.h
r61500 r61579 33 33 #endif 34 34 35 // Policy Client. 36 typedef void (*WKContextDidRecieveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef message, const void *clientInfo); 37 38 struct WKContextInjectedBundleClient { 39 int version; 40 const void * clientInfo; 41 WKContextDidRecieveMessageFromInjectedBundleCallback didRecieveMessageFromInjectedBundle; 42 }; 43 typedef struct WKContextInjectedBundleClient WKContextInjectedBundleClient; 44 35 45 WK_EXPORT WKContextRef WKContextCreate(); 36 46 WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path); 37 38 47 WK_EXPORT WKContextRef WKContextGetSharedProcessContext(); 39 48 40 49 WK_EXPORT void WKContextSetPreferences(WKContextRef context, WKPreferencesRef preferences); 41 50 WK_EXPORT WKPreferencesRef WKContextGetPreferences(WKContextRef context); 51 52 WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, WKContextInjectedBundleClient * client); 53 54 WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef message); 42 55 43 56 WK_EXPORT WKContextRef WKContextRetain(WKContextRef context); -
trunk/WebKit2/UIProcess/WebContext.cpp
r61500 r61579 27 27 28 28 #include "RunLoop.h" 29 #include "WebCoreTypeArgumentMarshalling.h" 29 30 #include "WebPageNamespace.h" 30 31 #include "WebPreferences.h" 31 32 #include "WebProcessManager.h" 33 #include "WebProcessMessageKinds.h" 32 34 #include "WebProcessProxy.h" 33 35 … … 80 82 webContextCounter.decrement(); 81 83 #endif 84 } 85 86 void WebContext::initializeInjectedBundleClient(WKContextInjectedBundleClient* client) 87 { 88 m_injectedBundleClient.initialize(client); 82 89 } 83 90 … … 141 148 } 142 149 150 // InjectedBundle client 151 152 void WebContext::didRecieveMessageFromInjectedBundle(const WebCore::String& message) 153 { 154 m_injectedBundleClient.didRecieveMessageFromInjectedBundle(this, message); 155 } 156 157 void WebContext::postMessageToInjectedBundle(WebCore::StringImpl* message) 158 { 159 if (!m_process || !m_process->isValid()) 160 return; 161 162 m_process->connection()->send(WebProcessMessage::PostMessage, 0, CoreIPC::In(String(message))); 163 } 164 143 165 void WebContext::getStatistics(WKContextStatistics* statistics) 144 166 { -
trunk/WebKit2/UIProcess/WebContext.h
r61500 r61579 28 28 29 29 #include "ProcessModel.h" 30 #include "WebContextInjectedBundleClient.h" 30 31 #include <WebCore/PlatformString.h> 31 32 #include <wtf/Forward.h> … … 56 57 ~WebContext(); 57 58 59 void initializeInjectedBundleClient(WKContextInjectedBundleClient*); 60 58 61 ProcessModel processModel() const { return m_processModel; } 59 62 WebProcessProxy* process() const { return m_process.get(); } … … 71 74 72 75 const WebCore::String& injectedBundlePath() const { return m_injectedBundlePath; } 76 77 // InjectedBundle client 78 void didRecieveMessageFromInjectedBundle(const WebCore::String&); 79 80 void postMessageToInjectedBundle(WebCore::StringImpl*); 73 81 74 82 void getStatistics(WKContextStatistics* statistics); … … 88 96 89 97 WebCore::String m_injectedBundlePath; 98 WebContextInjectedBundleClient m_injectedBundleClient; 90 99 }; 91 100 -
trunk/WebKit2/UIProcess/WebProcessManager.cpp
r61500 r61579 81 81 ASSERT(it->second == process); 82 82 m_processMap.remove(it); 83 return; 83 84 } 84 85 -
trunk/WebKit2/UIProcess/WebProcessProxy.cpp
r61500 r61579 32 32 #include "WebProcessManager.h" 33 33 #include "WebProcessMessageKinds.h" 34 #include "WebProcessProxyMessageKinds.h" 34 35 #include <WebCore/PlatformString.h> 35 36 … … 128 129 } 129 130 131 void WebProcessProxy::forwardMessageToWebContext(const WebCore::String& message) 132 { 133 m_context->didRecieveMessageFromInjectedBundle(message); 134 } 135 130 136 void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) 131 137 { 138 if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) { 139 switch (messageID.get<WebProcessProxyMessage::Kind>()) { 140 case WebProcessProxyMessage::PostMessage: { 141 WebCore::String message; 142 if (!arguments->decode(CoreIPC::Out(message))) 143 return; 144 145 forwardMessageToWebContext(message); 146 return; 147 } 148 } 149 } 150 132 151 uint64_t pageID = arguments->destinationID(); 133 152 if (!pageID) -
trunk/WebKit2/UIProcess/WebProcessProxy.h
r61500 r61579 77 77 void connect(); 78 78 79 void forwardMessageToWebContext(const WebCore::String&); 80 79 81 // CoreIPC::Connection::Client 80 82 void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); -
trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj
r61453 r61579 149 149 BC9E969C11457F3F00870E71 /* DrawingAreaMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9E969B11457F3F00870E71 /* DrawingAreaMessageKinds.h */; }; 150 150 BCB63478116BF10600603215 /* WebKit2.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB63477116BF10600603215 /* WebKit2.h */; settings = {ATTRIBUTES = (Public, ); }; }; 151 BCB7346E11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */; }; 151 152 BCB9E2431120DACA00A137E0 /* WebContext.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB9E2411120DACA00A137E0 /* WebContext.h */; }; 152 153 BCB9E2441120DACA00A137E0 /* WebContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB9E2421120DACA00A137E0 /* WebContext.cpp */; }; … … 176 177 BCD598AC112B7FDF00EC8C23 /* WebPreferencesStore.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD598AA112B7FDF00EC8C23 /* WebPreferencesStore.h */; }; 177 178 BCD598AD112B7FDF00EC8C23 /* WebPreferencesStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCD598AB112B7FDF00EC8C23 /* WebPreferencesStore.cpp */; }; 179 BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BCDE059911CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h */; }; 180 BCDE059C11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCDE059A11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp */; }; 178 181 BCEE966C112FAF57006BCC24 /* Attachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCEE966A112FAF57006BCC24 /* Attachment.cpp */; }; 179 182 BCEE966D112FAF57006BCC24 /* Attachment.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEE966B112FAF57006BCC24 /* Attachment.h */; }; … … 364 367 BC9E969B11457F3F00870E71 /* DrawingAreaMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingAreaMessageKinds.h; sourceTree = "<group>"; }; 365 368 BCB63477116BF10600603215 /* WebKit2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKit2.h; sourceTree = "<group>"; }; 369 BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessProxyMessageKinds.h; sourceTree = "<group>"; }; 366 370 BCB86F4B116AAACD00CE20B7 /* WebKit2.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebKit2.xcconfig; sourceTree = "<group>"; }; 367 371 BCB8D4E011AF78C1008F9103 /* WebKit2.exp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.exports; name = WebKit2.exp; path = mac/WebKit2.exp; sourceTree = "<group>"; }; … … 393 397 BCD598AA112B7FDF00EC8C23 /* WebPreferencesStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPreferencesStore.h; sourceTree = "<group>"; }; 394 398 BCD598AB112B7FDF00EC8C23 /* WebPreferencesStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPreferencesStore.cpp; sourceTree = "<group>"; }; 399 BCDE059911CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextInjectedBundleClient.h; sourceTree = "<group>"; }; 400 BCDE059A11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextInjectedBundleClient.cpp; sourceTree = "<group>"; }; 395 401 BCEE966A112FAF57006BCC24 /* Attachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Attachment.cpp; sourceTree = "<group>"; }; 396 402 BCEE966B112FAF57006BCC24 /* Attachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Attachment.h; sourceTree = "<group>"; }; … … 643 649 BCB9E2421120DACA00A137E0 /* WebContext.cpp */, 644 650 BCB9E2411120DACA00A137E0 /* WebContext.h */, 651 BCDE059A11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp */, 652 BCDE059911CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h */, 645 653 BCB9F69F1123A84B00A137E0 /* WebFramePolicyListenerProxy.cpp */, 646 654 BCB9F69E1123A84B00A137E0 /* WebFramePolicyListenerProxy.h */, … … 786 794 BC111B61112F638300337BAB /* WebPageProxyMessageKinds.h */, 787 795 BC111B62112F638300337BAB /* WebProcessMessageKinds.h */, 796 BCB7346D11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h */, 788 797 ); 789 798 path = CoreIPCSupport; … … 1002 1011 BC20528811C943A5008F3375 /* InjectedBundlePageClient.h in Headers */, 1003 1012 1A3E736111CC2659007BD539 /* WebPlatformStrategies.h in Headers */, 1013 BCDE059B11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h in Headers */, 1014 BCB7346E11CEE3FF00EC5002 /* WebProcessProxyMessageKinds.h in Headers */, 1004 1015 ); 1005 1016 runOnlyForDeploymentPostprocessing = 0; … … 1161 1172 BC20528911C943A5008F3375 /* InjectedBundlePageClient.cpp in Sources */, 1162 1173 1A3E736211CC2659007BD539 /* WebPlatformStrategies.cpp in Sources */, 1174 BCDE059C11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp in Sources */, 1163 1175 ); 1164 1176 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.cpp
r61222 r61579 26 26 #include "WKBundle.h" 27 27 28 #include "InjectedBundle.h" 29 #include "WKAPICast.h" 28 30 #include "WKBundleAPICast.h" 29 #include "InjectedBundle.h"30 31 31 32 using namespace WebKit; … … 36 37 toWK(bundleRef)->initializeClient(wkClient); 37 38 } 39 40 void WKBundlePostMessage(WKBundleRef bundleRef, WKStringRef messageRef) 41 { 42 toWK(bundleRef)->postMessage(toWK(messageRef)); 43 } -
trunk/WebKit2/WebProcess/InjectedBundle/API/c/WKBundle.h
r61222 r61579 27 27 #define WKBundle_h 28 28 29 #include <WebKit2/WKBase.h> 29 30 #include <WebKit2/WKBundleBase.h> 30 31 … … 34 35 35 36 // Client 36 typedef void (*WKBundleDidCreatePageCallback)(WKBundlePageRef page, const void *clientInfo); 37 typedef void (*WKBundleDidCreatePageCallback)(WKBundleRef bundle, WKBundlePageRef page, const void *clientInfo); 38 typedef void (*WKBundleDidRecieveMessageCallback)(WKBundleRef bundle, WKStringRef message, const void *clientInfo); 37 39 38 40 struct WKBundleClient { … … 40 42 const void * clientInfo; 41 43 WKBundleDidCreatePageCallback didCreatePage; 44 WKBundleDidRecieveMessageCallback didRecieveMessage; 42 45 }; 43 46 typedef struct WKBundleClient WKBundleClient; 44 47 45 48 WK_EXPORT void WKBundleSetClient(WKBundleRef bundle, WKBundleClient * client); 49 50 WK_EXPORT void WKBundlePostMessage(WKBundleRef bundle, WKStringRef message); 46 51 47 52 #ifdef __cplusplus -
trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
r61222 r61579 26 26 #include "InjectedBundle.h" 27 27 28 #include "WKAPICast.h" 28 29 #include "WKBundleAPICast.h" 30 #include "WebCoreTypeArgumentMarshalling.h" 31 #include "WebProcess.h" 32 #include "WebProcessProxyMessageKinds.h" 33 34 using namespace WebCore; 29 35 30 36 namespace WebKit { … … 49 55 } 50 56 57 void InjectedBundle::postMessage(StringImpl* message) 58 { 59 WebProcess::shared().connection()->send(WebProcessProxyMessage::PostMessage, 0, CoreIPC::In(String(message))); 60 } 61 51 62 void InjectedBundle::didCreatePage(WebPage* page) 52 63 { 53 64 if (m_client.didCreatePage) 54 m_client.didCreatePage(toRef(page), m_client.clientInfo); 65 m_client.didCreatePage(toRef(this), toRef(page), m_client.clientInfo); 66 } 67 68 void InjectedBundle::didRecieveMessage(const WebCore::String& message) 69 { 70 if (m_client.didRecieveMessage) 71 m_client.didRecieveMessage(toRef(this), toRef(message.impl()), m_client.clientInfo); 55 72 } 56 73 -
trunk/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h
r61222 r61579 54 54 // API 55 55 void initializeClient(WKBundleClient*); 56 void postMessage(WebCore::StringImpl*); 56 57 57 58 // Callback hooks 58 59 void didCreatePage(WebPage*); 60 void didRecieveMessage(const WebCore::String&); 59 61 60 62 private: -
trunk/WebKit2/WebProcess/WebProcess.cpp
r61516 r61579 70 70 } 71 71 72 void WebProcess::loadInjectedBundle(const WebCore::String& path)72 void WebProcess::loadInjectedBundle(const String& path) 73 73 { 74 74 ASSERT(m_pageMap.isEmpty()); … … 80 80 m_injectedBundle.clear(); 81 81 } 82 } 83 84 void WebProcess::forwardMessageToInjectedBundle(const String& message) 85 { 86 if (!m_injectedBundle) 87 return; 88 89 m_injectedBundle->didRecieveMessage(message); 82 90 } 83 91 … … 139 147 switch (messageID.get<WebProcessMessage::Kind>()) { 140 148 case WebProcessMessage::LoadInjectedBundle: { 141 WebCore::String path;149 String path; 142 150 if (!arguments->decode(CoreIPC::Out(path))) 143 151 return; … … 157 165 return; 158 166 } 167 case WebProcessMessage::PostMessage: { 168 String message; 169 if (!arguments->decode(CoreIPC::Out(message))) 170 return; 171 172 forwardMessageToInjectedBundle(message); 173 return; 174 } 159 175 } 160 176 } -
trunk/WebKit2/WebProcess/WebProcess.h
r61563 r61579 64 64 65 65 void loadInjectedBundle(const WebCore::String&); 66 void forwardMessageToInjectedBundle(const WebCore::String&); 66 67 67 68 // CoreIPC::Connection::Client -
trunk/WebKit2/mac/WebKit2.exp
r61500 r61579 2 2 _WKBundlePageGetMainFrameURL 3 3 _WKBundlePageSetClient 4 _WKBundlePostMessage 4 5 _WKBundleSetClient 5 6 _WKContextCreate … … 8 9 _WKContextGetSharedThreadContext 9 10 _WKContextGetStatistics 11 _WKContextPostMessageToInjectedBundle 10 12 _WKContextRelease 11 13 _WKContextRetain 14 _WKContextSetInjectedBundleClient 12 15 _WKFrameGetFrameLoadState 13 16 _WKFrameGetPage -
trunk/WebKit2/win/WebKit2.vcproj
r61443 r61579 525 525 <File 526 526 RelativePath="..\Shared\CoreIPCSupport\WebProcessMessageKinds.h" 527 > 528 </File> 529 <File 530 RelativePath="..\Shared\CoreIPCSupport\WebProcessProxyMessageKinds.h" 527 531 > 528 532 </File> … … 813 817 </File> 814 818 <File 819 RelativePath="..\UIProcess\WebContextInjectedBundleClient.cpp" 820 > 821 </File> 822 <File 823 RelativePath="..\UIProcess\WebContextInjectedBundleClient.h" 824 > 825 </File> 826 <File 815 827 RelativePath="..\UIProcess\WebFramePolicyListenerProxy.cpp" 816 828 > -
trunk/WebKitTools/ChangeLog
r61564 r61579 1 2010-06-21 Sam Weinig <sam@webkit.org> 2 3 Reviewed by Anders Carlsson. 4 5 Patch for https://bugs.webkit.org/show_bug.cgi?id=40940 6 Add message passing support to the WebKit2 API. 7 8 - Add some test messages. 9 10 * MiniBrowser/mac/AppDelegate.m: 11 (_didRecieveMessageFromInjectedBundle): 12 (-[BrowserAppDelegate init]): 13 * MiniBrowser/mac/WebBundle/WebBundleMain.m: 14 (_didClearWindow): 15 (_didCreatePage): 16 (_didRecieveMessage): 17 (WKBundleInitialize): 18 1 19 2010-06-21 Drew Wilson <atwilson@chromium.org> 2 20 -
trunk/WebKitTools/MiniBrowser/mac/AppDelegate.m
r61500 r61579 36 36 @implementation BrowserAppDelegate 37 37 38 void _didRecieveMessageFromInjectedBundle(WKContextRef context, WKStringRef message, const void *clientInfo) 39 { 40 CFStringRef cfMessage = WKStringCopyCFString(0, message); 41 NSLog(@"ContextInjectedBundleClient - didRecieveMessage - message: %@", cfMessage); 42 CFRelease(cfMessage); 43 44 WKStringRef newMessage = WKStringCreateWithCFString(CFSTR("Roger that!")); 45 WKContextPostMessageToInjectedBundle(context, newMessage); 46 WKStringRelease(newMessage); 47 } 48 38 49 - (id)init 39 50 { … … 53 64 54 65 WKContextRef processContext = WKContextCreateWithInjectedBundlePath(bundlePath); 66 67 WKContextInjectedBundleClient bundleClient = { 68 0, /* version */ 69 0, /* clientInfo */ 70 _didRecieveMessageFromInjectedBundle 71 }; 72 WKContextSetInjectedBundleClient(processContext, &bundleClient); 73 55 74 processPageNamespace = WKPageNamespaceCreate(processContext); 56 75 WKContextRelease(processContext); -
trunk/WebKitTools/MiniBrowser/mac/WebBundle/WebBundleMain.m
r61443 r61579 24 24 */ 25 25 26 #include <stdio.h>27 26 #include <Cocoa/Cocoa.h> 28 27 #include <WebKit2/WKBundle.h> 28 #include <WebKit2/WKBundleInitialize.h> 29 29 #include <WebKit2/WKBundlePage.h> 30 #include <WebKit2/WKBundleInitialize.h> 30 #include <WebKit2/WKString.h> 31 #include <WebKit2/WKStringCF.h> 31 32 #include <WebKit2/WKURLCF.h> 33 #include <stdio.h> 32 34 33 35 static WKBundleRef globalBundle; … … 38 40 NSLog(@"WKBundlePageClient - _didClearWindowForFrame %@", [(NSURL *)cfURL absoluteString]); 39 41 CFRelease(cfURL); 42 43 WKStringRef message = WKStringCreateWithCFString(CFSTR("Window was cleared")); 44 WKBundlePostMessage(globalBundle, message); 45 WKStringRelease(message); 40 46 } 41 47 42 void _didCreatePage(WKBundlePageRef page, const void* clientInfo)48 void _didCreatePage(WKBundlePageRef bundle, WKBundlePageRef page, const void* clientInfo) 43 49 { 44 50 NSLog(@"WKBundleClient - didCreatePage\n"); … … 52 58 } 53 59 60 void _didRecieveMessage(WKBundleRef bundle, WKStringRef message, const void *clientInfo) 61 { 62 CFStringRef cfMessage = WKStringCopyCFString(0, message); 63 NSLog(@"WKBundleClient - didRecieveMessage %@\n", cfMessage); 64 CFRelease(cfMessage); 65 } 66 54 67 void WKBundleInitialize(WKBundleRef bundle) 55 68 { … … 59 72 0, 60 73 0, 61 _didCreatePage 74 _didCreatePage, 75 _didRecieveMessage 62 76 }; 63 77 WKBundleSetClient(bundle, &client);
Note: See TracChangeset
for help on using the changeset viewer.