Commit a927c7cb authored by andersca@apple.com's avatar andersca@apple.com

Add WKRemoteObjectRegistry to WKConnection

https://bugs.webkit.org/show_bug.cgi?id=124054

Reviewed by Sam Weinig.

* UIProcess/API/mac/WKConnection.h:
* UIProcess/API/mac/WKConnection.mm:
(-[WKConnection delegate]):
(-[WKConnection setDelegate:]):
(-[WKConnection remoteObjectRegistry]):
(didReceiveMessage):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8eb44c70
2013-11-08 Anders Carlsson <andersca@apple.com>
Add WKRemoteObjectRegistry to WKConnection
https://bugs.webkit.org/show_bug.cgi?id=124054
Reviewed by Sam Weinig.
* UIProcess/API/mac/WKConnection.h:
* UIProcess/API/mac/WKConnection.mm:
(-[WKConnection delegate]):
(-[WKConnection setDelegate:]):
(-[WKConnection remoteObjectRegistry]):
(didReceiveMessage):
2013-11-08 Anders Carlsson <andersca@apple.com>
Encode and decode NSURLRequests using NSCoder
......
......@@ -26,7 +26,9 @@
#import <Foundation/Foundation.h>
#import <WebKit2/WKDeclarationSpecifiers.h>
@class WKConnection, WKConnectionData;
@class WKConnection;
@class WKConnectionData;
@class WKRemoteObjectRegistry;
@protocol WKConnectionDelegate <NSObject>
......@@ -43,8 +45,8 @@ WK_EXPORT
- (void)sendMessageWithName:(NSString *)messageName body:(id)messageBody;
#pragma mark Delegates
@property(assign) id <WKConnectionDelegate> delegate;
@property(assign) id<WKConnectionDelegate> delegate;
@property (nonatomic, readonly) WKRemoteObjectRegistry *remoteObjectRegistry;
@end
......@@ -33,6 +33,7 @@
#import "WKRetainPtr.h"
#import "WKString.h"
#import "WKStringCF.h"
#import "WKRemoteObjectRegistryInternal.h"
#import <wtf/RetainPtr.h>
using namespace WebKit;
......@@ -44,6 +45,8 @@ using namespace WebKit;
// Delegate for callbacks.
id<WKConnectionDelegate> _delegate;
RetainPtr<WKRemoteObjectRegistry> _remoteObjectRegistry;
}
@end
......@@ -68,18 +71,24 @@ using namespace WebKit;
WKConnectionPostMessage(_data->_connectionRef.get(), wkMessageName.get(), (WKTypeRef)wkMessageBody.get());
}
#pragma mark Delegates
- (id<WKConnectionDelegate>)delegate
- (id <WKConnectionDelegate>)delegate
{
return _data->_delegate;
}
- (void)setDelegate:(id<WKConnectionDelegate>)delegate
- (void)setDelegate:(id <WKConnectionDelegate>)delegate
{
_data->_delegate = delegate;
}
- (WKRemoteObjectRegistry *)remoteObjectRegistry
{
if (!_data->_remoteObjectRegistry)
_data->_remoteObjectRegistry = adoptNS([[WKRemoteObjectRegistry alloc] _initWithConnectionRef:_data->_connectionRef.get()]);
return _data->_remoteObjectRegistry.get();
}
@end
@implementation WKConnection (Internal)
......@@ -87,6 +96,9 @@ using namespace WebKit;
static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
{
WKConnection *connection = (WKConnection *)clientInfo;
if ([connection->_data->_remoteObjectRegistry _handleMessageWithName:messageName body:messageBody])
return;
if ([connection.delegate respondsToSelector:@selector(connection:didReceiveMessageWithName:body:)]) {
RetainPtr<CFStringRef> nsMessageName = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, messageName));
RetainPtr<id> nsMessageBody = ((ObjCObjectGraph*)messageBody)->rootObject();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment