Skip to content

Commit

Permalink
[Mac][WK2] Videos do not have access to session cookies
Browse files Browse the repository at this point in the history
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:]):


Canonical link: https://commits.webkit.org/149297@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166812 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed Apr 4, 2014
1 parent 2da27b4 commit 361b17c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
13 changes: 13 additions & 0 deletions Source/WebKit2/ChangeLog
@@ -1,3 +1,16 @@
2014-04-04 Jer Noble <jer.noble@apple.com>

[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 <ap@apple.com>

Improve error checking in WebPageProxy::didReceiveEvent
Expand Down
40 changes: 30 additions & 10 deletions Source/WebKit2/Shared/mac/CookieStorageShim.mm
Expand Up @@ -31,11 +31,11 @@
#include "CookieStorageShimLibrary.h"
#include "NetworkConnectionToWebProcess.h"
#include "NetworkProcessConnection.h"
#include <WebCore/SessionID.h>
#include "WebCoreArgumentCoders.h"
#include "WebProcess.h"
#include <WebCore/URL.h>
#include <WebCore/SessionID.h>
#include <WebCore/SoftLinking.h>
#include <WebCore/URL.h>
#include <dlfcn.h>
#include <wtf/MainThread.h>
#include <wtf/RetainPtr.h>
Expand All @@ -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 {
Expand Down Expand Up @@ -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
}

}
Expand All @@ -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)

0 comments on commit 361b17c

Please sign in to comment.