Diff
Modified: trunk/Source/WebCore/ChangeLog (224056 => 224057)
--- trunk/Source/WebCore/ChangeLog 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/ChangeLog 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,3 +1,26 @@
+2017-10-26 Eric Carlson <[email protected]>
+
+ NowPlayingInfo should contain a unique identifier
+ https://bugs.webkit.org/show_bug.cgi?id=178872
+
+ Reviewed by Jer Noble.
+
+ Updated TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm.
+
+ * platform/audio/PlatformMediaSessionManager.h:
+ (WebCore::PlatformMediaSessionManager::lastUpdatedNowPlayingInfoUniqueIdentifier const): New.
+
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Ditto.
+
+ * platform/audio/mac/MediaSessionManagerMac.h:
+ * platform/audio/mac/MediaSessionManagerMac.mm:
+ (WebCore::MediaSessionManagerMac::updateNowPlayingInfo): Ditto. Don't leak CFString.
+
+ * platform/mac/MediaRemoteSoftLink.cpp: Softlink kMRMediaRemoteNowPlayingInfoUniqueIdentifier.
+ * platform/mac/MediaRemoteSoftLink.h:
+
2017-10-26 Keith Miller <[email protected]>
Unreviewed, iOS build fix.
Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (224056 => 224057)
--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -60,6 +60,7 @@
WEBCORE_EXPORT virtual String lastUpdatedNowPlayingTitle() const { return emptyString(); }
WEBCORE_EXPORT virtual double lastUpdatedNowPlayingDuration() const { return NAN; }
WEBCORE_EXPORT virtual double lastUpdatedNowPlayingElapsedTime() const { return NAN; }
+ WEBCORE_EXPORT virtual uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const { return 0; }
bool willIgnoreSystemInterruptions() const { return m_willIgnoreSystemInterruptions; }
void setWillIgnoreSystemInterruptions(bool ignore) { m_willIgnoreSystemInterruptions = ignore; }
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (224056 => 224057)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -72,6 +72,7 @@
String lastUpdatedNowPlayingTitle() const final { return m_reportedTitle; }
double lastUpdatedNowPlayingDuration() const final { return m_reportedDuration; }
double lastUpdatedNowPlayingElapsedTime() const final { return m_reportedCurrentTime; }
+ uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
PlatformMediaSession* nowPlayingEligibleSession();
@@ -79,6 +80,7 @@
double m_reportedRate { 0 };
double m_reportedDuration { 0 };
double m_reportedCurrentTime { 0 };
+ uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 };
String m_reportedTitle;
bool m_nowPlayingActive { false };
};
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (224056 => 224057)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -79,13 +79,14 @@
SOFT_LINK_POINTER(MediaPlayer, MPNowPlayingInfoPropertyElapsedPlaybackTime, NSString *)
SOFT_LINK_POINTER(MediaPlayer, MPNowPlayingInfoPropertyPlaybackRate, NSString *)
SOFT_LINK_POINTER(MediaPlayer, MPVolumeViewWirelessRoutesAvailableDidChangeNotification, NSString *)
+SOFT_LINK_POINTER(MediaPlayer, kMRMediaRemoteNowPlayingInfoUniqueIdentifier, NSString *)
-
#define MPMediaItemPropertyTitle getMPMediaItemPropertyTitle()
#define MPMediaItemPropertyPlaybackDuration getMPMediaItemPropertyPlaybackDuration()
#define MPNowPlayingInfoPropertyElapsedPlaybackTime getMPNowPlayingInfoPropertyElapsedPlaybackTime()
#define MPNowPlayingInfoPropertyPlaybackRate getMPNowPlayingInfoPropertyPlaybackRate()
#define MPVolumeViewWirelessRoutesAvailableDidChangeNotification getMPVolumeViewWirelessRoutesAvailableDidChangeNotification()
+#define kMRMediaRemoteNowPlayingInfoUniqueIdentifier getkMRMediaRemoteNowPlayingInfoUniqueIdentifier()
WEBCORE_EXPORT NSString* WebUIApplicationWillResignActiveNotification = @"WebUIApplicationWillResignActiveNotification";
WEBCORE_EXPORT NSString* WebUIApplicationWillEnterForegroundNotification = @"WebUIApplicationWillEnterForegroundNotification";
@@ -270,6 +271,7 @@
if (std::isfinite(duration) && duration != MediaPlayer::invalidTime())
info.get()[MPMediaItemPropertyPlaybackDuration] = @(duration);
info.get()[MPNowPlayingInfoPropertyPlaybackRate] = @(rate);
+ info.get()[kMRMediaRemoteNowPlayingInfoUniqueIdentifier] = @(title.existingHash());
if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime())
info.get()[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(currentTime);
Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h (224056 => 224057)
--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -36,10 +36,11 @@
public:
virtual ~MediaSessionManagerMac();
- bool hasActiveNowPlayingSession() const override { return m_nowPlayingActive; }
- String lastUpdatedNowPlayingTitle() const override { return m_lastUpdatedNowPlayingTitle; }
- double lastUpdatedNowPlayingDuration() const override { return m_lastUpdatedNowPlayingDuration; }
- double lastUpdatedNowPlayingElapsedTime() const override { return m_lastUpdatedNowPlayingElapsedTime; }
+ bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
+ String lastUpdatedNowPlayingTitle() const final { return m_lastUpdatedNowPlayingTitle; }
+ double lastUpdatedNowPlayingDuration() const final { return m_lastUpdatedNowPlayingDuration; }
+ double lastUpdatedNowPlayingElapsedTime() const final { return m_lastUpdatedNowPlayingElapsedTime; }
+ uint64_t lastUpdatedNowPlayingInfoUniqueIdentifier() const final { return m_lastUpdatedNowPlayingInfoUniqueIdentifier; }
private:
friend class PlatformMediaSessionManager;
@@ -65,6 +66,7 @@
String m_lastUpdatedNowPlayingTitle;
double m_lastUpdatedNowPlayingDuration { NAN };
double m_lastUpdatedNowPlayingElapsedTime { NAN };
+ uint64_t m_lastUpdatedNowPlayingInfoUniqueIdentifier { 0 };
GenericTaskQueue<Timer> m_nowPlayingUpdateTaskQueue;
};
Modified: trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm (224056 => 224057)
--- trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -141,11 +141,13 @@
m_lastUpdatedNowPlayingTitle = emptyString();
m_lastUpdatedNowPlayingDuration = NAN;
m_lastUpdatedNowPlayingElapsedTime = NAN;
+ m_lastUpdatedNowPlayingInfoUniqueIdentifier = 0;
MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(MRMediaRemoteGetLocalOrigin(), kMRPlaybackStateStopped, dispatch_get_main_queue(), ^(MRMediaRemoteError error) {
#if LOG_DISABLED
UNUSED_PARAM(error);
#else
- LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);
+ if (error)
+ LOG(Media, "MediaSessionManagerMac::updateNowPlayingInfo - MRMediaRemoteSetNowPlayingApplicationPlaybackStateForOrigin(stopped) failed with error %ud", error);
#endif
});
@@ -173,9 +175,13 @@
m_lastUpdatedNowPlayingDuration = duration;
}
- auto cfRate = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &rate);
- CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoPlaybackRate, cfRate);
+ auto cfRate = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &rate));
+ CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoPlaybackRate, cfRate.get());
+ m_lastUpdatedNowPlayingInfoUniqueIdentifier = title.existingHash();
+ auto cfIdentifier = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberLongLongType, &m_lastUpdatedNowPlayingInfoUniqueIdentifier));
+ CFDictionarySetValue(info.get(), kMRMediaRemoteNowPlayingInfoUniqueIdentifier, cfIdentifier.get());
+
double currentTime = currentSession->currentTime();
if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime() && currentSession->supportsSeeking()) {
auto cfCurrentTime = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, ¤tTime));
Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp (224056 => 224057)
--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.cpp 2017-10-26 22:44:18 UTC (rev 224057)
@@ -50,6 +50,7 @@
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoElapsedTime, CFStringRef);
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoPlaybackRate, CFStringRef);
SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteOptionPlaybackPosition, CFStringRef);
+SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoUniqueIdentifier, CFStringRef);
#endif // USE(MEDIAREMOTE)
Modified: trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h (224056 => 224057)
--- trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebCore/platform/mac/MediaRemoteSoftLink.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -68,6 +68,8 @@
#define kMRMediaRemoteNowPlayingInfoPlaybackRate get_MediaRemote_kMRMediaRemoteNowPlayingInfoPlaybackRate()
SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteOptionPlaybackPosition, CFStringRef);
#define kMRMediaRemoteOptionPlaybackPosition get_MediaRemote_kMRMediaRemoteOptionPlaybackPosition()
+SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, MediaRemote, kMRMediaRemoteNowPlayingInfoUniqueIdentifier, CFStringRef);
+#define kMRMediaRemoteNowPlayingInfoUniqueIdentifier get_MediaRemote_kMRMediaRemoteNowPlayingInfoUniqueIdentifier()
#endif // USE(MEDIAREMOTE)
Modified: trunk/Source/WebKit/ChangeLog (224056 => 224057)
--- trunk/Source/WebKit/ChangeLog 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/ChangeLog 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,3 +1,37 @@
+2017-10-26 Eric Carlson <[email protected]>
+
+ NowPlayingInfo should contain a unique identifier
+ https://bugs.webkit.org/show_bug.cgi?id=178872
+
+ Reviewed by Jer Noble.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _requestActiveNowPlayingSessionInfo:]): Take a completion handler.
+ (-[WKWebView _requestActiveNowPlayingSessionInfo]): Deleted.
+ (-[WKWebView _handleActiveNowPlayingSessionInfoResponse:title:duration:elapsedTime:]): Deleted.
+ * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+ * UIProcess/PageClient.h:
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::requestActiveNowPlayingSessionInfo): Ditto.
+ (WebKit::WebPageProxy::nowPlayingInfoCallback): Lookup and call completion handler.
+ (WebKit::WebPageProxy::handleActiveNowPlayingSessionInfoResponse const): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::handleActiveNowPlayingSessionInfoResponse): Deleted.
+
+ * UIProcess/mac/PageClientImplMac.h:
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::handleActiveNowPlayingSessionInfoResponse): Deleted.
+
+ * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+ (WebKit::WebPage::requestActiveNowPlayingSessionInfo): Take callback ID. Pass unique ID.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
2017-10-26 Andy Estes <[email protected]>
[Payment Request] Enable Payment Request whenever Apple Pay is enabled
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -5936,15 +5936,19 @@
#endif // PLATFORM(MAC)
-- (void)_requestActiveNowPlayingSessionInfo
+- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, NSString*, double, double, NSInteger))callback
{
- if (_page)
- _page->requestActiveNowPlayingSessionInfo();
-}
+ if (!_page) {
+ callback(NO, @"", std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), 0);
+ return;
+ }
-- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime
-{
- // Overridden by subclasses.
+ auto handler = makeBlockPtr(callback);
+ auto localCallback = WebKit::NowPlayingInfoCallback::create([handler](bool active, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackBase::Error) {
+ handler(active, title, duration, elapsedTime, uniqueIdentifier);
+ });
+
+ _page->requestActiveNowPlayingSessionInfo(WTFMove(localCallback));
}
- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -433,8 +433,7 @@
- (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(10.12.3));
#endif
-- (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
-- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
+- (void)_requestActiveNowPlayingSessionInfo:(void(^)(BOOL, NSString*, double, double, NSInteger))callback WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_MAC_TBA));
- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(10.3));
- (CGFloat)_pageScale WK_API_AVAILABLE(ios(10.3));
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -279,10 +279,6 @@
virtual void setEditableElementIsFocused(bool) = 0;
#endif // PLATFORM(MAC)
-#if PLATFORM(COCOA)
- virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) = 0;
-#endif
-
#if PLATFORM(IOS)
virtual void commitPotentialTapFailed() = 0;
virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) = 0;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2017-10-26 22:44:18 UTC (rev 224057)
@@ -6712,14 +6712,28 @@
#endif
#if PLATFORM(COCOA)
-void WebPageProxy::requestActiveNowPlayingSessionInfo()
+void WebPageProxy::requestActiveNowPlayingSessionInfo(Ref<NowPlayingInfoCallback>&& callback)
{
- m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), m_pageID);
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ auto callbackID = callback->callbackID();
+ m_callbacks.put(WTFMove(callback));
+
+ m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(callbackID), m_pageID);
}
-void WebPageProxy::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const
+void WebPageProxy::nowPlayingInfoCallback(bool hasActiveSession, const String& title, double duration, double elapsedTime, uint64_t uniqueIdentifier, CallbackID callbackID)
{
- m_pageClient.handleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime);
+ auto callback = m_callbacks.take<NowPlayingInfoCallback>(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallbackWithReturnValue(hasActiveSession, title, duration, elapsedTime, uniqueIdentifier);
}
#endif
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -276,6 +276,7 @@
#if PLATFORM(COCOA)
typedef GenericCallback<const WebCore::MachSendRight&> MachSendRightCallback;
+typedef GenericCallback<bool, String, double, double, uint64_t> NowPlayingInfoCallback;
#endif
class WebPageProxy : public API::ObjectImpl<API::Object::Type::Page>
@@ -1085,8 +1086,8 @@
#endif
#if PLATFORM(COCOA)
- void requestActiveNowPlayingSessionInfo();
- void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const;
+ void requestActiveNowPlayingSessionInfo(Ref<NowPlayingInfoCallback>&&);
+ void nowPlayingInfoCallback(bool, const String&, double, double, uint64_t, CallbackID);
#endif
#if ENABLE(MEDIA_SESSION)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2017-10-26 22:44:18 UTC (rev 224057)
@@ -195,6 +195,7 @@
#endif
#if PLATFORM(COCOA)
MachSendRightCallback(WebCore::MachSendRight sendRight, WebKit::CallbackID callbackID)
+ NowPlayingInfoCallback(bool active, String title, double duration, double elapsedTime, uint64_t uniqueIdentifier, WebKit::CallbackID callbackID)
#endif
PageScaleFactorDidChange(double scaleFactor)
@@ -491,10 +492,6 @@
DidHandleAcceptedCandidate()
#endif
-#if PLATFORM(COCOA)
- HandleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, String title, double duration, double elapsedTime)
-#endif
-
SetIsUsingHighPerformanceWebGL(bool isUsingHighPerformanceWebGL)
StartURLSchemeTask(uint64_t handlerIdentifier, uint64_t taskIdentifier, WebCore::ResourceRequest request)
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -195,8 +195,6 @@
WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
- void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
-
#if USE(QUICK_LOOK)
void requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&&) override;
#endif
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -798,11 +798,6 @@
}
#endif
-void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
-{
- [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];
-}
-
#if USE(QUICK_LOOK)
void PageClientImpl::requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&& completionHandler)
{
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -210,7 +210,6 @@
void didFailLoadForMainFrame() override;
void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
void handleControlledElementIDResponse(const String&) override;
- void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (224056 => 224057)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -789,13 +789,6 @@
#endif
}
-void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
-{
-#if WK_API_ENABLED
- [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];
-#endif
-}
-
void PageClientImpl::didChangeBackgroundColor()
{
notImplemented();
Modified: trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (224056 => 224057)
--- trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,20 +41,22 @@
m_dataDetectionContext = loadParameters.dataDetectionContext;
}
-void WebPage::requestActiveNowPlayingSessionInfo()
+void WebPage::requestActiveNowPlayingSessionInfo(CallbackID callbackID)
{
bool hasActiveSession = false;
String title = emptyString();
double duration = NAN;
double elapsedTime = NAN;
+ uint64_t uniqueIdentifier = 0;
if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists()) {
hasActiveSession = sharedManager->hasActiveNowPlayingSession();
title = sharedManager->lastUpdatedNowPlayingTitle();
duration = sharedManager->lastUpdatedNowPlayingDuration();
elapsedTime = sharedManager->lastUpdatedNowPlayingElapsedTime();
+ uniqueIdentifier = sharedManager->lastUpdatedNowPlayingInfoUniqueIdentifier();
}
- send(Messages::WebPageProxy::HandleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime));
+ send(Messages::WebPageProxy::NowPlayingInfoCallback(hasActiveSession, title, duration, elapsedTime, uniqueIdentifier, callbackID));
}
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (224056 => 224057)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1263,7 +1263,7 @@
#endif
#if PLATFORM(COCOA)
- void requestActiveNowPlayingSessionInfo();
+ void requestActiveNowPlayingSessionInfo(CallbackID);
#endif
void setShouldDispatchFakeMouseMoveEvents(bool dispatch) { m_shouldDispatchFakeMouseMoveEvents = dispatch; }
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (224056 => 224057)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2017-10-26 22:44:18 UTC (rev 224057)
@@ -437,7 +437,7 @@
#endif
#if PLATFORM(COCOA)
- RequestActiveNowPlayingSessionInfo()
+ RequestActiveNowPlayingSessionInfo(WebKit::CallbackID callbackID)
#endif
SetShouldDispatchFakeMouseMoveEvents(bool shouldDispatchFakeMouseMoveEvents)
Modified: trunk/Tools/ChangeLog (224056 => 224057)
--- trunk/Tools/ChangeLog 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Tools/ChangeLog 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,17 @@
2017-10-26 Eric Carlson <[email protected]>
+ NowPlayingInfo should contain a unique identifier
+ https://bugs.webkit.org/show_bug.cgi?id=178872
+
+ Reviewed by Jer Noble.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm:
+ (-[NowPlayingTestWebView hasActiveNowPlayingSession]): Use completion handler.
+ (TestWebKitAPI::TEST): Cleanup tests. Use new API.
+ (-[NowPlayingTestWebView waitForNowPlayingInfoToChange]): Deleted.
+
+2017-10-26 Eric Carlson <[email protected]>
+
[MediaStream] Clear cached gUM prompt state
https://bugs.webkit.org/show_bug.cgi?id=178754
<rdar://problem/32742356>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm (224056 => 224057)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm 2017-10-26 22:42:41 UTC (rev 224056)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NowPlayingControlsTests.mm 2017-10-26 22:44:18 UTC (rev 224057)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -38,6 +38,7 @@
@property (readonly) NSString *lastUpdatedTitle;
@property (readonly) double lastUpdatedDuration;
@property (readonly) double lastUpdatedElapsedTime;
+@property (readonly) NSInteger lastUniqueIdentifier;
@end
@implementation NowPlayingTestWebView {
@@ -47,7 +48,18 @@
- (BOOL)hasActiveNowPlayingSession
{
_receivedNowPlayingInfoResponse = false;
- [self _requestActiveNowPlayingSessionInfo];
+
+ auto completionHandler = [retainedSelf = retainPtr(self), self](BOOL active, NSString *title, double duration, double elapsedTime, NSInteger uniqueIdentifier) {
+ _hasActiveNowPlayingSession = active;
+ _lastUpdatedTitle = [title copy];
+ _lastUpdatedDuration = duration;
+ _lastUniqueIdentifier = uniqueIdentifier;
+
+ _receivedNowPlayingInfoResponse = true;
+ };
+
+ [self _requestActiveNowPlayingSessionInfo:completionHandler];
+
TestWebKitAPI::Util::run(&_receivedNowPlayingInfoResponse);
return _hasActiveNowPlayingSession;
@@ -62,28 +74,6 @@
}
}
-- (void)waitForNowPlayingInfoToChange
-{
- BOOL initialHasActiveNowPlayingSession = self.hasActiveNowPlayingSession;
- NSString *initialTitle = self.lastUpdatedTitle;
- double initialDuration = self.lastUpdatedDuration;
- double initialElapsedTime = self.lastUpdatedElapsedTime;
- while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
- BOOL currentlyHasActiveNowPlayingSession = self.hasActiveNowPlayingSession;
- if (initialHasActiveNowPlayingSession != currentlyHasActiveNowPlayingSession)
- break;
-
- if (initialDuration != self.lastUpdatedDuration)
- break;
-
- if (initialElapsedTime != self.lastUpdatedElapsedTime)
- break;
-
- if (![initialTitle isEqualToString:self.lastUpdatedTitle] && self.lastUpdatedTitle != initialTitle)
- break;
- }
-}
-
- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime
{
_hasActiveNowPlayingSession = hasActiveSession;
@@ -111,17 +101,17 @@
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration];
+ auto webView = adoptNS([[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
[webView loadTestPageNamed:@"large-video-test-now-playing"];
[webView waitForMessage:@"playing"];
[webView setWindowVisible:YES];
- [webView.window makeKeyWindow];
+ [webView.get().window makeKeyWindow];
[webView expectHasActiveNowPlayingSession:NO];
- ASSERT_STREQ("foo", webView.lastUpdatedTitle.UTF8String);
- ASSERT_EQ(10, webView.lastUpdatedDuration);
- ASSERT_GE(webView.lastUpdatedElapsedTime, 0);
+ ASSERT_STREQ("foo", webView.get().lastUpdatedTitle.UTF8String);
+ ASSERT_EQ(10, webView.get().lastUpdatedDuration);
+ ASSERT_GE(webView.get().lastUpdatedElapsedTime, 0);
}
TEST(NowPlayingControlsTests, NowPlayingControlsShowForBackgroundPage)
@@ -128,17 +118,17 @@
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration];
+ auto webView = adoptNS([[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
[webView loadTestPageNamed:@"large-video-test-now-playing"];
[webView waitForMessage:@"playing"];
[webView setWindowVisible:NO];
- [webView.window resignKeyWindow];
+ [webView.get().window resignKeyWindow];
[webView expectHasActiveNowPlayingSession:YES];
- ASSERT_STREQ("foo", webView.lastUpdatedTitle.UTF8String);
- ASSERT_EQ(10, webView.lastUpdatedDuration);
- ASSERT_GE(webView.lastUpdatedElapsedTime, 0);
+ ASSERT_STREQ("foo", webView.get().lastUpdatedTitle.UTF8String);
+ ASSERT_EQ(10, webView.get().lastUpdatedDuration);
+ ASSERT_GE(webView.get().lastUpdatedElapsedTime, 0);
}
TEST(NowPlayingControlsTests, NowPlayingControlsHideAfterShowingKeepsSessionActive)
@@ -145,23 +135,23 @@
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration];
+ auto webView = adoptNS([[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration]);
[webView loadTestPageNamed:@"large-video-test-now-playing"];
[webView waitForMessage:@"playing"];
[webView setWindowVisible:NO];
- [webView.window resignKeyWindow];
+ [webView.get().window resignKeyWindow];
[webView expectHasActiveNowPlayingSession:YES];
[webView setWindowVisible:YES];
- [webView.window makeKeyWindow];
+ [webView.get().window makeKeyWindow];
[webView expectHasActiveNowPlayingSession:NO];
- ASSERT_STREQ("foo", webView.lastUpdatedTitle.UTF8String);
- ASSERT_EQ(10, webView.lastUpdatedDuration);
- ASSERT_GE(webView.lastUpdatedElapsedTime, 0);
+ ASSERT_STREQ("foo", webView.get().lastUpdatedTitle.UTF8String);
+ ASSERT_EQ(10, webView.get().lastUpdatedDuration);
+ ASSERT_GE(webView.get().lastUpdatedElapsedTime, 0);
}
TEST(NowPlayingControlsTests, NowPlayingControlsClearInfoAfterSessionIsNoLongerValid)
@@ -168,19 +158,41 @@
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 480, 320) configuration:configuration];
+ auto webView = adoptNS([[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 480, 320) configuration:configuration]);
[webView loadTestPageNamed:@"large-video-test-now-playing"];
[webView waitForMessage:@"playing"];
+ BOOL initialHasActiveNowPlayingSession = webView.get().hasActiveNowPlayingSession;
+ NSString *initialTitle = webView.get().lastUpdatedTitle;
+ double initialDuration = webView.get().lastUpdatedDuration;
+ double initialElapsedTime = webView.get().lastUpdatedElapsedTime;
+ NSInteger initialUniqueIdentifier = webView.get().lastUniqueIdentifier;
+
[webView stringByEvaluatingJavaScript:@"document.querySelector('video').muted = true"];
[webView setWindowVisible:NO];
- [webView.window resignKeyWindow];
+ [webView.get().window resignKeyWindow];
- [webView waitForNowPlayingInfoToChange];
+ while ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantPast]]) {
+ if (initialHasActiveNowPlayingSession != webView.get().hasActiveNowPlayingSession)
+ break;
- ASSERT_STREQ("", webView.lastUpdatedTitle.UTF8String);
- ASSERT_TRUE(isnan(webView.lastUpdatedDuration));
- ASSERT_TRUE(isnan(webView.lastUpdatedElapsedTime));
+ if (initialUniqueIdentifier != webView.get().lastUniqueIdentifier)
+ break;
+
+ if (initialDuration != webView.get().lastUpdatedDuration)
+ break;
+
+ if (initialElapsedTime != webView.get().lastUpdatedElapsedTime)
+ break;
+
+ if (![initialTitle isEqualToString:webView.get().lastUpdatedTitle])
+ break;
+ }
+
+ ASSERT_STREQ("", webView.get().lastUpdatedTitle.UTF8String);
+ ASSERT_TRUE(isnan(webView.get().lastUpdatedDuration));
+ ASSERT_TRUE(isnan(webView.get().lastUpdatedElapsedTime));
+ ASSERT_TRUE(!webView.get().lastUniqueIdentifier);
}
#endif // PLATFORM(MAC)
@@ -190,14 +202,14 @@
{
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
- NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 480, 320) configuration:configuration];
+ auto webView = adoptNS([[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 480, 320) configuration:configuration]);
[webView loadTestPageNamed:@"large-video-test-now-playing"];
[webView waitForMessage:@"playing"];
[webView expectHasActiveNowPlayingSession:YES];
- ASSERT_STREQ("foo", webView.lastUpdatedTitle.UTF8String);
- ASSERT_EQ(10, webView.lastUpdatedDuration);
- ASSERT_GE(webView.lastUpdatedElapsedTime, 0);
+ ASSERT_STREQ("foo", webView.get().lastUpdatedTitle.UTF8String);
+ ASSERT_EQ(10, webView.get().lastUpdatedDuration);
+ ASSERT_GE(webView.get().lastUpdatedElapsedTime, 0);
}
#endif