diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index c2bc2b769a7e..0f38ba88d0fe 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,16 @@ +2014-04-04 Jer Noble + + [Mac][WK2] Videos do not have access to session cookies + https://bugs.webkit.org/show_bug.cgi?id=129687 + + Reviewed by Eric Carlson. + + Update the CookieStorageShim to track changes in underlying networking stack. + + * Shared/mac/CookieStorageShim.mm: + (WebKit::CookieStorageShim::initialize): + (-[WKNSURLSessionLocal _getCookieHeadersForTask:completionHandler:]): + 2014-04-04 Alexey Proskuryakov Improve error checking in WebPageProxy::didReceiveEvent diff --git a/Source/WebKit2/Shared/mac/CookieStorageShim.mm b/Source/WebKit2/Shared/mac/CookieStorageShim.mm index f09ff4fb6533..42be1673be74 100644 --- a/Source/WebKit2/Shared/mac/CookieStorageShim.mm +++ b/Source/WebKit2/Shared/mac/CookieStorageShim.mm @@ -31,11 +31,11 @@ #include "CookieStorageShimLibrary.h" #include "NetworkConnectionToWebProcess.h" #include "NetworkProcessConnection.h" -#include #include "WebCoreArgumentCoders.h" #include "WebProcess.h" -#include +#include #include +#include #include #include #include @@ -50,6 +50,9 @@ @interface WKNSURLSessionLocal : NSObject - (CFDictionaryRef) _copyCookiesForRequestUsingAllAppropriateStorageSemantics:(CFURLRequestRef) request; +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 +- (void)_getCookieHeadersForTask:(NSURLSessionTask*)task completionHandler:(void (^)(CFDictionaryRef))completionHandler; +#endif @end namespace WebKit { @@ -87,14 +90,19 @@ static CFDictionaryRef webKitCookieStorageCopyRequestHeaderFieldsForURL(CFHTTPCo if (!__NSURLSessionLocalClass) return; - Method original = class_getInstanceMethod(__NSURLSessionLocalClass, @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:)); - if (!original) - return; - - Method replacement = class_getInstanceMethod([WKNSURLSessionLocal class], @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:)); - ASSERT(replacement); - - method_exchangeImplementations(original, replacement); + if (Method original = class_getInstanceMethod(__NSURLSessionLocalClass, @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:))) { + Method replacement = class_getInstanceMethod([WKNSURLSessionLocal class], @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:)); + ASSERT(replacement); + method_exchangeImplementations(original, replacement); + } + +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 + if (Method original = class_getInstanceMethod(__NSURLSessionLocalClass, @selector(_getCookieHeadersForTask:completionHandler:))) { + Method replacement = class_getInstanceMethod([WKNSURLSessionLocal class], @selector(_getCookieHeadersForTask:completionHandler:)); + ASSERT(replacement); + method_exchangeImplementations(original, replacement); + } +#endif } } @@ -104,6 +112,18 @@ - (CFDictionaryRef)_copyCookiesForRequestUsingAllAppropriateStorageSemantics:(CF { return WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, CFURLRequestGetURL(request)); } + +#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 +- (void)_getCookieHeadersForTask:(NSURLSessionTask*)task completionHandler:(void (^)(CFDictionaryRef))completionHandler +{ + if (!completionHandler) + return; + + dispatch_async(dispatch_get_main_queue(), ^{ + completionHandler(WebKit::webKitCookieStorageCopyRequestHeaderFieldsForURL(nullptr, (CFURLRef)[[task currentRequest] URL])); + }); +} +#endif @end #endif // ENABLE(NETWORK_PROCESS)