diff options
Diffstat (limited to 'Source/WebKit2/Shared')
70 files changed, 996 insertions, 232 deletions
diff --git a/Source/WebKit2/Shared/API/c/WKBase.h b/Source/WebKit2/Shared/API/c/WKBase.h index 900cd51..1baa872 100644 --- a/Source/WebKit2/Shared/API/c/WKBase.h +++ b/Source/WebKit2/Shared/API/c/WKBase.h @@ -84,8 +84,10 @@ typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef; typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef; typedef const struct OpaqueWKGeolocationPermissionRequest* WKGeolocationPermissionRequestRef; typedef const struct OpaqueWKGeolocationPosition* WKGeolocationPositionRef; +typedef const struct OpaqueWKIconDatabase* WKIconDatabaseRef; typedef const struct OpaqueWKInspector* WKInspectorRef; typedef const struct OpaqueWKKeyValueStorageManager* WKKeyValueStorageManagerRef; +typedef const struct OpaqueWKMediaCacheManager* WKMediaCacheManagerRef; typedef const struct OpaqueWKNavigationData* WKNavigationDataRef; typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef; typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef; diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp index 0d96ca1..ecd680c 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.cpp @@ -51,3 +51,8 @@ bool WKDictionarySetItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRe { return toImpl(dictionaryRef)->set(toImpl(keyRef)->string(), toImpl(itemRef)); } + +void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionaryRef, WKStringRef keyRef) +{ + toImpl(dictionaryRef)->remove(toImpl(keyRef)->string()); +} diff --git a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h index 467c1d4..2459f91 100644 --- a/Source/WebKit2/Shared/API/c/WKMutableDictionary.h +++ b/Source/WebKit2/Shared/API/c/WKMutableDictionary.h @@ -42,6 +42,7 @@ WK_EXPORT bool WKDictionaryIsMutable(WKDictionaryRef dictionary); WK_EXPORT bool WKDictionaryAddItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); WK_EXPORT bool WKDictionarySetItem(WKMutableDictionaryRef dictionary, WKStringRef key, WKTypeRef item); +WK_EXPORT void WKDictionaryRemoveItem(WKMutableDictionaryRef dictionary, WKStringRef key); #ifdef __cplusplus } diff --git a/Source/WebKit2/Shared/API/c/WKString.cpp b/Source/WebKit2/Shared/API/c/WKString.cpp index 72841a4..0c388c6 100644 --- a/Source/WebKit2/Shared/API/c/WKString.cpp +++ b/Source/WebKit2/Shared/API/c/WKString.cpp @@ -67,6 +67,11 @@ bool WKStringIsEqualToUTF8CString(WKStringRef aRef, const char* b) return toImpl(aRef)->equalToUTF8String(b); } +bool WKStringIsEqualToUTF8CStringIgnoringCase(WKStringRef aRef, const char* b) +{ + return toImpl(aRef)->equalToUTF8StringIgnoringCase(b); +} + WKStringRef WKStringCreateWithJSString(JSStringRef jsStringRef) { RefPtr<WebString> webString = WebString::create(jsStringRef); diff --git a/Source/WebKit2/Shared/API/c/WKString.h b/Source/WebKit2/Shared/API/c/WKString.h index e79839e..dffcab2 100644 --- a/Source/WebKit2/Shared/API/c/WKString.h +++ b/Source/WebKit2/Shared/API/c/WKString.h @@ -47,6 +47,7 @@ WK_EXPORT size_t WKStringGetUTF8CString(WKStringRef string, char* buffer, size_t WK_EXPORT bool WKStringIsEqual(WKStringRef a, WKStringRef b); WK_EXPORT bool WKStringIsEqualToUTF8CString(WKStringRef a, const char* b); +WK_EXPORT bool WKStringIsEqualToUTF8CStringIgnoringCase(WKStringRef a, const char* b); #ifdef __cplusplus } diff --git a/Source/WebKit2/Shared/API/c/WKURL.cpp b/Source/WebKit2/Shared/API/c/WKURL.cpp index 6b7e567..dacd589 100644 --- a/Source/WebKit2/Shared/API/c/WKURL.cpp +++ b/Source/WebKit2/Shared/API/c/WKURL.cpp @@ -49,3 +49,13 @@ bool WKURLIsEqual(WKURLRef a, WKURLRef b) { return toImpl(a)->string() == toImpl(b)->string(); } + +WKStringRef WKURLCopyHostName(WKURLRef url) +{ + return toCopiedAPI(toImpl(url)->host()); +} + +WKStringRef WKURLCopyScheme(WKURLRef url) +{ + return toCopiedAPI(toImpl(url)->protocol()); +} diff --git a/Source/WebKit2/Shared/API/c/WKURL.h b/Source/WebKit2/Shared/API/c/WKURL.h index 738bce5..f599f16 100644 --- a/Source/WebKit2/Shared/API/c/WKURL.h +++ b/Source/WebKit2/Shared/API/c/WKURL.h @@ -36,7 +36,9 @@ WK_EXPORT WKTypeID WKURLGetTypeID(); WK_EXPORT WKURLRef WKURLCreateWithUTF8CString(const char* string); -WK_EXPORT WKStringRef WKURLCopyString(WKURLRef URL); +WK_EXPORT WKStringRef WKURLCopyString(WKURLRef url); +WK_EXPORT WKStringRef WKURLCopyHostName(WKURLRef url); +WK_EXPORT WKStringRef WKURLCopyScheme(WKURLRef url); WK_EXPORT bool WKURLIsEqual(WKURLRef a, WKURLRef b); diff --git a/Source/WebKit2/Shared/API/c/cf/WKErrorCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKErrorCF.cpp new file mode 100644 index 0000000..95a1b43 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKErrorCF.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2011 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 "WKErrorCF.h" + +#include "WKAPICast.h" +#include "WebError.h" + +using namespace WebCore; +using namespace WebKit; + +WKErrorRef WKErrorCreateWithCFError(CFErrorRef cfError) +{ + RefPtr<WebError> error = WebError::create(ResourceError(cfError)); + return toAPI(error.release().releaseRef()); +} + +CFErrorRef WKErrorCopyCFError(CFAllocatorRef alloc, WKErrorRef error) +{ + RetainPtr<CFErrorRef> cfError = toImpl(error)->platformError().cfError(); + return cfError.leakRef(); +} diff --git a/Source/WebKit2/Shared/API/c/cf/WKErrorCF.h b/Source/WebKit2/Shared/API/c/cf/WKErrorCF.h new file mode 100644 index 0000000..298f7c2 --- /dev/null +++ b/Source/WebKit2/Shared/API/c/cf/WKErrorCF.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2011 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 WKErrorCF_h +#define WKErrorCF_h + +#include <CoreFoundation/CoreFoundation.h> +#include <WebKit2/WKBase.h> + +#ifdef __cplusplus +extern "C" { +#endif + +WK_EXPORT WKErrorRef WKErrorCreateWithCFError(CFErrorRef error); +WK_EXPORT CFErrorRef WKErrorCopyCFError(CFAllocatorRef alloc, WKErrorRef error); + +#ifdef __cplusplus +} +#endif + +#endif /* WKErrorCF_h */ diff --git a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp index 42473c8..10b4941 100644 --- a/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp +++ b/Source/WebKit2/Shared/API/c/cf/WKURLResponseCF.cpp @@ -33,6 +33,9 @@ using namespace WebKit; WKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlResponse) { + if (!urlResponse) + return 0; + CFURLResponseRef copiedURLResponse = CFURLResponseCreateCopy(kCFAllocatorDefault, urlResponse); RefPtr<WebURLResponse> response = WebURLResponse::create(copiedURLResponse); return toAPI(response.release().releaseRef()); @@ -40,5 +43,12 @@ WKURLResponseRef WKURLResponseCreateWithCFURLResponse(CFURLResponseRef urlRespon CFURLResponseRef WKURLResponseCopyCFURLResponse(CFAllocatorRef alloc, WKURLResponseRef urlResponse) { + if (!urlResponse) + return 0; + + PlatformResponse platformURLResponse = toImpl(urlResponse)->platformResponse(); + if (!platformURLResponse) + return 0; + return CFURLResponseCreateCopy(alloc, toImpl(urlResponse)->platformResponse()); } diff --git a/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp b/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp index 61b5f17..7af747e 100644 --- a/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp +++ b/Source/WebKit2/Shared/API/c/cg/WKImageCG.cpp @@ -36,6 +36,14 @@ using namespace WebCore; CGImageRef WKImageCreateCGImage(WKImageRef imageRef) { - OwnPtr<GraphicsContext> sourceContext = toImpl(imageRef)->bitmap()->createGraphicsContext(); - return CGBitmapContextCreateImage(sourceContext->platformContext()); + return toImpl(imageRef)->bitmap()->makeCGImageCopy().leakRef(); +} + +WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options) +{ + IntSize imageSize(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); + RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options)); + OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext(); + CGContextDrawImage(graphicsContext->platformContext(), CGRectMake(0, 0, imageSize.width(), imageSize.height()), imageRef); + return toAPI(webImage.release().leakRef()); } diff --git a/Source/WebKit2/Shared/API/c/cg/WKImageCG.h b/Source/WebKit2/Shared/API/c/cg/WKImageCG.h index 7705c31..800b02e 100644 --- a/Source/WebKit2/Shared/API/c/cg/WKImageCG.h +++ b/Source/WebKit2/Shared/API/c/cg/WKImageCG.h @@ -28,6 +28,7 @@ #include <CoreGraphics/CGImage.h> #include <WebKit2/WKBase.h> +#include <WebKit2/WKImage.h> #ifdef __cplusplus extern "C" { @@ -35,6 +36,8 @@ extern "C" { WK_EXPORT CGImageRef WKImageCreateCGImage(WKImageRef image); +WK_EXPORT WKImageRef WKImageCreateFromCGImage(CGImageRef imageRef, WKImageOptions options); + #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h index 7d44478..d098f34 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h +++ b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.h @@ -33,6 +33,7 @@ extern "C" { #endif +WK_EXPORT WKCertificateInfoRef WKCertificateInfoCreateWithCertficateChain(CFArrayRef certificateChain); WK_EXPORT CFArrayRef WKCertificateInfoGetCertificateChain(WKCertificateInfoRef certificateInfo); #ifdef __cplusplus diff --git a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm index a2f348d..34dd431 100644 --- a/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm +++ b/Source/WebKit2/Shared/API/c/mac/WKCertificateInfoMac.mm @@ -31,6 +31,12 @@ using namespace WebKit; +WKCertificateInfoRef WKCertificateInfoCreateWithCertficateChain(CFArrayRef certificateChain) +{ + RefPtr<WebCertificateInfo> certificateInfo = WebCertificateInfo::create(PlatformCertificateInfo(certificateChain)); + return toAPI(certificateInfo.release().leakRef()); +} + CFArrayRef WKCertificateInfoGetCertificateChain(WKCertificateInfoRef certificateInfoRef) { return toImpl(certificateInfoRef)->platformCertificateInfo().certificateChain(); diff --git a/Source/WebKit2/Shared/API/c/win/WKBaseWin.h b/Source/WebKit2/Shared/API/c/win/WKBaseWin.h index e2ee9a7..fdd4607 100644 --- a/Source/WebKit2/Shared/API/c/win/WKBaseWin.h +++ b/Source/WebKit2/Shared/API/c/win/WKBaseWin.h @@ -31,5 +31,6 @@ #endif typedef const struct OpaqueWKView* WKViewRef; +typedef const struct OpaqueWKEditCommand* WKEditCommandRef; #endif /* WKBaseWin_h */ diff --git a/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp index ada20ef..674f94e 100644 --- a/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp +++ b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.cpp @@ -31,6 +31,11 @@ using namespace WebKit; +WKCertificateInfoRef WKCertificateInfoCreateWithCertificate(PCCERT_CONTEXT certificate) +{ + return toAPI(WebCertificateInfo::create(PlatformCertificateInfo(certificate)).leakRef()); +} + size_t WKCertificateInfoGetCertificateChainLength(WKCertificateInfoRef certificateInfoRef) { return toImpl(certificateInfoRef)->platformCertificateInfo().certificateChain().size(); diff --git a/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h index 0fcd818..a3ee9e5 100644 --- a/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h +++ b/Source/WebKit2/Shared/API/c/win/WKCertificateInfoWin.h @@ -33,6 +33,7 @@ extern "C" { #endif +WK_EXPORT WKCertificateInfoRef WKCertificateInfoCreateWithCertificate(PCCERT_CONTEXT certificate); WK_EXPORT size_t WKCertificateInfoGetCertificateChainLength(WKCertificateInfoRef certificateInfo); WK_EXPORT PCCERT_CONTEXT WKCertificateInfoGetCertificateContextAtIndex(WKCertificateInfoRef certificateInfo, size_t index); diff --git a/Source/WebKit2/Shared/APIObject.h b/Source/WebKit2/Shared/APIObject.h index 24f8cba..7f50b51 100644 --- a/Source/WebKit2/Shared/APIObject.h +++ b/Source/WebKit2/Shared/APIObject.h @@ -72,11 +72,14 @@ public: TypeFormSubmissionListener, TypeFrame, TypeFramePolicyListener, + TypeFullScreenManager, TypeGeolocationManager, TypeGeolocationPermissionRequest, TypeGeolocationPosition, + TypeIconDatabase, TypeInspector, TypeKeyValueStorageManager, + TypeMediaCacheManager, TypeNavigationData, TypeOpenPanelParameters, TypeOpenPanelResultListener, @@ -101,7 +104,8 @@ public: TypeBundleScriptWorld, // Platform specific - TypeView + TypeView, + TypeEditCommandProxy }; virtual ~APIObject() diff --git a/Source/WebKit2/Shared/DictionaryPopupInfo.cpp b/Source/WebKit2/Shared/DictionaryPopupInfo.cpp index 15cb306..45bf91d 100644 --- a/Source/WebKit2/Shared/DictionaryPopupInfo.cpp +++ b/Source/WebKit2/Shared/DictionaryPopupInfo.cpp @@ -28,6 +28,10 @@ #include "WebCoreArgumentCoders.h" +#if PLATFORM(MAC) +#include "ArgumentCodersCF.h" +#endif + namespace WebKit { void DictionaryPopupInfo::encode(CoreIPC::ArgumentEncoder* encoder) const @@ -35,6 +39,10 @@ void DictionaryPopupInfo::encode(CoreIPC::ArgumentEncoder* encoder) const encoder->encode(origin); encoder->encode(fontInfo); encoder->encodeEnum(type); + +#if PLATFORM(MAC) + CoreIPC::encode(encoder, options.get()); +#endif } bool DictionaryPopupInfo::decode(CoreIPC::ArgumentDecoder* decoder, DictionaryPopupInfo& result) @@ -45,6 +53,10 @@ bool DictionaryPopupInfo::decode(CoreIPC::ArgumentDecoder* decoder, DictionaryPo return false; if (!decoder->decodeEnum(result.type)) return false; +#if PLATFORM(MAC) + if (!CoreIPC::decode(decoder, result.options)) + return false; +#endif return true; } diff --git a/Source/WebKit2/Shared/DictionaryPopupInfo.h b/Source/WebKit2/Shared/DictionaryPopupInfo.h index 5682fcd..68c81a7 100644 --- a/Source/WebKit2/Shared/DictionaryPopupInfo.h +++ b/Source/WebKit2/Shared/DictionaryPopupInfo.h @@ -29,6 +29,10 @@ #include "FontInfo.h" #include <WebCore/FloatPoint.h> +#if PLATFORM(MAC) +#include <wtf/RetainPtr.h> +#endif + namespace CoreIPC { class ArgumentDecoder; class ArgumentEncoder; @@ -48,6 +52,9 @@ struct DictionaryPopupInfo { WebCore::FloatPoint origin; FontInfo fontInfo; Type type; +#if PLATFORM(MAC) + RetainPtr<CFDictionaryRef> options; +#endif }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/HTTPCookieAcceptPolicy.h b/Source/WebKit2/Shared/HTTPCookieAcceptPolicy.h new file mode 100644 index 0000000..d7a645e --- /dev/null +++ b/Source/WebKit2/Shared/HTTPCookieAcceptPolicy.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011 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. ``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 + * 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 HTTPCookieAcceptPolicy_h +#define HTTPCookieAcceptPolicy_h + +namespace WebKit { + +enum { + HTTPCookieAcceptPolicyAlways = 0, + HTTPCookieAcceptPolicyNever = 1, + HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2, +}; +typedef unsigned HTTPCookieAcceptPolicy; + +} // namespace WebKit + +#endif // HTTPCookieAcceptPolicy_h diff --git a/Source/WebKit2/Shared/LayerTreeContext.h b/Source/WebKit2/Shared/LayerTreeContext.h index e2938aa..233b7ae 100644 --- a/Source/WebKit2/Shared/LayerTreeContext.h +++ b/Source/WebKit2/Shared/LayerTreeContext.h @@ -26,13 +26,13 @@ #ifndef LayerTreeContext_h #define LayerTreeContext_h -#if USE(ACCELERATED_COMPOSITING) - namespace CoreIPC { class ArgumentDecoder; class ArgumentEncoder; } +#if USE(ACCELERATED_COMPOSITING) + namespace WebKit { class LayerTreeContext { diff --git a/Source/WebKit2/Shared/MutableDictionary.cpp b/Source/WebKit2/Shared/MutableDictionary.cpp index 222caf3..2f905ec 100644 --- a/Source/WebKit2/Shared/MutableDictionary.cpp +++ b/Source/WebKit2/Shared/MutableDictionary.cpp @@ -48,4 +48,9 @@ bool MutableDictionary::set(const String& key, APIObject* item) return result.second; } +void MutableDictionary::remove(const String& key) +{ + m_map.remove(key); +} + } // namespace WebKit diff --git a/Source/WebKit2/Shared/MutableDictionary.h b/Source/WebKit2/Shared/MutableDictionary.h index f5ee4e7..5898cb7 100644 --- a/Source/WebKit2/Shared/MutableDictionary.h +++ b/Source/WebKit2/Shared/MutableDictionary.h @@ -43,6 +43,7 @@ public: bool add(const String& key, APIObject*); bool set(const String& key, APIObject*); + void remove(const String& key); virtual bool isMutable() { return true; } diff --git a/Source/WebKit2/Shared/PlatformPopupMenuData.cpp b/Source/WebKit2/Shared/PlatformPopupMenuData.cpp index a5ebb45..1f56daf 100644 --- a/Source/WebKit2/Shared/PlatformPopupMenuData.cpp +++ b/Source/WebKit2/Shared/PlatformPopupMenuData.cpp @@ -51,13 +51,12 @@ void PlatformPopupMenuData::encode(CoreIPC::ArgumentEncoder* encoder) const encoder->encode(m_clientInsetRight); encoder->encode(m_popupWidth); encoder->encode(m_itemHeight); - encoder->encode(m_backingStoreSize); - SharedMemory::Handle notSelectedBackingStoreHandle; + ShareableBitmap::Handle notSelectedBackingStoreHandle; m_notSelectedBackingStore->createHandle(notSelectedBackingStoreHandle); encoder->encode(notSelectedBackingStoreHandle); - SharedMemory::Handle selectedBackingStoreHandle; + ShareableBitmap::Handle selectedBackingStoreHandle; m_selectedBackingStore->createHandle(selectedBackingStoreHandle); encoder->encode(selectedBackingStoreHandle); #elif PLATFORM(MAC) @@ -80,18 +79,16 @@ bool PlatformPopupMenuData::decode(CoreIPC::ArgumentDecoder* decoder, PlatformPo return false; if (!decoder->decode(data.m_itemHeight)) return false; - if (!decoder->decode(data.m_backingStoreSize)) - return false; - SharedMemory::Handle notSelectedBackingStoreHandle; + ShareableBitmap::Handle notSelectedBackingStoreHandle; if (!decoder->decode(notSelectedBackingStoreHandle)) return false; - data.m_notSelectedBackingStore = ShareableBitmap::create(data.m_backingStoreSize, notSelectedBackingStoreHandle); + data.m_notSelectedBackingStore = ShareableBitmap::create(notSelectedBackingStoreHandle); - SharedMemory::Handle selectedBackingStoreHandle; + ShareableBitmap::Handle selectedBackingStoreHandle; if (!decoder->decode(selectedBackingStoreHandle)) return false; - data.m_selectedBackingStore = ShareableBitmap::create(data.m_backingStoreSize, selectedBackingStoreHandle); + data.m_selectedBackingStore = ShareableBitmap::create(selectedBackingStoreHandle); #elif PLATFORM(MAC) if (!decoder->decode(data.fontInfo)) return false; diff --git a/Source/WebKit2/Shared/PlatformPopupMenuData.h b/Source/WebKit2/Shared/PlatformPopupMenuData.h index f79b4b2..5b3f58d 100644 --- a/Source/WebKit2/Shared/PlatformPopupMenuData.h +++ b/Source/WebKit2/Shared/PlatformPopupMenuData.h @@ -50,7 +50,6 @@ struct PlatformPopupMenuData { int m_clientInsetRight; int m_popupWidth; int m_itemHeight; - WebCore::IntSize m_backingStoreSize; RefPtr<ShareableBitmap> m_notSelectedBackingStore; RefPtr<ShareableBitmap> m_selectedBackingStore; #elif PLATFORM(MAC) diff --git a/Source/WebKit2/Shared/Plugins/NPIdentifierData.h b/Source/WebKit2/Shared/Plugins/NPIdentifierData.h index dbe979e..1a7c772 100644 --- a/Source/WebKit2/Shared/Plugins/NPIdentifierData.h +++ b/Source/WebKit2/Shared/Plugins/NPIdentifierData.h @@ -28,7 +28,7 @@ #if ENABLE(PLUGIN_PROCESS) -#include <WebCore/npruntime.h> +#include <WebCore/npruntime_internal.h> #include <wtf/text/CString.h> namespace CoreIPC { diff --git a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp index 2fd7244..46742af 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp +++ b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.cpp @@ -33,21 +33,18 @@ #include "NPRuntimeUtilities.h" #include "NPVariantData.h" -// FIXME: This code shouldn't know about NPJSObject. -#include "NPJSObject.h" - namespace WebKit { -PassOwnPtr<NPObjectMessageReceiver> NPObjectMessageReceiver::create(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID, NPObject* npObject) +PassOwnPtr<NPObjectMessageReceiver> NPObjectMessageReceiver::create(NPRemoteObjectMap* npRemoteObjectMap, Plugin* plugin, uint64_t npObjectID, NPObject* npObject) { - return adoptPtr(new NPObjectMessageReceiver(npRemoteObjectMap, npObjectID, npObject)); + return adoptPtr(new NPObjectMessageReceiver(npRemoteObjectMap, plugin, npObjectID, npObject)); } -NPObjectMessageReceiver::NPObjectMessageReceiver(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID, NPObject* npObject) +NPObjectMessageReceiver::NPObjectMessageReceiver(NPRemoteObjectMap* npRemoteObjectMap, Plugin* plugin, uint64_t npObjectID, NPObject* npObject) : m_npRemoteObjectMap(npRemoteObjectMap) + , m_plugin(plugin) , m_npObjectID(npObjectID) , m_npObject(npObject) - , m_shouldReleaseObjectWhenInvalidating(!NPJSObject::isNPJSObject(npObject)) { retainNPObject(m_npObject); } @@ -56,13 +53,6 @@ NPObjectMessageReceiver::~NPObjectMessageReceiver() { m_npRemoteObjectMap->unregisterNPObject(m_npObjectID); - // If we're invalidating the remote object map, we don't always want to release the underlying NPObject. - // One example of this is NPJSObjects in the Web process, which have already been deallocated by the plug-in view. - // FIXME: This is not the ideal way to handle this. Maybe NPObjectMessageReceiver should be notified somehow when the underlying - // NPObject is deallocated. - if (m_npRemoteObjectMap->isInvalidating() && !m_shouldReleaseObjectWhenInvalidating) - return; - releaseNPObject(m_npObject); } @@ -90,7 +80,7 @@ void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, con Vector<NPVariant> arguments; for (size_t i = 0; i < argumentsData.size(); ++i) - arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i])); + arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i], m_plugin)); NPVariant result; VOID_TO_NPVARIANT(result); @@ -98,7 +88,7 @@ void NPObjectMessageReceiver::invoke(const NPIdentifierData& methodNameData, con returnValue = m_npObject->_class->invoke(m_npObject, methodNameData.createNPIdentifier(), arguments.data(), arguments.size(), &result); if (returnValue) { // Convert the NPVariant to an NPVariantData. - resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result); + resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); } // Release all arguments. @@ -118,7 +108,7 @@ void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumen Vector<NPVariant> arguments; for (size_t i = 0; i < argumentsData.size(); ++i) - arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i])); + arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i], m_plugin)); NPVariant result; VOID_TO_NPVARIANT(result); @@ -126,7 +116,7 @@ void NPObjectMessageReceiver::invokeDefault(const Vector<NPVariantData>& argumen returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), arguments.size(), &result); if (returnValue) { // Convert the NPVariant to an NPVariantData. - resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result); + resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); } // Release all arguments. @@ -160,7 +150,7 @@ void NPObjectMessageReceiver::getProperty(const NPIdentifierData& propertyNameDa return; // Convert the NPVariant to an NPVariantData. - resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result); + resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); // And release the result. releaseNPVariantValue(&result); @@ -173,7 +163,7 @@ void NPObjectMessageReceiver::setProperty(const NPIdentifierData& propertyNameDa return; } - NPVariant propertyValue = m_npRemoteObjectMap->npVariantDataToNPVariant(propertyValueData); + NPVariant propertyValue = m_npRemoteObjectMap->npVariantDataToNPVariant(propertyValueData, m_plugin); // Set the property. returnValue = m_npObject->_class->setProperty(m_npObject, propertyNameData.createNPIdentifier(), &propertyValue); @@ -221,7 +211,7 @@ void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsDa Vector<NPVariant> arguments; for (size_t i = 0; i < argumentsData.size(); ++i) - arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i])); + arguments.append(m_npRemoteObjectMap->npVariantDataToNPVariant(argumentsData[i], m_plugin)); NPVariant result; VOID_TO_NPVARIANT(result); @@ -229,7 +219,7 @@ void NPObjectMessageReceiver::construct(const Vector<NPVariantData>& argumentsDa returnValue = m_npObject->_class->construct(m_npObject, arguments.data(), arguments.size(), &result); if (returnValue) { // Convert the NPVariant to an NPVariantData. - resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result); + resultData = m_npRemoteObjectMap->npVariantToNPVariantData(result, m_plugin); } // Release all arguments. diff --git a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h index cfb66e1..22352d2 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h +++ b/Source/WebKit2/Shared/Plugins/NPObjectMessageReceiver.h @@ -38,20 +38,22 @@ namespace WebKit { class NPIdentifierData; class NPRemoteObjectMap; class NPVariantData; +class Plugin; class NPObjectMessageReceiver { WTF_MAKE_NONCOPYABLE(NPObjectMessageReceiver); public: - static PassOwnPtr<NPObjectMessageReceiver> create(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID, NPObject* npObject); + static PassOwnPtr<NPObjectMessageReceiver> create(NPRemoteObjectMap*, Plugin*, uint64_t npObjectID, NPObject*); ~NPObjectMessageReceiver(); CoreIPC::SyncReplyMode didReceiveSyncNPObjectMessageReceiverMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*); + Plugin* plugin() const { return m_plugin; } NPObject* npObject() const { return m_npObject; } private: - NPObjectMessageReceiver(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID, NPObject* npObject); + NPObjectMessageReceiver(NPRemoteObjectMap*, Plugin*, uint64_t npObjectID, NPObject*); // Message handlers. void deallocate(); @@ -66,9 +68,9 @@ private: void construct(const Vector<NPVariantData>& argumentsData, bool& returnValue, NPVariantData& resultData); NPRemoteObjectMap* m_npRemoteObjectMap; + Plugin* m_plugin; uint64_t m_npObjectID; NPObject* m_npObject; - bool m_shouldReleaseObjectWhenInvalidating; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp b/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp index 04a6e7d..61daa6c 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp +++ b/Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp @@ -38,16 +38,17 @@ namespace WebKit { -NPObjectProxy* NPObjectProxy::create(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID) +NPObjectProxy* NPObjectProxy::create(NPRemoteObjectMap* npRemoteObjectMap, Plugin* plugin, uint64_t npObjectID) { NPObjectProxy* npObjectProxy = toNPObjectProxy(createNPObject(0, npClass())); - npObjectProxy->initialize(npRemoteObjectMap, npObjectID); + npObjectProxy->initialize(npRemoteObjectMap, plugin, npObjectID); return npObjectProxy; } NPObjectProxy::NPObjectProxy() : m_npRemoteObjectMap(0) + , m_plugin(0) , m_npObjectID(0) { } @@ -69,19 +70,24 @@ bool NPObjectProxy::isNPObjectProxy(NPObject* npObject) void NPObjectProxy::invalidate() { ASSERT(m_npRemoteObjectMap); + ASSERT(m_plugin); m_npRemoteObjectMap = 0; + m_plugin = 0; } -void NPObjectProxy::initialize(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID) +void NPObjectProxy::initialize(NPRemoteObjectMap* npRemoteObjectMap, Plugin* plugin, uint64_t npObjectID) { ASSERT(!m_npRemoteObjectMap); + ASSERT(!m_plugin); ASSERT(!m_npObjectID); ASSERT(npRemoteObjectMap); + ASSERT(plugin); ASSERT(npObjectID); m_npRemoteObjectMap = npRemoteObjectMap; + m_plugin = plugin; m_npObjectID = npObjectID; } @@ -108,7 +114,7 @@ bool NPObjectProxy::invoke(NPIdentifier methodName, const NPVariant* arguments, NPIdentifierData methodNameData = NPIdentifierData::fromNPIdentifier(methodName); Vector<NPVariantData> argumentsData; for (uint32_t i = 0; i < argumentCount; ++i) - argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i])); + argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i], m_plugin)); bool returnValue = false; NPVariantData resultData; @@ -119,7 +125,7 @@ bool NPObjectProxy::invoke(NPIdentifier methodName, const NPVariant* arguments, if (!returnValue) return false; - *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData); + *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData, m_plugin); return true; } @@ -130,7 +136,7 @@ bool NPObjectProxy::invokeDefault(const NPVariant* arguments, uint32_t argumentC Vector<NPVariantData> argumentsData; for (uint32_t i = 0; i < argumentCount; ++i) - argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i])); + argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i], m_plugin)); bool returnValue = false; NPVariantData resultData; @@ -141,7 +147,7 @@ bool NPObjectProxy::invokeDefault(const NPVariant* arguments, uint32_t argumentC if (!returnValue) return false; - *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData); + *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData, m_plugin); return true; } @@ -176,7 +182,7 @@ bool NPObjectProxy::getProperty(NPIdentifier propertyName, NPVariant* result) if (!returnValue) return false; - *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData); + *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData, m_plugin); return true; } @@ -186,7 +192,7 @@ bool NPObjectProxy::setProperty(NPIdentifier propertyName, const NPVariant* valu return false; NPIdentifierData propertyNameData = NPIdentifierData::fromNPIdentifier(propertyName); - NPVariantData propertyValueData = m_npRemoteObjectMap->npVariantToNPVariantData(*value); + NPVariantData propertyValueData = m_npRemoteObjectMap->npVariantToNPVariantData(*value, m_plugin); bool returnValue = false; @@ -242,7 +248,7 @@ bool NPObjectProxy::construct(const NPVariant* arguments, uint32_t argumentCount Vector<NPVariantData> argumentsData; for (uint32_t i = 0; i < argumentCount; ++i) - argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i])); + argumentsData.append(m_npRemoteObjectMap->npVariantToNPVariantData(arguments[i], m_plugin)); bool returnValue = false; NPVariantData resultData; @@ -253,7 +259,7 @@ bool NPObjectProxy::construct(const NPVariant* arguments, uint32_t argumentCount if (!returnValue) return false; - *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData); + *result = m_npRemoteObjectMap->npVariantDataToNPVariant(resultData, m_plugin); return true; } diff --git a/Source/WebKit2/Shared/Plugins/NPObjectProxy.h b/Source/WebKit2/Shared/Plugins/NPObjectProxy.h index e4c00c5..f472cb8 100644 --- a/Source/WebKit2/Shared/Plugins/NPObjectProxy.h +++ b/Source/WebKit2/Shared/Plugins/NPObjectProxy.h @@ -28,18 +28,19 @@ #if ENABLE(PLUGIN_PROCESS) -#include <WebCore/npruntime.h> +#include <WebCore/npruntime_internal.h> #include <wtf/Noncopyable.h> namespace WebKit { class NPRemoteObjectMap; +class Plugin; class NPObjectProxy : public NPObject { WTF_MAKE_NONCOPYABLE(NPObjectProxy); public: - static NPObjectProxy* create(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID); + static NPObjectProxy* create(NPRemoteObjectMap*, Plugin*, uint64_t npObjectID); static bool isNPObjectProxy(NPObject*); @@ -49,6 +50,7 @@ public: return static_cast<NPObjectProxy*>(npObject); } + Plugin* plugin() const { return m_plugin; } uint64_t npObjectID() const { return m_npObjectID; } void invalidate(); @@ -57,7 +59,7 @@ private: NPObjectProxy(); ~NPObjectProxy(); - void initialize(NPRemoteObjectMap* npRemoteObjectMap, uint64_t npObjectID); + void initialize(NPRemoteObjectMap*, Plugin*, uint64_t npObjectID); bool hasMethod(NPIdentifier methodName); bool invoke(NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result); @@ -83,6 +85,7 @@ private: static bool NP_Construct(NPObject*, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result); NPRemoteObjectMap* m_npRemoteObjectMap; + Plugin* m_plugin; uint64_t m_npObjectID; }; diff --git a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp index 0e164f1..70978c5 100644 --- a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp +++ b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.cpp @@ -50,7 +50,6 @@ PassRefPtr<NPRemoteObjectMap> NPRemoteObjectMap::create(CoreIPC::Connection* con NPRemoteObjectMap::NPRemoteObjectMap(CoreIPC::Connection* connection) : m_connection(connection) - , m_isInvalidating(false) { } @@ -60,9 +59,9 @@ NPRemoteObjectMap::~NPRemoteObjectMap() ASSERT(m_registeredNPObjects.isEmpty()); } -NPObject* NPRemoteObjectMap::createNPObjectProxy(uint64_t remoteObjectID) +NPObject* NPRemoteObjectMap::createNPObjectProxy(uint64_t remoteObjectID, Plugin* plugin) { - NPObjectProxy* npObjectProxy = NPObjectProxy::create(this, remoteObjectID); + NPObjectProxy* npObjectProxy = NPObjectProxy::create(this, plugin, remoteObjectID); m_npObjectProxies.add(npObjectProxy); @@ -71,16 +70,16 @@ NPObject* NPRemoteObjectMap::createNPObjectProxy(uint64_t remoteObjectID) void NPRemoteObjectMap::npObjectProxyDestroyed(NPObject* npObject) { - ASSERT(NPObjectProxy::isNPObjectProxy(npObject)); - ASSERT(m_npObjectProxies.contains(npObject)); + NPObjectProxy* npObjectProxy = NPObjectProxy::toNPObjectProxy(npObject); + ASSERT(m_npObjectProxies.contains(npObjectProxy)); - m_npObjectProxies.remove(npObject); + m_npObjectProxies.remove(npObjectProxy); } -uint64_t NPRemoteObjectMap::registerNPObject(NPObject* npObject) +uint64_t NPRemoteObjectMap::registerNPObject(NPObject* npObject, Plugin* plugin) { uint64_t npObjectID = generateNPObjectID(); - m_registeredNPObjects.set(npObjectID, NPObjectMessageReceiver::create(this, npObjectID, npObject).leakPtr()); + m_registeredNPObjects.set(npObjectID, NPObjectMessageReceiver::create(this, plugin, npObjectID, npObject).leakPtr()); return npObjectID; } @@ -90,7 +89,7 @@ void NPRemoteObjectMap::unregisterNPObject(uint64_t npObjectID) m_registeredNPObjects.remove(npObjectID); } -NPVariantData NPRemoteObjectMap::npVariantToNPVariantData(const NPVariant& variant) +NPVariantData NPRemoteObjectMap::npVariantToNPVariantData(const NPVariant& variant, Plugin* plugin) { switch (variant.type) { case NPVariantType_Void: @@ -124,7 +123,7 @@ NPVariantData NPRemoteObjectMap::npVariantToNPVariantData(const NPVariant& varia return NPVariantData::makeRemoteNPObjectID(npObjectID); } - uint64_t npObjectID = registerNPObject(npObject); + uint64_t npObjectID = registerNPObject(npObject, plugin); return NPVariantData::makeLocalNPObjectID(npObjectID); } @@ -134,7 +133,7 @@ NPVariantData NPRemoteObjectMap::npVariantToNPVariantData(const NPVariant& varia return NPVariantData::makeVoid(); } -NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVariantData) +NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVariantData, Plugin* plugin) { NPVariant npVariant; @@ -178,7 +177,7 @@ NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVar break; } case NPVariantData::RemoteNPObjectID: { - NPObject* npObjectProxy = createNPObjectProxy(npVariantData.remoteNPObjectIDValue()); + NPObject* npObjectProxy = createNPObjectProxy(npVariantData.remoteNPObjectIDValue(), plugin); OBJECT_TO_NPVARIANT(npObjectProxy, npVariant); break; } @@ -187,25 +186,37 @@ NPVariant NPRemoteObjectMap::npVariantDataToNPVariant(const NPVariantData& npVar return npVariant; } -void NPRemoteObjectMap::invalidate() +void NPRemoteObjectMap::pluginDestroyed(Plugin* plugin) { - ASSERT(!m_isInvalidating); - - m_isInvalidating = true; - Vector<NPObjectMessageReceiver*> messageReceivers; - copyValuesToVector(m_registeredNPObjects, messageReceivers); + + // Gather the receivers associated with this plug-in. + for (HashMap<uint64_t, NPObjectMessageReceiver*>::const_iterator it = m_registeredNPObjects.begin(), end = m_registeredNPObjects.end(); it != end; ++it) { + NPObjectMessageReceiver* npObjectMessageReceiver = it->second; + if (npObjectMessageReceiver->plugin() == plugin) + messageReceivers.append(npObjectMessageReceiver); + } // Now delete all the receivers. deleteAllValues(messageReceivers); - ASSERT(m_registeredNPObjects.isEmpty()); + Vector<NPObjectProxy*> objectProxies; + for (HashSet<NPObjectProxy*>::const_iterator it = m_npObjectProxies.begin(), end = m_npObjectProxies.end(); it != end; ++it) { + NPObjectProxy* npObjectProxy = *it; - for (HashSet<NPObject*>::const_iterator it = m_npObjectProxies.begin(), end = m_npObjectProxies.end(); it != end; ++it) - NPObjectProxy::toNPObjectProxy(*it)->invalidate(); - m_npObjectProxies.clear(); + if (npObjectProxy->plugin() == plugin) + objectProxies.append(npObjectProxy); + } + + // Invalidate and remove all proxies associated with this plug-in. + for (size_t i = 0; i < objectProxies.size(); ++i) { + NPObjectProxy* npObjectProxy = objectProxies[i]; - m_isInvalidating = false; + npObjectProxy->invalidate(); + + ASSERT(m_npObjectProxies.contains(npObjectProxy)); + m_npObjectProxies.remove(npObjectProxy); + } } CoreIPC::SyncReplyMode NPRemoteObjectMap::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply) diff --git a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h index ff0bbbb..812d4d7 100644 --- a/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h +++ b/Source/WebKit2/Shared/Plugins/NPRemoteObjectMap.h @@ -39,6 +39,7 @@ namespace WebKit { class NPObjectMessageReceiver; class NPObjectProxy; class NPVariantData; +class Plugin; class NPRemoteObjectMap : public RefCounted<NPRemoteObjectMap> { public: @@ -46,23 +47,22 @@ public: ~NPRemoteObjectMap(); // Creates an NPObjectProxy wrapper for the remote object with the given remote object ID. - NPObject* createNPObjectProxy(uint64_t remoteObjectID); + NPObject* createNPObjectProxy(uint64_t remoteObjectID, Plugin*); void npObjectProxyDestroyed(NPObject*); // Expose the given NPObject as a remote object. Returns the objectID. - uint64_t registerNPObject(NPObject*); + uint64_t registerNPObject(NPObject*, Plugin*); void unregisterNPObject(uint64_t); // Given an NPVariant, creates an NPVariantData object (a CoreIPC representation of an NPVariant). - NPVariantData npVariantToNPVariantData(const NPVariant&); + NPVariantData npVariantToNPVariantData(const NPVariant&, Plugin*); // Given an NPVariantData, creates an NPVariant object. - NPVariant npVariantDataToNPVariant(const NPVariantData&); + NPVariant npVariantDataToNPVariant(const NPVariantData&, Plugin*); CoreIPC::Connection* connection() const { return m_connection; } - bool isInvalidating() const { return m_isInvalidating; } - void invalidate(); + void pluginDestroyed(Plugin*); CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply); @@ -70,14 +70,12 @@ private: explicit NPRemoteObjectMap(CoreIPC::Connection*); CoreIPC::Connection* m_connection; - bool m_isInvalidating; - // A map of NPObjectMessageReceiver classes, wrapping objects that we export to the // other end of the connection. HashMap<uint64_t, NPObjectMessageReceiver*> m_registeredNPObjects; // A set of NPObjectProxy objects associated with this map. - HashSet<NPObject*> m_npObjectProxies; + HashSet<NPObjectProxy*> m_npObjectProxies; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp index 7bbdaa8..54af967 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.cpp @@ -58,16 +58,6 @@ NetscapePluginModule::~NetscapePluginModule() ASSERT(initializedNetscapePluginModules().find(this) == notFound); } -void NetscapePluginModule::pluginCreated() -{ - incrementLoadCount(); -} - -void NetscapePluginModule::pluginDestroyed() -{ - decrementLoadCount(); -} - Vector<String> NetscapePluginModule::sitesWithData() { Vector<String> sites; @@ -235,8 +225,21 @@ bool NetscapePluginModule::tryLoad() // reversed. Failing to follow this order results in crashes (e.g., in Silverlight on Mac and // in Flash and QuickTime on Windows). #if PLUGIN_ARCHITECTURE(MAC) - if (initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR || getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR) - return false; +#ifndef NP_NO_CARBON + // Plugins (at least QT) require that you call UseResFile on the resource file before loading it. + ResFileRefNum currentResourceFile = CurResFile(); + + ResFileRefNum pluginResourceFile = m_module->bundleResourceMap(); + UseResFile(pluginResourceFile); +#endif + bool result = initializeFuncPtr(netscapeBrowserFuncs()) == NPERR_NO_ERROR && getEntryPointsFuncPtr(&m_pluginFuncs) == NPERR_NO_ERROR; + +#ifndef NP_NO_CARBON + // Restore the resource file. + UseResFile(currentResourceFile); +#endif + + return result; #elif PLUGIN_ARCHITECTURE(WIN) if (getEntryPointsFuncPtr(&m_pluginFuncs) != NPERR_NO_ERROR || initializeFuncPtr(netscapeBrowserFuncs()) != NPERR_NO_ERROR) return false; diff --git a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h index aee26bb..4ec7991 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h +++ b/Source/WebKit2/Shared/Plugins/Netscape/NetscapePluginModule.h @@ -45,9 +45,9 @@ public: ~NetscapePluginModule(); const NPPluginFuncs& pluginFuncs() const { return m_pluginFuncs; } - - void pluginCreated(); - void pluginDestroyed(); + + void incrementLoadCount(); + void decrementLoadCount(); static bool getPluginInfo(const String& pluginPath, PluginInfoStore::Plugin&); @@ -68,9 +68,6 @@ private: void applyX11QuirksBeforeLoad(); #endif - void incrementLoadCount(); - void decrementLoadCount(); - bool tryGetSitesWithData(Vector<String>&); bool tryClearSiteData(const String& site, uint64_t flags, uint64_t maxAge); diff --git a/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm b/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm index accab46..d290f5b 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm +++ b/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm @@ -86,13 +86,35 @@ static bool getPluginArchitecture(CFBundleRef bundle, cpu_type_t& pluginArchitec return false; } + +static RetainPtr<CFDictionaryRef> getMIMETypesFromPluginBundle(CFBundleRef bundle) +{ + CFStringRef propertyListFilename = static_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypesFilename"))); + if (propertyListFilename) { + RetainPtr<CFStringRef> propertyListPath(AdoptCF, CFStringCreateWithFormat(kCFAllocatorDefault, 0, CFSTR("%@/Library/Preferences/%@"), NSHomeDirectory(), propertyListFilename)); + RetainPtr<CFURLRef> propertyListURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, propertyListPath.get(), kCFURLPOSIXPathStyle, FALSE)); + + CFDataRef propertyListData; + CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, propertyListURL.get(), &propertyListData, 0, 0, 0); + RetainPtr<CFPropertyListRef> propertyList(AdoptCF, CFPropertyListCreateWithData(kCFAllocatorDefault, propertyListData, kCFPropertyListImmutable, 0, 0)); + if (propertyListData) + CFRelease(propertyListData); + + // FIXME: Have the plug-in create the MIME types property list if it doesn't exist. + // https://bugs.webkit.org/show_bug.cgi?id=57204 + if (!propertyList || CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID()) + return 0; + + return static_cast<CFDictionaryRef>(CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), CFSTR("WebPluginMIMETypes"))); + } + + return static_cast<CFDictionaryRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes"))); +} static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& pluginInfo) { - // FIXME: Handle WebPluginMIMETypesFilenameKey. - - CFDictionaryRef mimeTypes = static_cast<CFDictionaryRef>(CFBundleGetValueForInfoDictionaryKey(bundle, CFSTR("WebPluginMIMETypes"))); - if (!mimeTypes || CFGetTypeID(mimeTypes) != CFDictionaryGetTypeID()) + RetainPtr<CFDictionaryRef> mimeTypes = getMIMETypesFromPluginBundle(bundle); + if (!mimeTypes || CFGetTypeID(mimeTypes.get()) != CFDictionaryGetTypeID()) return false; // Get the plug-in name. @@ -106,10 +128,10 @@ static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& plugi pluginInfo.desc = pluginDescription; // Get the MIME type mapping dictionary. - CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes); + CFIndex numMimeTypes = CFDictionaryGetCount(mimeTypes.get()); Vector<CFStringRef> mimeTypesVector(numMimeTypes); Vector<CFDictionaryRef> mimeTypeInfoVector(numMimeTypes); - CFDictionaryGetKeysAndValues(mimeTypes, reinterpret_cast<const void**>(mimeTypesVector.data()), reinterpret_cast<const void**>(mimeTypeInfoVector.data())); + CFDictionaryGetKeysAndValues(mimeTypes.get(), reinterpret_cast<const void**>(mimeTypesVector.data()), reinterpret_cast<const void**>(mimeTypeInfoVector.data())); for (CFIndex i = 0; i < numMimeTypes; ++i) { MimeClassInfo mimeClassInfo; @@ -142,8 +164,15 @@ static bool getPluginInfoFromPropertyLists(CFBundleRef bundle, PluginInfo& plugi CFStringRef extension = static_cast<CFStringRef>(CFArrayGetValueAtIndex(extensionsArray, i)); if (!extension || CFGetTypeID(extension) != CFStringGetTypeID()) continue; - - mimeClassInfo.extensions.append(String(extension).lower()); + + // The DivX plug-in lists multiple extensions in a comma separated string instead of using + // multiple array elements in the property list. Work around this here by splitting the + // extension string into components. + Vector<String> extensionComponents; + String(extension).lower().split(',', extensionComponents); + + for (size_t i = 0; i < extensionComponents.size(); ++i) + mimeClassInfo.extensions.append(extensionComponents[i]); } // Add this MIME type. @@ -333,8 +362,24 @@ void NetscapePluginModule::determineQuirks() if (plugin.bundleIdentifier == "com.macromedia.Flash Player.plugin") { // Flash requires that the return value of getprogname() be "WebKitPluginHost". m_pluginQuirks.add(PluginQuirks::PrognameShouldBeWebKitPluginHost); + + // Flash supports snapshotting. m_pluginQuirks.add(PluginQuirks::SupportsSnapshotting); } + + if (plugin.bundleIdentifier == "com.microsoft.SilverlightPlugin") { + // Silverlight doesn't explicitly opt into transparency, so we'll do it whenever + // there's a 'background' attribute. + m_pluginQuirks.add(PluginQuirks::MakeTransparentIfBackgroundAttributeExists); + } + +#ifndef NP_NO_QUICKDRAW + if (plugin.bundleIdentifier == "com.apple.ist.ds.appleconnect.webplugin") { + // The AppleConnect plug-in uses QuickDraw but doesn't paint or receive events + // so we'll allow it to be instantiated even though we don't support QuickDraw. + m_pluginQuirks.add(PluginQuirks::AllowHalfBakedQuickDrawSupport); + } +#endif } } // namespace WebKit diff --git a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp index b5e3aad..76ecda7 100644 --- a/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp +++ b/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp @@ -40,7 +40,7 @@ namespace WebKit { #if PLATFORM(QT) static void initializeGTK() { - QLibrary library("libgtk-x11-2.0.so.0"); + QLibrary library(QLatin1String("libgtk-x11-2.0.so.0")); if (library.load()) { typedef void *(*gtk_init_check_ptr)(int*, char***); gtk_init_check_ptr gtkInitCheck = reinterpret_cast<gtk_init_check_ptr>(library.resolve("gtk_init_check")); diff --git a/Source/WebKit2/Shared/Plugins/PluginQuirks.h b/Source/WebKit2/Shared/Plugins/PluginQuirks.h index 9f8c1c4..ea4643b 100644 --- a/Source/WebKit2/Shared/Plugins/PluginQuirks.h +++ b/Source/WebKit2/Shared/Plugins/PluginQuirks.h @@ -36,8 +36,25 @@ public: // The plug-in wants the call to getprogame() to return "WebKitPluginHost". // Adobe Flash Will not handle key down events otherwise. PrognameShouldBeWebKitPluginHost, + // Supports receiving a paint event, even when using CoreAnimation rendering. SupportsSnapshotting, + + // Make the plug-in transparent if it has a "background" attribute set. + // Microsoft Silverlight doesn't opt into transparency using NPN_SetValue and + // NPPVpluginTransparentBool, so we'll always force if the plug-in has a "background" + // attribute specified, regardless of it's value. + // FIXME: We could get more fancy here and check for specific values that we know are + // transparent. + MakeTransparentIfBackgroundAttributeExists, + +#ifndef NP_NO_QUICKDRAW + // Allow the plug-in to use the QuickDraw drawing model, since wek now that the plug-in + // will never paint or receive events. Used by the AppleConnect plug-in. + AllowHalfBakedQuickDrawSupport, +#endif + + // X11 specific quirks: #elif PLUGIN_ARCHITECTURE(X11) // Flash and npwrapper ask the browser about which GTK version does it use // and refuse to load and work if it is not GTK 2 so we need to fake it in diff --git a/Source/WebKit2/Shared/ResourceCachesToClear.h b/Source/WebKit2/Shared/ResourceCachesToClear.h new file mode 100644 index 0000000..df9367c --- /dev/null +++ b/Source/WebKit2/Shared/ResourceCachesToClear.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 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 ResourceCachesToClear_h +#define ResourceCachesToClear_h + +namespace WebKit { + +enum ResourceCachesToClear { + AllResourceCaches = 0, + InMemoryResourceCachesOnly = 1 +}; + +} // namespace WebKit + +#endif // ResourceCachesToClear_h diff --git a/Source/WebKit2/Shared/ShareableBitmap.cpp b/Source/WebKit2/Shared/ShareableBitmap.cpp index ab1991f..cde3aa1 100644 --- a/Source/WebKit2/Shared/ShareableBitmap.cpp +++ b/Source/WebKit2/Shared/ShareableBitmap.cpp @@ -27,13 +27,37 @@ #include "ShareableBitmap.h" #include "SharedMemory.h" +#include "WebCoreArgumentCoders.h" #include <WebCore/GraphicsContext.h> using namespace WebCore; namespace WebKit { -PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size) +ShareableBitmap::Handle::Handle() + : m_flags(0) +{ +} + +void ShareableBitmap::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const +{ + encoder->encode(m_handle); + encoder->encode(m_size); + encoder->encode(m_flags); +} + +bool ShareableBitmap::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& handle) +{ + if (!decoder->decode(handle.m_handle)) + return false; + if (!decoder->decode(handle.m_size)) + return false; + if (!decoder->decode(handle.m_flags)) + return false; + return true; +} + +PassRefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags) { size_t numBytes = numBytesForSize(size); @@ -41,10 +65,10 @@ PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size if (!tryFastMalloc(numBytes).getValue(data)) return 0; - return adoptRef(new ShareableBitmap(size, data)); + return adoptRef(new ShareableBitmap(size, flags, data)); } -PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size) +PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size, Flags flags) { size_t numBytes = numBytesForSize(size); @@ -52,44 +76,50 @@ PassRefPtr<ShareableBitmap> ShareableBitmap::createShareable(const IntSize& size if (!sharedMemory) return 0; - return adoptRef(new ShareableBitmap(size, sharedMemory)); + return adoptRef(new ShareableBitmap(size, flags, sharedMemory)); } -PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size, PassRefPtr<SharedMemory> sharedMemory) +PassRefPtr<ShareableBitmap> ShareableBitmap::create(const IntSize& size, Flags flags, PassRefPtr<SharedMemory> sharedMemory) { ASSERT(sharedMemory); size_t numBytes = numBytesForSize(size); ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes); - return adoptRef(new ShareableBitmap(size, sharedMemory)); + return adoptRef(new ShareableBitmap(size, flags, sharedMemory)); } -PassRefPtr<ShareableBitmap> ShareableBitmap::create(const WebCore::IntSize& size, const SharedMemory::Handle& handle) +PassRefPtr<ShareableBitmap> ShareableBitmap::create(const Handle& handle) { // Create the shared memory. - RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadWrite); + RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle.m_handle, SharedMemory::ReadWrite); if (!sharedMemory) return 0; - return create(size, sharedMemory.release()); + return create(handle.m_size, handle.m_flags, sharedMemory.release()); } -bool ShareableBitmap::createHandle(SharedMemory::Handle& handle) +bool ShareableBitmap::createHandle(Handle& handle) { ASSERT(isBackedBySharedMemory()); - return m_sharedMemory->createHandle(handle, SharedMemory::ReadWrite); + if (!m_sharedMemory->createHandle(handle.m_handle, SharedMemory::ReadWrite)) + return false; + handle.m_size = m_size; + handle.m_flags = m_flags; + return true; } -ShareableBitmap::ShareableBitmap(const IntSize& size, void* data) +ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, void* data) : m_size(size) + , m_flags(flags) , m_data(data) { } -ShareableBitmap::ShareableBitmap(const IntSize& size, PassRefPtr<SharedMemory> sharedMemory) +ShareableBitmap::ShareableBitmap(const IntSize& size, Flags flags, PassRefPtr<SharedMemory> sharedMemory) : m_size(size) + , m_flags(flags) , m_sharedMemory(sharedMemory) , m_data(0) { diff --git a/Source/WebKit2/Shared/ShareableBitmap.h b/Source/WebKit2/Shared/ShareableBitmap.h index f9a3af0..fe7fa0a 100644 --- a/Source/WebKit2/Shared/ShareableBitmap.h +++ b/Source/WebKit2/Shared/ShareableBitmap.h @@ -33,6 +33,10 @@ #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> +#if PLATFORM(CG) +#include <wtf/RetainPtr.h> +#endif + namespace WebCore { class GraphicsContext; } @@ -41,20 +45,43 @@ namespace WebKit { class ShareableBitmap : public RefCounted<ShareableBitmap> { public: + enum Flag { + SupportsAlpha = 1 << 0, + }; + typedef unsigned Flags; + + class Handle { + WTF_MAKE_NONCOPYABLE(Handle); + public: + Handle(); + + bool isNull() const { return m_handle.isNull(); } + + void encode(CoreIPC::ArgumentEncoder*) const; + static bool decode(CoreIPC::ArgumentDecoder*, Handle&); + + private: + friend class ShareableBitmap; + + mutable SharedMemory::Handle m_handle; + WebCore::IntSize m_size; + Flags m_flags; + }; + // Create a shareable bitmap that uses malloced memory. - static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&); + static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags); // Create a shareable bitmap whose backing memory can be shared with another process. - static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&); + static PassRefPtr<ShareableBitmap> createShareable(const WebCore::IntSize&, Flags); // Create a shareable bitmap from an already existing shared memory block. - static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, PassRefPtr<SharedMemory>); + static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, Flags, PassRefPtr<SharedMemory>); - // Create a shareable bitmap from a shared memory handle. - static PassRefPtr<ShareableBitmap> create(const WebCore::IntSize&, const SharedMemory::Handle&); + // Create a shareable bitmap from a handle. + static PassRefPtr<ShareableBitmap> create(const Handle&); - // Create a shared memory handle. - bool createHandle(SharedMemory::Handle&); + // Create a handle. + bool createHandle(Handle&); ~ShareableBitmap(); @@ -71,18 +98,31 @@ public: bool isBackedBySharedMemory() const { return m_sharedMemory; } +#if PLATFORM(CG) + // This creates a copied CGImageRef (most likely a copy-on-write) of the shareable bitmap. + RetainPtr<CGImageRef> makeCGImageCopy(); + + // This creates a CGImageRef that directly references the shared bitmap data. + // This is only safe to use when we know that the contents of the shareable bitmap won't change. + RetainPtr<CGImageRef> makeCGImage(); +#endif + private: - ShareableBitmap(const WebCore::IntSize&, void*); - ShareableBitmap(const WebCore::IntSize&, PassRefPtr<SharedMemory>); + ShareableBitmap(const WebCore::IntSize&, Flags, void*); + ShareableBitmap(const WebCore::IntSize&, Flags, PassRefPtr<SharedMemory>); static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; } - static void releaseData(void* typelessBitmap, void* typelessData); - +#if PLATFORM(CG) + static void releaseBitmapContextData(void* typelessBitmap, void* typelessData); + static void releaseDataProviderData(void* typelessBitmap, const void* typelessData, size_t); +#endif + void* data() const; size_t sizeInBytes() const { return numBytesForSize(m_size); } WebCore::IntSize m_size; + Flags m_flags; // If the shareable bitmap is backed by shared memory, this points to the shared memory object. RefPtr<SharedMemory> m_sharedMemory; diff --git a/Source/WebKit2/Shared/UpdateInfo.h b/Source/WebKit2/Shared/UpdateInfo.h index 7b5454e..8e08ed0 100644 --- a/Source/WebKit2/Shared/UpdateInfo.h +++ b/Source/WebKit2/Shared/UpdateInfo.h @@ -26,7 +26,7 @@ #ifndef UpdateInfo_h #define UpdateInfo_h -#include "SharedMemory.h" +#include "ShareableBitmap.h" #include <WebCore/IntRect.h> #include <wtf/Noncopyable.h> @@ -60,7 +60,7 @@ public: Vector<WebCore::IntRect> updateRects; // The handle of the shareable bitmap containing the updates. Will be null if there are no updates. - SharedMemory::Handle bitmapHandle; + ShareableBitmap::Handle bitmapHandle; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/UserMessageCoders.h b/Source/WebKit2/Shared/UserMessageCoders.h index 1326a98..ad72493 100644 --- a/Source/WebKit2/Shared/UserMessageCoders.h +++ b/Source/WebKit2/Shared/UserMessageCoders.h @@ -31,7 +31,9 @@ #include "ImmutableArray.h" #include "ImmutableDictionary.h" #include "ShareableBitmap.h" +#include "WebCertificateInfo.h" #include "WebCoreArgumentCoders.h" +#include "WebData.h" #include "WebImage.h" #include "WebNumber.h" #include "WebSerializedScriptValue.h" @@ -47,6 +49,8 @@ namespace WebKit { // - SerializedScriptValue -> SerializedScriptValue // - String -> String // - UserContentURLPattern -> UserContentURLPattern +// - WebCertificateInfo -> WebCertificateInfo +// - WebData -> WebData // - WebDouble -> WebDouble // - WebImage -> WebImage // - WebUInt64 -> WebUInt64 @@ -128,16 +132,25 @@ public: return true; } - SharedMemory::Handle handle; + ShareableBitmap::Handle handle; if (!image->bitmap()->createHandle(handle)) return false; encoder->encode(true); - encoder->encode(image->size()); encoder->encode(handle); return true; } + case APIObject::TypeData: { + WebData* data = static_cast<WebData*>(m_root); + encoder->encodeBytes(data->bytes(), data->size()); + return true; + } + case APIObject::TypeCertificateInfo: { + WebCertificateInfo* certificateInfo = static_cast<WebCertificateInfo*>(m_root); + encoder->encode(certificateInfo->platformCertificateInfo()); + return true; + } default: break; } @@ -162,6 +175,8 @@ protected: // - SerializedScriptValue -> SerializedScriptValue // - String -> String // - UserContentURLPattern -> UserContentURLPattern +// - WebCertificateInfo -> WebCertificateInfo +// - WebData -> WebData // - WebDouble -> WebDouble // - WebImage -> WebImage // - WebUInt64 -> WebUInt64 @@ -277,17 +292,27 @@ public: if (!didEncode) break; - WebCore::IntSize size; - if (!decoder->decode(size)) - return false; - - SharedMemory::Handle handle; + ShareableBitmap::Handle handle; if (!decoder->decode(handle)) return false; - coder.m_root = WebImage::create(ShareableBitmap::create(size, handle)); + coder.m_root = WebImage::create(ShareableBitmap::create(handle)); return true; } + case APIObject::TypeData: { + Vector<uint8_t> buffer; + if (!decoder->decodeBytes(buffer)) + return false; + coder.m_root = WebData::create(buffer); + break; + } + case APIObject::TypeCertificateInfo: { + PlatformCertificateInfo platformCertificateInfo; + if (!decoder->decode(platformCertificateInfo)) + return false; + coder.m_root = WebCertificateInfo::create(platformCertificateInfo); + break; + } default: break; } diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp index e97c7fd..99b3c00 100644 --- a/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp +++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.cpp @@ -37,25 +37,21 @@ namespace CoreIPC { void encodeImage(ArgumentEncoder* encoder, Image* image) { - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size()); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), ShareableBitmap::SupportsAlpha); bitmap->createGraphicsContext()->drawImage(image, ColorSpaceDeviceRGB, IntPoint()); - SharedMemory::Handle handle; + ShareableBitmap::Handle handle; bitmap->createHandle(handle); - encoder->encode(image->size()); encoder->encode(handle); } bool decodeImage(ArgumentDecoder* decoder, RefPtr<Image>& image) { - IntSize imageSize; - if (!decoder->decode(imageSize)) - return false; - SharedMemory::Handle handle; + ShareableBitmap::Handle handle; if (!decoder->decode(handle)) return false; - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageSize, handle); + RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle); if (!bitmap) return false; image = createImage(bitmap.get()); diff --git a/Source/WebKit2/Shared/WebCoreArgumentCoders.h b/Source/WebKit2/Shared/WebCoreArgumentCoders.h index 1679bb6..e12b9be 100644 --- a/Source/WebKit2/Shared/WebCoreArgumentCoders.h +++ b/Source/WebKit2/Shared/WebCoreArgumentCoders.h @@ -277,26 +277,22 @@ template<> struct ArgumentCoder<WebCore::ResourceResponse> { } }; +// These two functions are implemented in a platform specific manner. +void encodeResourceError(ArgumentEncoder*, const WebCore::ResourceError&); +bool decodeResourceError(ArgumentDecoder*, WebCore::ResourceError&); + template<> struct ArgumentCoder<WebCore::ResourceError> { static void encode(ArgumentEncoder* encoder, const WebCore::ResourceError& resourceError) { - encoder->encode(CoreIPC::In(resourceError.domain(), resourceError.errorCode(), resourceError.failingURL(), resourceError.localizedDescription())); + encodeResourceError(encoder, resourceError); } static bool decode(ArgumentDecoder* decoder, WebCore::ResourceError& resourceError) { - String domain; - int errorCode; - String failingURL; - String localizedDescription; - if (!decoder->decode(CoreIPC::Out(domain, errorCode, failingURL, localizedDescription))) - return false; - resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription); - return true; + return decodeResourceError(decoder, resourceError); } }; - template<> struct ArgumentCoder<WebCore::WindowFeatures> { static void encode(ArgumentEncoder* encoder, const WebCore::WindowFeatures& windowFeatures) { diff --git a/Source/WebKit2/Shared/WebData.h b/Source/WebKit2/Shared/WebData.h index 789b965..538e496 100644 --- a/Source/WebKit2/Shared/WebData.h +++ b/Source/WebKit2/Shared/WebData.h @@ -38,34 +38,60 @@ class WebData : public APIObject { public: static const Type APIType = TypeData; + typedef void (*FreeDataFunction)(unsigned char*, const void* context); + + static PassRefPtr<WebData> createWithoutCopying(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context) + { + return adoptRef(new WebData(bytes, size, freeDataFunction, context)); + } + static PassRefPtr<WebData> create(const unsigned char* bytes, size_t size) { - return adoptRef(new WebData(bytes, size)); + unsigned char *copiedBytes = 0; + + if (size) { + copiedBytes = static_cast<unsigned char*>(fastMalloc(size)); + memcpy(copiedBytes, bytes, size); + } + + return createWithoutCopying(copiedBytes, size, fastFreeBytes, 0); } static PassRefPtr<WebData> create(const Vector<unsigned char>& buffer) { - return adoptRef(new WebData(buffer)); + return create(buffer.data(), buffer.size()); } - - const unsigned char* bytes() const { return m_buffer.data(); } - size_t size() const { return m_buffer.size(); } + + ~WebData() + { + m_freeDataFunction(const_cast<unsigned char*>(m_bytes), m_context); + } + + const unsigned char* bytes() const { return m_bytes; } + size_t size() const { return m_size; } private: - WebData(const unsigned char* bytes, size_t size) - : m_buffer(size) + WebData(const unsigned char* bytes, size_t size, FreeDataFunction freeDataFunction, const void* context) + : m_bytes(bytes) + , m_size(size) + , m_freeDataFunction(freeDataFunction) + , m_context(context) { - memcpy(m_buffer.data(), bytes, size); } - - WebData(const Vector<unsigned char>& buffer) - : m_buffer(buffer) + + static void fastFreeBytes(unsigned char* bytes, const void*) { + if (bytes) + fastFree(static_cast<void*>(bytes)); } virtual Type type() const { return APIType; } - Vector<unsigned char> m_buffer; + const unsigned char* m_bytes; + size_t m_size; + + FreeDataFunction m_freeDataFunction; + const void* m_context; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/WebImage.cpp b/Source/WebKit2/Shared/WebImage.cpp index e245268..b0e4bff 100644 --- a/Source/WebKit2/Shared/WebImage.cpp +++ b/Source/WebKit2/Shared/WebImage.cpp @@ -35,8 +35,8 @@ namespace WebKit { PassRefPtr<WebImage> WebImage::create(const IntSize& size, ImageOptions options) { if (options & ImageOptionsShareable) - return WebImage::create(ShareableBitmap::createShareable(size)); - return WebImage::create(ShareableBitmap::create(size)); + return WebImage::create(ShareableBitmap::createShareable(size, ShareableBitmap::SupportsAlpha)); + return WebImage::create(ShareableBitmap::create(size, ShareableBitmap::SupportsAlpha)); } PassRefPtr<WebImage> WebImage::create(PassRefPtr<ShareableBitmap> bitmap) diff --git a/Source/WebKit2/Shared/WebMemorySampler.cpp b/Source/WebKit2/Shared/WebMemorySampler.cpp index 82b2be9..ef17a2b 100644 --- a/Source/WebKit2/Shared/WebMemorySampler.cpp +++ b/Source/WebKit2/Shared/WebMemorySampler.cpp @@ -117,7 +117,7 @@ bool WebMemorySampler::isRunning() const void WebMemorySampler::initializeTempLogFile() { - m_sampleLogFilePath = String((openTemporaryFile(processName().utf8().data(), m_sampleLogFile)).data()); + m_sampleLogFilePath = openTemporaryFile(processName(), m_sampleLogFile); writeHeaders(); } diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.cpp b/Source/WebKit2/Shared/WebPageCreationParameters.cpp index 33b53e3..c5dff58 100644 --- a/Source/WebKit2/Shared/WebPageCreationParameters.cpp +++ b/Source/WebKit2/Shared/WebPageCreationParameters.cpp @@ -51,6 +51,7 @@ void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const encoder->encode(highestUsedBackForwardItemID); encoder->encode(canRunBeforeUnloadConfirmPanel); encoder->encode(canRunModal); + encoder->encode(userSpaceScaleFactor); #if PLATFORM(MAC) encoder->encode(isSmartInsertDeleteEnabled); @@ -99,6 +100,8 @@ bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPag return false; if (!decoder->decode(parameters.canRunModal)) return false; + if (!decoder->decode(parameters.userSpaceScaleFactor)) + return false; #if PLATFORM(MAC) if (!decoder->decode(parameters.isSmartInsertDeleteEnabled)) diff --git a/Source/WebKit2/Shared/WebPageCreationParameters.h b/Source/WebKit2/Shared/WebPageCreationParameters.h index 31759e1..5fb152f 100644 --- a/Source/WebKit2/Shared/WebPageCreationParameters.h +++ b/Source/WebKit2/Shared/WebPageCreationParameters.h @@ -71,6 +71,8 @@ struct WebPageCreationParameters { bool canRunBeforeUnloadConfirmPanel; bool canRunModal; + float userSpaceScaleFactor; + #if PLATFORM(MAC) bool isSmartInsertDeleteEnabled; #endif diff --git a/Source/WebKit2/Shared/WebPreferencesStore.cpp b/Source/WebKit2/Shared/WebPreferencesStore.cpp index c215782..c072740 100644 --- a/Source/WebKit2/Shared/WebPreferencesStore.cpp +++ b/Source/WebKit2/Shared/WebPreferencesStore.cpp @@ -49,6 +49,8 @@ namespace WebPreferencesKey { static bool hasXSSAuditorEnabledTestRunnerOverride; static bool xssAuditorEnabledTestRunnerOverride; +static bool hasAllowUniversalAccessFromFileURLsTestRunnerOverride; +static bool allowUniversalAccessFromFileURLsTestRunnerOverride; WebPreferencesStore::WebPreferencesStore() { @@ -67,6 +69,9 @@ bool WebPreferencesStore::decode(CoreIPC::ArgumentDecoder* decoder, WebPreferenc if (hasXSSAuditorEnabledTestRunnerOverride) s.m_boolValues.set(WebPreferencesKey::xssAuditorEnabledKey(), xssAuditorEnabledTestRunnerOverride); + if (hasAllowUniversalAccessFromFileURLsTestRunnerOverride) + s.m_boolValues.set(WebPreferencesKey::allowUniversalAccessFromFileURLsKey(), allowUniversalAccessFromFileURLsTestRunnerOverride); + return true; } @@ -76,6 +81,12 @@ void WebPreferencesStore::overrideXSSAuditorEnabledForTestRunner(bool enabled) xssAuditorEnabledTestRunnerOverride = enabled; } +void WebPreferencesStore::overrideAllowUniversalAccessFromFileURLsForTestRunner(bool enabled) +{ + hasAllowUniversalAccessFromFileURLsTestRunnerOverride = true; + allowUniversalAccessFromFileURLsTestRunnerOverride = enabled; +} + void WebPreferencesStore::removeTestRunnerOverrides() { hasXSSAuditorEnabledTestRunnerOverride = false; diff --git a/Source/WebKit2/Shared/WebPreferencesStore.h b/Source/WebKit2/Shared/WebPreferencesStore.h index f00a90e..43ef487 100644 --- a/Source/WebKit2/Shared/WebPreferencesStore.h +++ b/Source/WebKit2/Shared/WebPreferencesStore.h @@ -54,6 +54,7 @@ namespace WebKit { macro(NeedsSiteSpecificQuirks, needsSiteSpecificQuirks, Bool, bool, false) \ macro(AcceleratedCompositingEnabled, acceleratedCompositingEnabled, Bool, bool, true) \ macro(AcceleratedDrawingEnabled, acceleratedDrawingEnabled, Bool, bool, false) \ + macro(CanvasUsesAcceleratedDrawing, canvasUsesAcceleratedDrawing, Bool, bool, true) \ macro(CompositingBordersVisible, compositingBordersVisible, Bool, bool, false) \ macro(CompositingRepaintCountersVisible, compositingRepaintCountersVisible, Bool, bool, false) \ macro(WebGLEnabled, webGLEnabled, Bool, bool, false) \ @@ -68,6 +69,10 @@ namespace WebKit { macro(DOMPasteAllowed, domPasteAllowed, Bool, bool, false) \ macro(JavaScriptCanAccessClipboard, javaScriptCanAccessClipboard, Bool, bool, false) \ macro(ShouldPrintBackgrounds, shouldPrintBackgrounds, Bool, bool, false) \ + macro(FullScreenEnabled, fullScreenEnabled, Bool, bool, true) \ + macro(WebSecurityEnabled, webSecurityEnabled, Bool, bool, true) \ + macro(AllowUniversalAccessFromFileURLs, allowUniversalAccessFromFileURLs, Bool, bool, false) \ + macro(AllowFileAccessFromFileURLs, allowFileAccessFromFileURLs, Bool, bool, false) \ \ #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \ @@ -163,6 +168,7 @@ struct WebPreferencesStore { double getDoubleValueForKey(const String& key) const; static void overrideXSSAuditorEnabledForTestRunner(bool); + static void overrideAllowUniversalAccessFromFileURLsForTestRunner(bool); static void removeTestRunnerOverrides(); HashMap<String, String> m_stringValues; diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp index 360c6d7..db3cd4c 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.cpp +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.cpp @@ -51,6 +51,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con encoder->encode(injectedBundlePathExtensionHandle); encoder->encode(applicationCacheDirectory); encoder->encode(databaseDirectory); + encoder->encode(localStorageDirectory); encoder->encode(urlSchemesRegistererdAsEmptyDocument); encoder->encode(urlSchemesRegisteredAsSecure); encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden); @@ -60,6 +61,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con encoder->encode(clearResourceCaches); encoder->encode(clearApplicationCache); encoder->encode(shouldAlwaysUseComplexTextCodePath); + encoder->encode(iconDatabaseEnabled); encoder->encode(languageCode); encoder->encode(textCheckerState); encoder->encode(defaultRequestTimeoutInterval); @@ -79,6 +81,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con encoder->encode(cfURLCachePath); encoder->encode(cfURLCacheDiskCapacity); encoder->encode(cfURLCacheMemoryCapacity); + encoder->encode(initialHTTPCookieAcceptPolicy); #endif } @@ -92,6 +95,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web return false; if (!decoder->decode(parameters.databaseDirectory)) return false; + if (!decoder->decode(parameters.localStorageDirectory)) + return false; if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument)) return false; if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure)) @@ -110,6 +115,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web return false; if (!decoder->decode(parameters.shouldAlwaysUseComplexTextCodePath)) return false; + if (!decoder->decode(parameters.iconDatabaseEnabled)) + return false; if (!decoder->decode(parameters.languageCode)) return false; if (!decoder->decode(parameters.textCheckerState)) @@ -145,6 +152,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web return false; if (!decoder->decode(parameters.cfURLCacheMemoryCapacity)) return false; + if (!decoder->decode(parameters.initialHTTPCookieAcceptPolicy)) + return false; #endif return true; diff --git a/Source/WebKit2/Shared/WebProcessCreationParameters.h b/Source/WebKit2/Shared/WebProcessCreationParameters.h index a57be99..112d6eb 100644 --- a/Source/WebKit2/Shared/WebProcessCreationParameters.h +++ b/Source/WebKit2/Shared/WebProcessCreationParameters.h @@ -54,6 +54,7 @@ struct WebProcessCreationParameters { String applicationCacheDirectory; String databaseDirectory; + String localStorageDirectory; Vector<String> urlSchemesRegistererdAsEmptyDocument; Vector<String> urlSchemesRegisteredAsSecure; Vector<String> urlSchemesForWhichDomainRelaxationIsForbidden; @@ -69,6 +70,8 @@ struct WebProcessCreationParameters { bool shouldAlwaysUseComplexTextCodePath; + bool iconDatabaseEnabled; + String languageCode; TextCheckerState textCheckerState; @@ -97,6 +100,8 @@ struct WebProcessCreationParameters { uint64_t cfURLCacheDiskCapacity; uint64_t cfURLCacheMemoryCapacity; + uint32_t initialHTTPCookieAcceptPolicy; + bool shouldPaintNativeControls; #endif }; diff --git a/Source/WebKit2/Shared/WebString.h b/Source/WebKit2/Shared/WebString.h index a77293b..6827276 100644 --- a/Source/WebKit2/Shared/WebString.h +++ b/Source/WebKit2/Shared/WebString.h @@ -74,6 +74,7 @@ public: bool equal(WebString* other) { return m_string == other->m_string; } bool equalToUTF8String(const char* other) { return m_string == String::fromUTF8(other); } + bool equalToUTF8StringIgnoringCase(const char* other) { return equalIgnoringCase(m_string, other); } const String& string() const { return m_string; } diff --git a/Source/WebKit2/Shared/WebURL.h b/Source/WebKit2/Shared/WebURL.h index 1b0826b..14bd99f 100644 --- a/Source/WebKit2/Shared/WebURL.h +++ b/Source/WebKit2/Shared/WebURL.h @@ -27,6 +27,9 @@ #define WebURL_h #include "APIObject.h" +#include <WebCore/KURL.h> +#include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> #include <wtf/PassRefPtr.h> #include <wtf/text/WTFString.h> @@ -48,15 +51,35 @@ public: const String& string() const { return m_string; } + String host() const + { + parseURLIfNecessary(); + return m_parsedURL->isValid() ? m_parsedURL->host() : String(); + } + + String protocol() const + { + parseURLIfNecessary(); + return m_parsedURL->isValid() ? m_parsedURL->protocol() : String(); + } + private: WebURL(const String& string) : m_string(string) { } + void parseURLIfNecessary() const + { + if (m_parsedURL) + return; + m_parsedURL = WTF::adoptPtr(new WebCore::KURL(WebCore::KURL(), m_string)); + } + virtual Type type() const { return APIType; } String m_string; + mutable OwnPtr<WebCore::KURL> m_parsedURL; }; } // namespace WebKit diff --git a/Source/WebKit2/Shared/cf/ArgumentCodersCF.cpp b/Source/WebKit2/Shared/cf/ArgumentCodersCF.cpp index 936b6b3..c762d5b 100644 --- a/Source/WebKit2/Shared/cf/ArgumentCodersCF.cpp +++ b/Source/WebKit2/Shared/cf/ArgumentCodersCF.cpp @@ -48,6 +48,9 @@ enum CFType { CFNumber, CFString, CFURL, +#if PLATFORM(MAC) + SecCertificate, +#endif Null, Unknown, }; @@ -76,6 +79,10 @@ static CFType typeFromCFTypeRef(CFTypeRef type) return CFString; if (typeID == CFURLGetTypeID()) return CFURL; +#if PLATFORM(MAC) + if (typeID == SecCertificateGetTypeID()) + return SecCertificate; +#endif ASSERT_NOT_REACHED(); return Unknown; @@ -110,6 +117,11 @@ static void encode(ArgumentEncoder* encoder, CFTypeRef typeRef) case CFURL: encode(encoder, static_cast<CFURLRef>(typeRef)); return; +#if PLATFORM(MAC) + case SecCertificate: + encode(encoder, (SecCertificateRef)typeRef); + return; +#endif case Null: return; case Unknown: @@ -178,6 +190,15 @@ static bool decode(ArgumentDecoder* decoder, RetainPtr<CFTypeRef>& result) result.adoptCF(url.leakRef()); return true; } +#if PLATFORM(MAC) + case SecCertificate: { + RetainPtr<SecCertificateRef> certificate; + if (!decode(decoder, certificate)) + return false; + result.adoptCF(certificate.leakRef()); + return true; + } +#endif case Null: result = tokenNullTypeRef(); return true; @@ -459,5 +480,22 @@ bool decode(ArgumentDecoder* decoder, RetainPtr<CFURLRef>& result) return true; } -} // namespace CoreIPC +#if PLATFORM(MAC) +void encode(ArgumentEncoder* encoder, SecCertificateRef certificate) +{ + RetainPtr<CFDataRef> data(AdoptCF, SecCertificateCopyData(certificate)); + encode(encoder, data.get()); +} +bool decode(ArgumentDecoder* decoder, RetainPtr<SecCertificateRef>& result) +{ + RetainPtr<CFDataRef> data; + if (!decode(decoder, data)) + return false; + + result.adoptCF(SecCertificateCreateWithData(0, data.get())); + return true; +} +#endif + +} // namespace CoreIPC diff --git a/Source/WebKit2/Shared/cf/ArgumentCodersCF.h b/Source/WebKit2/Shared/cf/ArgumentCodersCF.h index 4caec5f..291a093 100644 --- a/Source/WebKit2/Shared/cf/ArgumentCodersCF.h +++ b/Source/WebKit2/Shared/cf/ArgumentCodersCF.h @@ -28,6 +28,10 @@ #include <wtf/RetainPtr.h> +#if PLATFORM(MAC) +#include <Security/SecCertificate.h> +#endif + namespace CoreIPC { class ArgumentEncoder; @@ -61,6 +65,12 @@ bool decode(ArgumentDecoder*, RetainPtr<CFStringRef>& result); void encode(ArgumentEncoder*, CFURLRef); bool decode(ArgumentDecoder*, RetainPtr<CFURLRef>& result); +#if PLATFORM(MAC) +// SecCertificateRef +void encode(ArgumentEncoder*, SecCertificateRef); +bool decode(ArgumentDecoder*, RetainPtr<SecCertificateRef>& result); +#endif + CFTypeRef tokenNullTypeRef(); } // namespace CoreIPC diff --git a/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp b/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp index 28ba7ea..6bcc108 100644 --- a/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp +++ b/Source/WebKit2/Shared/cg/ShareableBitmapCG.cpp @@ -34,14 +34,26 @@ using namespace WebCore; namespace WebKit { +static CGBitmapInfo bitmapInfo(ShareableBitmap::Flags flags) +{ + CGBitmapInfo info = kCGBitmapByteOrder32Host; + if (flags & ShareableBitmap::SupportsAlpha) + info |= kCGImageAlphaPremultipliedFirst; + else + info |= kCGImageAlphaNoneSkipFirst; + + return info; +} + PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext() { RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); - ref(); // Balanced by deref in releaseData. + + ref(); // Balanced by deref in releaseBitmapContextData. RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), - kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, releaseData, this)); + bitmapInfo(m_flags), releaseBitmapContextData, this)); // We want the origin to be in the top left corner so we flip the backing store context. CGContextTranslateCTM(bitmapContext.get(), 0, m_size.height()); @@ -52,14 +64,38 @@ PassOwnPtr<GraphicsContext> ShareableBitmap::createGraphicsContext() void ShareableBitmap::paint(WebCore::GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect) { - paintBitmapContext(context.platformContext(), createGraphicsContext()->platformContext(), dstPoint, srcRect); + paintImage(context.platformContext(), makeCGImageCopy().get(), dstPoint, srcRect); +} + +RetainPtr<CGImageRef> ShareableBitmap::makeCGImageCopy() +{ + OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext(); + RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(graphicsContext->platformContext())); + return image; +} + +RetainPtr<CGImageRef> ShareableBitmap::makeCGImage() +{ + ref(); // Balanced by deref in releaseDataProviderData. + RetainPtr<CGDataProvider> dataProvider(AdoptCF, CGDataProviderCreateWithData(this, data(), sizeInBytes(), releaseDataProviderData)); + + RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); + RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(m_size.width(), m_size.height(), 8, 32, m_size.width() * 4, colorSpace.get(), bitmapInfo(m_flags), dataProvider.get(), 0, false, kCGRenderingIntentDefault)); + return image; } -void ShareableBitmap::releaseData(void* typelessBitmap, void* typelessData) +void ShareableBitmap::releaseBitmapContextData(void* typelessBitmap, void* typelessData) { ShareableBitmap* bitmap = static_cast<ShareableBitmap*>(typelessBitmap); ASSERT_UNUSED(typelessData, bitmap->data() == typelessData); bitmap->deref(); // Balanced by ref in createGraphicsContext. } +void ShareableBitmap::releaseDataProviderData(void* typelessBitmap, const void* typelessData, size_t) +{ + ShareableBitmap* bitmap = static_cast<ShareableBitmap*>(typelessBitmap); + ASSERT_UNUSED(typelessData, bitmap->data() == typelessData); + bitmap->deref(); // Balanced by ref in createCGImage. +} + } // namespace WebKit diff --git a/Source/WebKit2/Shared/cg/WebCoreArgumentCodersCG.cpp b/Source/WebKit2/Shared/cg/WebCoreArgumentCodersCG.cpp index 058cf51..fb1395f 100644 --- a/Source/WebKit2/Shared/cg/WebCoreArgumentCodersCG.cpp +++ b/Source/WebKit2/Shared/cg/WebCoreArgumentCodersCG.cpp @@ -36,7 +36,7 @@ namespace CoreIPC { RefPtr<Image> createImage(ShareableBitmap* bitmap) { - RetainPtr<CGImageRef> platformImage(AdoptCF, CGBitmapContextCreateImage(bitmap->createGraphicsContext()->platformContext())); + RetainPtr<CGImageRef> platformImage = bitmap->makeCGImage(); if (!platformImage) return 0; // BitmapImage::create adopts the CGImageRef that's passed in, which is why we need to leakRef here. diff --git a/Source/WebKit2/Shared/gtk/WebCoreArgumentCodersGtk.cpp b/Source/WebKit2/Shared/gtk/WebCoreArgumentCodersGtk.cpp index 2770a3f..73527ce 100644 --- a/Source/WebKit2/Shared/gtk/WebCoreArgumentCodersGtk.cpp +++ b/Source/WebKit2/Shared/gtk/WebCoreArgumentCodersGtk.cpp @@ -39,7 +39,12 @@ void encodeResourceRequest(ArgumentEncoder* encoder, const WebCore::ResourceRequ bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& resourceRequest) { notImplemented(); - return false; + + // FIXME: Add real implementation when we want to implement something that + // depends on this like the policy client. + // https://bugs.webkit.org/show_bug.cgi?id=55934 + resourceRequest = WebCore::ResourceRequest(); + return true; } void encodeResourceResponse(ArgumentEncoder* encoder, const WebCore::ResourceResponse& resourceResponse) @@ -50,7 +55,27 @@ void encodeResourceResponse(ArgumentEncoder* encoder, const WebCore::ResourceRes bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse& resourceResponse) { notImplemented(); - return false; + + // FIXME: Ditto. + resourceResponse = WebCore::ResourceResponse(); + return true; +} + +void encodeResourceError(ArgumentEncoder* encoder, const WebCore::ResourceError& resourceError) +{ + encoder->encode(CoreIPC::In(resourceError.domain(), resourceError.errorCode(), resourceError.failingURL(), resourceError.localizedDescription())); +} + +bool decodeResourceError(ArgumentDecoder* decoder, WebCore::ResourceError& resourceError) +{ + String domain; + int errorCode; + String failingURL; + String localizedDescription; + if (!decoder->decode(CoreIPC::Out(domain, errorCode, failingURL, localizedDescription))) + return false; + resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription); + return true; } } diff --git a/Source/WebKit2/Shared/gtk/WebEventFactory.cpp b/Source/WebKit2/Shared/gtk/WebEventFactory.cpp index a9acbb3..d8f8b46 100644 --- a/Source/WebKit2/Shared/gtk/WebEventFactory.cpp +++ b/Source/WebKit2/Shared/gtk/WebEventFactory.cpp @@ -28,6 +28,7 @@ #include "config.h" #include "WebEventFactory.h" +#include "GtkVersioning.h" #include "PlatformKeyboardEvent.h" #include "Scrollbar.h" #include "WindowsKeyboardCodes.h" @@ -41,7 +42,7 @@ namespace WebKit { static inline bool isGdkKeyCodeFromKeyPad(unsigned keyval) { - return keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9; + return keyval >= GDK_KP_Space && keyval <= GDK_KP_9; } static inline WebEvent::Modifiers modifiersForEvent(const GdkEvent* event) 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; } diff --git a/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp b/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp index a5d5f12..8377923 100644 --- a/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp +++ b/Source/WebKit2/Shared/qt/WebCoreArgumentCodersQt.cpp @@ -60,4 +60,21 @@ bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse& return true; } +void encodeResourceError(ArgumentEncoder* encoder, const WebCore::ResourceError& resourceError) +{ + encoder->encode(CoreIPC::In(resourceError.domain(), resourceError.errorCode(), resourceError.failingURL(), resourceError.localizedDescription())); +} + +bool decodeResourceError(ArgumentDecoder* decoder, WebCore::ResourceError& resourceError) +{ + String domain; + int errorCode; + String failingURL; + String localizedDescription; + if (!decoder->decode(CoreIPC::Out(domain, errorCode, failingURL, localizedDescription))) + return false; + resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription); + return true; +} + } // namespace CoreIPC diff --git a/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp b/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp index ade2291..0d1ca36 100644 --- a/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp +++ b/Source/WebKit2/Shared/win/PlatformCertificateInfo.cpp @@ -65,14 +65,23 @@ PlatformCertificateInfo::PlatformCertificateInfo(const ResourceResponse& respons PCERT_SIMPLE_CHAIN firstSimpleChain = chainContext->rgpChain[0]; for (unsigned i = 0; i < firstSimpleChain->cElement; ++i) { PCCERT_CONTEXT certificateContext = firstSimpleChain->rgpElement[i]->pCertContext; - ::CertDuplicateCertificateContext(certificateContext); - m_certificateChain.append(certificateContext); + PCCERT_CONTEXT certificateContextCopy = ::CertDuplicateCertificateContext(certificateContext); + m_certificateChain.append(certificateContextCopy); } #else // FIXME: WinCairo implementation #endif } +PlatformCertificateInfo::PlatformCertificateInfo(PCCERT_CONTEXT certificateContext) +{ + if (!certificateContext) + return; + + PCCERT_CONTEXT certificateContextCopy = ::CertDuplicateCertificateContext(certificateContext); + m_certificateChain.append(certificateContextCopy); +} + PlatformCertificateInfo::~PlatformCertificateInfo() { clearCertificateChain(); @@ -81,8 +90,8 @@ PlatformCertificateInfo::~PlatformCertificateInfo() PlatformCertificateInfo::PlatformCertificateInfo(const PlatformCertificateInfo& other) { for (size_t i = 0; i < other.m_certificateChain.size(); ++i) { - ::CertDuplicateCertificateContext(other.m_certificateChain[i]); - m_certificateChain.append(other.m_certificateChain[i]); + PCCERT_CONTEXT certificateContextCopy = ::CertDuplicateCertificateContext(other.m_certificateChain[i]); + m_certificateChain.append(certificateContextCopy); } } @@ -90,8 +99,8 @@ PlatformCertificateInfo& PlatformCertificateInfo::operator=(const PlatformCertif { clearCertificateChain(); for (size_t i = 0; i < other.m_certificateChain.size(); ++i) { - ::CertDuplicateCertificateContext(other.m_certificateChain[i]); - m_certificateChain.append(other.m_certificateChain[i]); + PCCERT_CONTEXT certificateContextCopy = ::CertDuplicateCertificateContext(other.m_certificateChain[i]); + m_certificateChain.append(certificateContextCopy); } return *this; } diff --git a/Source/WebKit2/Shared/win/PlatformCertificateInfo.h b/Source/WebKit2/Shared/win/PlatformCertificateInfo.h index e483d37..dd999ef 100644 --- a/Source/WebKit2/Shared/win/PlatformCertificateInfo.h +++ b/Source/WebKit2/Shared/win/PlatformCertificateInfo.h @@ -43,6 +43,7 @@ class PlatformCertificateInfo { public: PlatformCertificateInfo(); explicit PlatformCertificateInfo(const WebCore::ResourceResponse&); + explicit PlatformCertificateInfo(PCCERT_CONTEXT); ~PlatformCertificateInfo(); PlatformCertificateInfo(const PlatformCertificateInfo&); diff --git a/Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp b/Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp index 9513e90..d659ac4 100644 --- a/Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp +++ b/Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp @@ -28,6 +28,8 @@ #if USE(CFNETWORK) #include "ArgumentCodersCF.h" +#include "PlatformCertificateInfo.h" +#include <WebCore/CertificateCFWin.h> #include <WebKitSystemInterface/WebKitSystemInterface.h> #endif @@ -117,4 +119,39 @@ bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse& #endif } +void encodeResourceError(ArgumentEncoder* encoder, const WebCore::ResourceError& resourceError) +{ + encoder->encode(CoreIPC::In(resourceError.domain(), resourceError.errorCode(), resourceError.failingURL(), resourceError.localizedDescription())); + +#if USE(CFNETWORK) + encoder->encode(WebKit::PlatformCertificateInfo(resourceError.certificate())); +#endif +} + +bool decodeResourceError(ArgumentDecoder* decoder, WebCore::ResourceError& resourceError) +{ + String domain; + int errorCode; + String failingURL; + String localizedDescription; + if (!decoder->decode(CoreIPC::Out(domain, errorCode, failingURL, localizedDescription))) + return false; + +#if USE(CFNETWORK) + WebKit::PlatformCertificateInfo certificate; + if (!decoder->decode(certificate)) + return false; + + const Vector<PCCERT_CONTEXT> certificateChain = certificate.certificateChain(); + if (!certificateChain.isEmpty()) { + ASSERT(certificateChain.size() == 1); + resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription, WebCore::copyCertificateToData(certificateChain.first()).get()); + return true; + } +#endif + + resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription); + return true; +} + } // namespace CoreIPC |