Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Promote WKWebView media playback SPI to API
https://bugs.webkit.org/show_bug.cgi?id=217335 <rdar://problem/63406100> Reviewed by Jer Noble. Source/WebCore: Change stopAllMediaPlayback to be more aptly named pauseAllMediaPlayback because it is possible to resume playing media after this is called. 'Stop' implies more permanence. Add a function to the Document and Page objects to see if media playback exists, is paused, or is suspended to determine media playback state. * dom/Document.cpp: (WebCore::Document::~Document): (WebCore::Document::mediaPlaybackExists): (WebCore::Document::mediaPlaybackIsPaused): (WebCore::Document::pauseAllMediaPlayback): (WebCore::Document::stopAllMediaPlayback): Deleted. * dom/Document.h: * page/Page.cpp: (WebCore::Page::mediaPlaybackExists): (WebCore::Page::mediaPlaybackIsPaused): (WebCore::Page::pauseAllMediaPlayback): (WebCore::Page::stopAllMediaPlayback): Deleted. * page/Page.h: * platform/audio/PlatformMediaSessionManager.cpp: (WebCore::PlatformMediaSessionManager::pauseAllMediaPlaybackForDocument): (WebCore::PlatformMediaSessionManager::mediaPlaybackIsPaused): (WebCore::PlatformMediaSessionManager::stopAllMediaPlaybackForDocument): Deleted. * platform/audio/PlatformMediaSessionManager.h: Source/WebKit: Currently the only way to interact with video in WKWebView is by injecting JavaScript into a page. It would be useful to promote various media playback SPI to API to make this easier for clients, including adding completion handlers to the new API calls. Along with this, we should add new API to check for media playback state. This patch keeps the SPI around for compatibility. * Shared/API/Cocoa/WebKit.h: * Shared/MediaPlaybackState.h: Added. * UIProcess/API/Cocoa/WKMediaPlaybackState.h: Added. * UIProcess/API/Cocoa/WKWebView.h: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView closeAllMediaPresentations]): (-[WKWebView pauseAllMediaPlayback:]): (-[WKWebView suspendAllMediaPlayback:]): (-[WKWebView resumeAllMediaPlayback:]): (toWKMediaPlaybackState): (-[WKWebView requestMediaPlaybackState:]): (-[WKWebView _closeAllMediaPresentations]): (-[WKWebView _stopAllMediaPlayback]): (-[WKWebView _suspendAllMediaPlayback]): (-[WKWebView _resumeAllMediaPlayback]): * UIProcess/ios/fullscreen/WKFullScreenViewController.mm: (-[WKFullScreenViewController _showPhishingAlert]): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::requestMediaPlaybackState): (WebKit::WebPageProxy::pauseAllMediaPlayback): (WebKit::WebPageProxy::suspendAllMediaPlayback): (WebKit::WebPageProxy::resumeAllMediaPlayback): (WebKit::WebPageProxy::stopAllMediaPlayback): Deleted. * UIProcess/WebPageProxy.h: * WebKit.xcodeproj/project.pbxproj: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::requestMediaPlaybackState): (WebKit::WebPage::pauseAllMediaPlayback): (WebKit::WebPage::suspendAllMediaPlayback): (WebKit::WebPage::resumeAllMediaPlayback): (WebKit::WebPage::stopAllMediaPlayback): Deleted. * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Tools: Add API testing coverage for new API. Also converted testing to use the new API instead of SPI. * TestWebKitAPI/Tests/WebKitCocoa/StopSuspendResumeAllMedia.mm: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/230299@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268268 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
22 changed files
with
557 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2020 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace WebKit { | ||
|
||
enum class MediaPlaybackState : uint8_t { | ||
NoMediaPlayback, | ||
MediaPlaybackPaused, | ||
MediaPlaybackSuspended, | ||
MediaPlaybackPlaying | ||
}; | ||
|
||
} // namespace WebKit | ||
|
||
namespace WTF { | ||
|
||
template<> struct EnumTraits<WebKit::MediaPlaybackState> { | ||
using values = EnumValues< | ||
WebKit::MediaPlaybackState, | ||
WebKit::MediaPlaybackState::NoMediaPlayback, | ||
WebKit::MediaPlaybackState::MediaPlaybackPaused, | ||
WebKit::MediaPlaybackState::MediaPlaybackSuspended, | ||
WebKit::MediaPlaybackState::MediaPlaybackPlaying | ||
>; | ||
}; | ||
|
||
} // namespace WTF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2020 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <WebKit/WKFoundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef NS_ENUM(NSUInteger, WKMediaPlaybackState) { | ||
WKMediaPlaybackStateNone, | ||
WKMediaPlaybackStatePaused, | ||
WKMediaPlaybackStateSuspended, | ||
WKMediaPlaybackStatePlaying | ||
} WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.