summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Shared/mac
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/Shared/mac')
-rw-r--r--Source/WebKit2/Shared/mac/PlatformCertificateInfo.h1
-rw-r--r--Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm41
-rw-r--r--Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm106
-rw-r--r--Source/WebKit2/Shared/mac/WebEventFactory.mm15
4 files changed, 128 insertions, 35 deletions
diff --git a/Source/WebKit2/Shared/mac/PlatformCertificateInfo.h b/Source/WebKit2/Shared/mac/PlatformCertificateInfo.h
index be7eb36..7ef5b37 100644
--- a/Source/WebKit2/Shared/mac/PlatformCertificateInfo.h
+++ b/Source/WebKit2/Shared/mac/PlatformCertificateInfo.h
@@ -40,6 +40,7 @@ class PlatformCertificateInfo {
public:
PlatformCertificateInfo();
explicit PlatformCertificateInfo(const WebCore::ResourceResponse&);
+ explicit PlatformCertificateInfo(CFArrayRef certificateChain);
CFArrayRef certificateChain() const { return m_certificateChain.get(); }
diff --git a/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm b/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
index 0c0b737..5ae772c 100644
--- a/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
+++ b/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
@@ -26,10 +26,10 @@
#import "config.h"
#import "PlatformCertificateInfo.h"
+#import "ArgumentCodersCF.h"
#import "ArgumentDecoder.h"
#import "ArgumentEncoder.h"
#import <WebKitSystemInterface.h>
-#import <Security/Security.h>
using namespace WebCore;
@@ -44,47 +44,34 @@ PlatformCertificateInfo::PlatformCertificateInfo(const ResourceResponse& respons
{
}
+PlatformCertificateInfo::PlatformCertificateInfo(CFArrayRef certificateChain)
+ : m_certificateChain(certificateChain)
+{
+}
+
void PlatformCertificateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const
{
- // Special case no certificates,
if (!m_certificateChain) {
- encoder->encodeUInt64(std::numeric_limits<uint64_t>::max());
+ encoder->encodeBool(false);
return;
}
- uint64_t length = CFArrayGetCount(m_certificateChain.get());
- encoder->encodeUInt64(length);
-
- for (size_t i = 0; i < length; ++i) {
- RetainPtr<CFDataRef> data(AdoptCF, SecCertificateCopyData((SecCertificateRef)CFArrayGetValueAtIndex(m_certificateChain.get(), i)));
- encoder->encodeBytes(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get()));
- }
+ encoder->encodeBool(true);
+ CoreIPC::encode(encoder, m_certificateChain.get());
}
bool PlatformCertificateInfo::decode(CoreIPC::ArgumentDecoder* decoder, PlatformCertificateInfo& c)
{
- uint64_t length;
- if (!decoder->decode(length))
+ bool hasCertificateChain;
+ if (!decoder->decode(hasCertificateChain))
return false;
- if (length == std::numeric_limits<uint64_t>::max()) {
- // This is the no certificates case.
+ if (!hasCertificateChain)
return true;
- }
-
- RetainPtr<CFMutableArrayRef> array(AdoptCF, CFArrayCreateMutable(0, length, &kCFTypeArrayCallBacks));
-
- for (size_t i = 0; i < length; ++i) {
- Vector<uint8_t> bytes;
- if (!decoder->decodeBytes(bytes))
- return false;
- RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(0, bytes.data(), bytes.size(), kCFAllocatorNull));
- RetainPtr<SecCertificateRef> certificate(AdoptCF, SecCertificateCreateWithData(0, data.get()));
- CFArrayAppendValue(array.get(), certificate.get());
- }
+ if (!CoreIPC::decode(decoder, c.m_certificateChain))
+ return false;
- c.m_certificateChain = array;
return true;
}
diff --git a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm b/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
index a12e566..321cb40 100644
--- a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
+++ b/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
@@ -27,11 +27,15 @@
#import "WebCoreArgumentCoders.h"
#import "ArgumentCodersCF.h"
+#import "PlatformCertificateInfo.h"
#import "WebKitSystemInterface.h"
+using namespace WebCore;
+using namespace WebKit;
+
namespace CoreIPC {
-void encodeResourceRequest(ArgumentEncoder* encoder, const WebCore::ResourceRequest& resourceRequest)
+void encodeResourceRequest(ArgumentEncoder* encoder, const ResourceRequest& resourceRequest)
{
bool requestIsPresent = resourceRequest.nsURLRequest();
encoder->encode(requestIsPresent);
@@ -43,14 +47,14 @@ void encodeResourceRequest(ArgumentEncoder* encoder, const WebCore::ResourceRequ
encode(encoder, dictionary.get());
}
-bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& resourceRequest)
+bool decodeResourceRequest(ArgumentDecoder* decoder, ResourceRequest& resourceRequest)
{
bool requestIsPresent;
if (!decoder->decode(requestIsPresent))
return false;
if (!requestIsPresent) {
- resourceRequest = WebCore::ResourceRequest();
+ resourceRequest = ResourceRequest();
return true;
}
@@ -62,11 +66,11 @@ bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& r
if (!nsURLRequest)
return false;
- resourceRequest = WebCore::ResourceRequest(nsURLRequest);
+ resourceRequest = ResourceRequest(nsURLRequest);
return true;
}
-void encodeResourceResponse(ArgumentEncoder* encoder, const WebCore::ResourceResponse& resourceResponse)
+void encodeResourceResponse(ArgumentEncoder* encoder, const ResourceResponse& resourceResponse)
{
bool responseIsPresent = resourceResponse.nsURLResponse();
encoder->encode(responseIsPresent);
@@ -78,14 +82,14 @@ void encodeResourceResponse(ArgumentEncoder* encoder, const WebCore::ResourceRes
encode(encoder, dictionary.get());
}
-bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse& resourceResponse)
+bool decodeResourceResponse(ArgumentDecoder* decoder, ResourceResponse& resourceResponse)
{
bool responseIsPresent;
if (!decoder->decode(responseIsPresent))
return false;
if (!responseIsPresent) {
- resourceResponse = WebCore::ResourceResponse();
+ resourceResponse = ResourceResponse();
return true;
}
@@ -97,7 +101,93 @@ bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse&
if (!nsURLResponse)
return false;
- resourceResponse = WebCore::ResourceResponse(nsURLResponse);
+ resourceResponse = ResourceResponse(nsURLResponse);
+ return true;
+}
+
+static NSString* nsString(const String& string)
+{
+ return string.impl() ? [NSString stringWithCharacters:reinterpret_cast<const UniChar*>(string.characters()) length:string.length()] : @"";
+}
+
+void encodeResourceError(ArgumentEncoder* encoder, const ResourceError& resourceError)
+{
+ bool errorIsNull = resourceError.isNull();
+ encoder->encode(errorIsNull);
+
+ if (errorIsNull)
+ return;
+
+ NSError *nsError = resourceError.nsError();
+
+ String domain = [nsError domain];
+ encoder->encode(domain);
+
+ int64_t code = [nsError code];
+ encoder->encode(code);
+
+ HashMap<String, String> stringUserInfoMap;
+
+ NSDictionary* userInfo = [nsError userInfo];
+ for (NSString *key in userInfo) {
+ id value = [userInfo objectForKey:key];
+ if (![value isKindOfClass:[NSString class]])
+ continue;
+
+ stringUserInfoMap.set(key, (NSString *)value);
+ continue;
+ }
+ encoder->encode(stringUserInfoMap);
+
+ id peerCertificateChain = [userInfo objectForKey:@"NSErrorPeerCertificateChainKey"];
+ ASSERT(!peerCertificateChain || [peerCertificateChain isKindOfClass:[NSArray class]]);
+ encoder->encode(PlatformCertificateInfo((CFArrayRef)peerCertificateChain));
+}
+
+bool decodeResourceError(ArgumentDecoder* decoder, ResourceError& resourceError)
+{
+ bool errorIsNull;
+ if (!decoder->decode(errorIsNull))
+ return false;
+
+ if (errorIsNull) {
+ resourceError = ResourceError();
+ return true;
+ }
+
+ String domain;
+ if (!decoder->decode(domain))
+ return false;
+
+ int64_t code;
+ if (!decoder->decode(code))
+ return false;
+
+ HashMap<String, String> stringUserInfoMap;
+ if (!decoder->decode(stringUserInfoMap))
+ return false;
+
+ PlatformCertificateInfo certificate;
+ if (!decoder->decode(certificate))
+ return false;
+
+ NSUInteger userInfoSize = stringUserInfoMap.size();
+ if (certificate.certificateChain())
+ userInfoSize++;
+
+ NSMutableDictionary* userInfo = [NSMutableDictionary dictionaryWithCapacity:userInfoSize];
+
+ HashMap<String, String>::const_iterator it = stringUserInfoMap.begin();
+ HashMap<String, String>::const_iterator end = stringUserInfoMap.end();
+ for (; it != end; ++it)
+ [userInfo setObject:nsString(it->second) forKey:nsString(it->first)];
+
+ if (certificate.certificateChain())
+ [userInfo setObject:(NSArray *)certificate.certificateChain() forKey:@"NSErrorPeerCertificateChainKey"];
+
+ NSError *nsError = [[NSError alloc] initWithDomain:nsString(domain) code:code userInfo:userInfo];
+
+ resourceError = ResourceError(nsError);
return true;
}
diff --git a/Source/WebKit2/Shared/mac/WebEventFactory.mm b/Source/WebKit2/Shared/mac/WebEventFactory.mm
index 8f02f6b..67ab1ba 100644
--- a/Source/WebKit2/Shared/mac/WebEventFactory.mm
+++ b/Source/WebKit2/Shared/mac/WebEventFactory.mm
@@ -34,6 +34,18 @@ using namespace WebCore;
namespace WebKit {
+static WebMouseEvent::Button currentMouseButton()
+{
+ NSUInteger pressedMouseButtons = [NSEvent pressedMouseButtons];
+ if (!pressedMouseButtons)
+ return WebMouseEvent::NoButton;
+ if (pressedMouseButtons == 1 << 0)
+ return WebMouseEvent::LeftButton;
+ if (pressedMouseButtons == 1 << 1)
+ return WebMouseEvent::RightButton;
+ return WebMouseEvent::MiddleButton;
+}
+
static WebMouseEvent::Button mouseButtonForEvent(NSEvent *event)
{
switch ([event type]) {
@@ -49,6 +61,9 @@ static WebMouseEvent::Button mouseButtonForEvent(NSEvent *event)
case NSOtherMouseUp:
case NSOtherMouseDragged:
return WebMouseEvent::MiddleButton;
+ case NSMouseEntered:
+ case NSMouseExited:
+ return currentMouseButton();
default:
return WebMouseEvent::NoButton;
}