Title: [166940] trunk/Source/WebKit2
Revision
166940
Author
jer.no...@apple.com
Date
2014-04-08 11:26:51 -0700 (Tue, 08 Apr 2014)

Log Message

[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:]):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (166939 => 166940)


--- trunk/Source/WebKit2/ChangeLog	2014-04-08 18:22:56 UTC (rev 166939)
+++ trunk/Source/WebKit2/ChangeLog	2014-04-08 18:26:51 UTC (rev 166940)
@@ -1,3 +1,16 @@
+2014-04-07  Jer Noble  <jer.no...@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-08  Dan Bernstein  <m...@apple.com>
 
         [Cocoa] Add a way to tell whether a WKWebProcessPlugInNodeHandle is a text-type HTML input element

Modified: trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm (166939 => 166940)


--- trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm	2014-04-08 18:22:56 UTC (rev 166939)
+++ trunk/Source/WebKit2/Shared/mac/CookieStorageShim.mm	2014-04-08 18:26:51 UTC (rev 166940)
@@ -31,17 +31,18 @@
 #include "CookieStorageShimLibrary.h"
 #include "NetworkConnectionToWebProcess.h"
 #include "NetworkProcessConnection.h"
-#include <WebCore/SessionID.h>
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
+#include <WebCore/SessionID.h>
+#include <WebCore/SoftLinking.h>
 #include <WebCore/URL.h>
-#include <WebCore/SoftLinking.h>
 #include <dlfcn.h>
 #include <wtf/MainThread.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/text/WTFString.h>
 
 typedef const struct _CFURLRequest* CFURLRequestRef;
+@class NSURLSessionTask;
 
 SOFT_LINK_FRAMEWORK(CFNetwork)
 SOFT_LINK(CFNetwork, CFURLRequestGetURL, CFURLRef, (CFURLRequestRef request), (request))
@@ -50,6 +51,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 +91,19 @@
     if (!__NSURLSessionLocalClass)
         return;
 
-    Method original = class_getInstanceMethod(__NSURLSessionLocalClass, @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:));
-    if (!original)
-        return;
+    if (Method original = class_getInstanceMethod(__NSURLSessionLocalClass, @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:))) {
+        Method replacement = class_getInstanceMethod([WKNSURLSessionLocal class], @selector(_copyCookiesForRequestUsingAllAppropriateStorageSemantics:));
+        ASSERT(replacement);
+        method_exchangeImplementations(original, replacement);
+    }
 
-    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 +113,18 @@
 {
     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)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to