Diff
Modified: branches/safari-600.1.4-branch/Source/WebCore/ChangeLog (172422 => 172423)
--- branches/safari-600.1.4-branch/Source/WebCore/ChangeLog 2014-08-12 00:36:33 UTC (rev 172422)
+++ branches/safari-600.1.4-branch/Source/WebCore/ChangeLog 2014-08-12 01:00:36 UTC (rev 172423)
@@ -1,3 +1,31 @@
+2014-08-11 Babak Shafiei <[email protected]>
+
+ Merge r172422. <rdar://problem/17912361>
+
+ 2014-08-11 Jer Noble <[email protected]>
+
+ [iOS] <video> element requests are missing session cookies; sometimes persistant cookies.
+ https://bugs.webkit.org/show_bug.cgi?id=135816
+
+ Reviewed by Alexey Proskuryakov.
+
+ On iOS, the AVFoundation framework will copy appropriate cookies for the requested URL across to the
+ mediaserverd process. For WebKit2, the WebProcess does not have access to session cookies for the
+ current browsing session. When creating an AVURLAsset, fetch the appropriate cookies for the requested
+ URL, and pass them into AVURLAsset in the options dictionary.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerGetRawCookies): Call CookieJar's equivalent method.
+ * html/HTMLMediaElement.h:
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::getRawCookies): Pass to HTMLMediaElement.
+ * platform/graphics/MediaPlayer.h:
+ (WebCore::MediaPlayerClient::mediaPlayerGetRawCookies):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::toNSHTTPCookie): Convert a WebCore Cookie -> NSHTTPCookie.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Fetch cookies for the requested
+ URL, and if successful, add them to the AVURLAsset options dictionary.
+
2014-08-07 Matthew Hanson <[email protected]>
Merge r172275. <rdar://problem/17886686>
Modified: branches/safari-600.1.4-branch/Source/WebCore/html/HTMLMediaElement.cpp (172422 => 172423)
--- branches/safari-600.1.4-branch/Source/WebCore/html/HTMLMediaElement.cpp 2014-08-12 00:36:33 UTC (rev 172422)
+++ branches/safari-600.1.4-branch/Source/WebCore/html/HTMLMediaElement.cpp 2014-08-12 01:00:36 UTC (rev 172423)
@@ -37,6 +37,7 @@
#include "ClientRectList.h"
#include "ContentSecurityPolicy.h"
#include "ContentType.h"
+#include "CookieJar.h"
#include "DiagnosticLoggingKeys.h"
#include "DisplaySleepDisabler.h"
#include "DocumentLoader.h"
@@ -5744,6 +5745,11 @@
return settings->networkInterfaceName();
}
+
+bool HTMLMediaElement::mediaPlayerGetRawCookies(const URL& url, Vector<Cookie>& cookies) const
+{
+ return getRawCookies(&document(), url, cookies);
+}
#endif
void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
Modified: branches/safari-600.1.4-branch/Source/WebCore/html/HTMLMediaElement.h (172422 => 172423)
--- branches/safari-600.1.4-branch/Source/WebCore/html/HTMLMediaElement.h 2014-08-12 00:36:33 UTC (rev 172422)
+++ branches/safari-600.1.4-branch/Source/WebCore/html/HTMLMediaElement.h 2014-08-12 01:00:36 UTC (rev 172423)
@@ -572,6 +572,7 @@
#if PLATFORM(IOS)
virtual String mediaPlayerNetworkInterfaceName() const;
+ virtual bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const override;
#endif
void loadTimerFired(Timer<HTMLMediaElement>&);
Modified: branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp (172422 => 172423)
--- branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp 2014-08-12 00:36:33 UTC (rev 172422)
+++ branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/MediaPlayer.cpp 2014-08-12 01:00:36 UTC (rev 172423)
@@ -1428,6 +1428,14 @@
return m_mediaPlayerClient->mediaPlayerNetworkInterfaceName();
}
+
+bool MediaPlayer::getRawCookies(const URL& url, Vector<Cookie>& cookies) const
+{
+ if (!m_mediaPlayerClient)
+ return false;
+
+ return m_mediaPlayerClient->mediaPlayerGetRawCookies(url, cookies);
+}
#endif
}
Modified: branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/MediaPlayer.h (172422 => 172423)
--- branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/MediaPlayer.h 2014-08-12 00:36:33 UTC (rev 172422)
+++ branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/MediaPlayer.h 2014-08-12 01:00:36 UTC (rev 172423)
@@ -76,6 +76,7 @@
#endif
class MediaPlayerPrivateInterface;
class TextTrackRepresentation;
+struct Cookie;
// Structure that will hold every native
// types supported by the current media player.
@@ -264,6 +265,7 @@
#if PLATFORM(IOS)
virtual String mediaPlayerNetworkInterfaceName() const { return String(); }
+ virtual bool mediaPlayerGetRawCookies(const URL&, Vector<Cookie>&) const { return false; }
#endif
virtual bool mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&) { return false; }
@@ -560,6 +562,7 @@
#if PLATFORM(IOS)
String mediaPlayerNetworkInterfaceName() const;
+ bool getRawCookies(const URL&, Vector<Cookie>&) const;
#endif
static void resetMediaEngines();
Modified: branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (172422 => 172423)
--- branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2014-08-12 00:36:33 UTC (rev 172422)
+++ branches/safari-600.1.4-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2014-08-12 01:00:36 UTC (rev 172423)
@@ -33,6 +33,7 @@
#import "AuthenticationChallenge.h"
#import "BlockExceptions.h"
#import "CDMSessionAVFoundationObjC.h"
+#import "Cookie.h"
#import "ExceptionCodePlaceholder.h"
#import "FloatConversion.h"
#import "FloatConversion.h"
@@ -228,6 +229,7 @@
#endif
#if ENABLE(AVF_CAPTIONS)
+SOFT_LINK_POINTER(AVFoundation, AVURLAssetHTTPCookiesKey, NSString*)
SOFT_LINK_POINTER(AVFoundation, AVURLAssetOutOfBandAlternateTracksKey, NSString*)
SOFT_LINK_POINTER(AVFoundation, AVOutOfBandAlternateTrackDisplayNameKey, NSString*)
SOFT_LINK_POINTER(AVFoundation, AVOutOfBandAlternateTrackExtendedLanguageTagKey, NSString*)
@@ -238,6 +240,7 @@
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString*)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString*)
+#define AVURLAssetHTTPCookiesKey getAVURLAssetHTTPCookiesKey()
#define AVURLAssetOutOfBandAlternateTracksKey getAVURLAssetOutOfBandAlternateTracksKey()
#define AVOutOfBandAlternateTrackDisplayNameKey getAVOutOfBandAlternateTrackDisplayNameKey()
#define AVOutOfBandAlternateTrackExtendedLanguageTagKey getAVOutOfBandAlternateTrackExtendedLanguageTagKey()
@@ -711,6 +714,24 @@
return [canonicalRequest URL];
}
+static NSHTTPCookie* toNSHTTPCookie(const Cookie& cookie)
+{
+ RetainPtr<NSMutableDictionary> properties = adoptNS([[NSMutableDictionary alloc] init]);
+ [properties setDictionary:@{
+ NSHTTPCookieName: cookie.name,
+ NSHTTPCookieValue: cookie.value,
+ NSHTTPCookieDomain: cookie.domain,
+ NSHTTPCookiePath: cookie.path,
+ NSHTTPCookieExpires: [NSDate dateWithTimeIntervalSince1970:(cookie.expires / 1000)],
+ }];
+ if (cookie.secure)
+ [properties setObject:@YES forKey:NSHTTPCookieSecure];
+ if (cookie.session)
+ [properties setObject:@YES forKey:NSHTTPCookieDiscard];
+
+ return [NSHTTPCookie cookieWithProperties:properties.get()];
+}
+
void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url)
{
if (m_avAsset)
@@ -773,6 +794,17 @@
[options setObject:networkInterfaceName forKey:AVURLAssetBoundNetworkInterfaceName];
#endif
+#if PLATFORM(IOS)
+ Vector<Cookie> cookies;
+ if (player()->getRawCookies(URL(ParsedURLString, url), cookies)) {
+ RetainPtr<NSMutableArray> nsCookies = adoptNS([[NSMutableArray alloc] initWithCapacity:cookies.size()]);
+ for (auto& cookie : cookies)
+ [nsCookies addObject:toNSHTTPCookie(cookie)];
+
+ [options setObject:nsCookies.get() forKey:AVURLAssetHTTPCookiesKey];
+ }
+#endif
+
NSURL *cocoaURL = canonicalURL(url);
m_avAsset = adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);