- Revision
- 172422
- Author
- [email protected]
- Date
- 2014-08-11 17:36:33 -0700 (Mon, 11 Aug 2014)
Log Message
[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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (172421 => 172422)
--- trunk/Source/WebCore/ChangeLog 2014-08-12 00:13:35 UTC (rev 172421)
+++ trunk/Source/WebCore/ChangeLog 2014-08-12 00:36:33 UTC (rev 172422)
@@ -1,3 +1,27 @@
+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-11 Roger Fong <[email protected]>
Adjustments to CueBox CSS Width calculations Part 2.
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (172421 => 172422)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2014-08-12 00:13:35 UTC (rev 172421)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2014-08-12 00:36:33 UTC (rev 172422)
@@ -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: trunk/Source/WebCore/html/HTMLMediaElement.h (172421 => 172422)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2014-08-12 00:13:35 UTC (rev 172421)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2014-08-12 00:36:33 UTC (rev 172422)
@@ -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: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (172421 => 172422)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2014-08-12 00:13:35 UTC (rev 172421)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2014-08-12 00:36:33 UTC (rev 172422)
@@ -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: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (172421 => 172422)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2014-08-12 00:13:35 UTC (rev 172421)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2014-08-12 00:36:33 UTC (rev 172422)
@@ -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: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (172421 => 172422)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2014-08-12 00:13:35 UTC (rev 172421)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2014-08-12 00:36:33 UTC (rev 172422)
@@ -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()
@@ -712,6 +715,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)
@@ -774,6 +795,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()]);