Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (220388 => 220389)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-08-08 06:43:25 UTC (rev 220388)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-08-08 07:29:22 UTC (rev 220389)
@@ -1,3 +1,28 @@
+2017-08-08 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r220247. rdar://problem/33754443
+
+ 2017-08-03 Jer Noble <jer.no...@apple.com>
+
+ [EME][Mac] SecureStop left on disk in Private Browsing mode.
+ https://bugs.webkit.org/show_bug.cgi?id=175162
+
+ Reviewed by Eric Carlson.
+
+ Return an empty string from mediaKeysStorageDirectory() when the page indicates that storage should
+ be ephemeral(). Previously, an empty string in this case would be treated as an error. Instead, treat
+ an empty string as valid, and do not try to store or retrieve session information to disk in that case.
+
+ * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
+ (WebCore::WebKitMediaKeySession::mediaKeysStorageDirectory const):
+ * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm:
+ (WebCore::CDMSessionAVContentKeySession::releaseKeys):
+ (WebCore::CDMSessionAVContentKeySession::update):
+ (WebCore::CDMSessionAVContentKeySession::generateKeyReleaseMessage):
+ (WebCore::CDMSessionAVContentKeySession::contentKeySession):
+ * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
+ (WebCore::CDMSessionMediaSourceAVFObjC::storagePath const):
+
2017-08-07 Jason Marcell <jmarc...@apple.com>
Cherry-pick r220163. rdar://problem/33711032
Modified: branches/safari-604-branch/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp (220388 => 220389)
--- branches/safari-604-branch/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp 2017-08-08 06:43:25 UTC (rev 220388)
+++ branches/safari-604-branch/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp 2017-08-08 07:29:22 UTC (rev 220389)
@@ -32,6 +32,7 @@
#include "EventNames.h"
#include "ExceptionCode.h"
#include "FileSystem.h"
+#include "Page.h"
#include "SecurityOriginData.h"
#include "Settings.h"
#include "WebKitMediaKeyError.h"
@@ -223,6 +224,10 @@
if (!document)
return emptyString();
+ auto* page = document->page();
+ if (!page || page->usesEphemeralSession())
+ return emptyString();
+
auto storageDirectory = document->settings().mediaKeysStorageDirectory();
if (storageDirectory.isEmpty())
return emptyString();
Modified: branches/safari-604-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm (220388 => 220389)
--- branches/safari-604-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm 2017-08-08 06:43:25 UTC (rev 220388)
+++ branches/safari-604-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm 2017-08-08 07:29:22 UTC (rev 220389)
@@ -45,8 +45,12 @@
SOFT_LINK_CLASS(AVFoundation, AVStreamDataParser);
SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVContentKeySession);
SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVContentKeyRequestProtocolVersionsKey, NSString *)
+SOFT_LINK_CONSTANT_MAY_FAIL(AVFoundation, AVContentKeySystemFairPlayStreaming, NSString *)
+typedef NSString *AVContentKeySystem;
+
@interface AVContentKeySession : NSObject
++ (instancetype)contentKeySessionWithKeySystem:(AVContentKeySystem)keySystem;
- (instancetype)initWithStorageDirectoryAtURL:(NSURL *)storageURL;
@property (assign) id delegate;
- (void)addStreamDataParser:(AVStreamDataParser *)streamDataParser;
@@ -191,8 +195,12 @@
if (![getAVContentKeySessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)])
return;
+ auto storagePath = this->storagePath();
+ if (storagePath.isEmpty())
+ return;
+
RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
- NSArray* expiredSessions = [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath()]];
+ NSArray* expiredSessions = [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]];
for (NSData* expiredSessionData in expiredSessions) {
NSDictionary *expiredSession = [NSPropertyListSerialization propertyListWithData:expiredSessionData options:kCFPropertyListImmutable format:nullptr error:nullptr];
NSString *playbackSessionIdValue = (NSString *)[expiredSession objectForKey:PlaybackSessionIdKey];
@@ -239,7 +247,8 @@
if (isEqual(key, "acknowledged")) {
LOG(Media, "CDMSessionAVContentKeySession::update(%p) - acknowleding secure stop message", this);
- if (!m_expiredSession) {
+ String storagePath = this->storagePath();
+ if (!m_expiredSession || storagePath.isEmpty()) {
errorCode = MediaPlayer::InvalidPlayerState;
return false;
}
@@ -247,7 +256,7 @@
RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
if ([getAVContentKeySessionClass() respondsToSelector:@selector(removePendingExpiredSessionReports:withAppIdentifier:storageDirectoryAtURL:)])
- [getAVContentKeySessionClass() removePendingExpiredSessionReports:@[m_expiredSession.get()] withAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath()]];
+ [getAVContentKeySessionClass() removePendingExpiredSessionReports:@[m_expiredSession.get()] withAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]];
m_expiredSession = nullptr;
return true;
}
@@ -315,13 +324,14 @@
m_certificate = m_initData;
RetainPtr<NSData> certificateData = adoptNS([[NSData alloc] initWithBytes:m_certificate->data() length:m_certificate->length()]);
- if (![getAVContentKeySessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)]) {
+ String storagePath = this->storagePath();
+ if (storagePath.isEmpty() || ![getAVContentKeySessionClass() respondsToSelector:@selector(pendingExpiredSessionReportsWithAppIdentifier:storageDirectoryAtURL:)]) {
errorCode = MediaPlayer::KeySystemNotSupported;
systemCode = '!mor';
return nullptr;
}
- NSArray* expiredSessions = [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath()]];
+ NSArray* expiredSessions = [getAVContentKeySessionClass() pendingExpiredSessionReportsWithAppIdentifier:certificateData.get() storageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]];
if (![expiredSessions count]) {
LOG(Media, "CDMSessionAVContentKeySession::generateKeyReleaseMessage(%p) - no expired sessions found", this);
@@ -345,12 +355,16 @@
AVContentKeySession* CDMSessionAVContentKeySession::contentKeySession()
{
- if (!m_contentKeySession) {
+ if (m_contentKeySession)
+ return m_contentKeySession.get();
- String storagePath = this->storagePath();
- if (storagePath.isEmpty())
+ String storagePath = this->storagePath();
+ if (storagePath.isEmpty()) {
+ if (![getAVContentKeySessionClass() respondsToSelector:@selector(contentKeySessionWithKeySystem:)] || !canLoadAVContentKeySystemFairPlayStreaming())
return nil;
+ m_contentKeySession = [getAVContentKeySessionClass() contentKeySessionWithKeySystem:getAVContentKeySystemFairPlayStreaming()];
+ } else {
String storageDirectory = directoryName(storagePath);
if (!fileExists(storageDirectory)) {
@@ -359,9 +373,9 @@
}
m_contentKeySession = adoptNS([allocAVContentKeySessionInstance() initWithStorageDirectoryAtURL:[NSURL fileURLWithPath:storagePath]]);
- m_contentKeySession.get().delegate = m_contentKeySessionDelegate.get();
}
+ m_contentKeySession.get().delegate = m_contentKeySessionDelegate.get();
return m_contentKeySession.get();
}
Modified: branches/safari-604-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (220388 => 220389)
--- branches/safari-604-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm 2017-08-08 06:43:25 UTC (rev 220388)
+++ branches/safari-604-branch/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm 2017-08-08 07:29:22 UTC (rev 220389)
@@ -98,7 +98,14 @@
String CDMSessionMediaSourceAVFObjC::storagePath() const
{
- return m_client ? pathByAppendingComponent(m_client->mediaKeysStorageDirectory(), "SecureStop.plist") : emptyString();
+ if (!m_client)
+ return emptyString();
+
+ String storageDirectory = m_client->mediaKeysStorageDirectory();
+ if (storageDirectory.isEmpty())
+ return emptyString();
+
+ return pathByAppendingComponent(storageDirectory, "SecureStop.plist");
}
}