Diff
Modified: trunk/Source/WebCore/ChangeLog (273872 => 273873)
--- trunk/Source/WebCore/ChangeLog 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/ChangeLog 2021-03-04 05:59:26 UTC (rev 273873)
@@ -1,3 +1,27 @@
+2021-03-03 Jean-Yves Avenard <j...@apple.com>
+
+ Remove RemoteCommandListenerIOS in favor of a common RemoteCommandListenerCocoa
+ https://bugs.webkit.org/show_bug.cgi?id=222342
+ rdar://problem/74773837
+
+ Reviewed by Eric Carlson.
+
+ There is no change in behavior with this commit.
+
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/RemoteCommandListener.cpp:
+ (WebCore::RemoteCommandListener::resetCreationFunction):
+ * platform/cocoa/RemoteCommandListenerCocoa.h: Renamed from Source/WebCore/platform/mac/RemoteCommandListenerMac.h.
+ * platform/cocoa/RemoteCommandListenerCocoa.mm: Renamed from Source/WebCore/platform/mac/RemoteCommandListenerMac.mm.
+ (WebCore::RemoteCommandListenerCocoa::create):
+ (WebCore::RemoteCommandListenerCocoa::defaultCommands):
+ (WebCore::RemoteCommandListenerCocoa::updateSupportedCommands):
+ (WebCore::RemoteCommandListenerCocoa::RemoteCommandListenerCocoa):
+ (WebCore::RemoteCommandListenerCocoa::~RemoteCommandListenerCocoa):
+ * platform/ios/RemoteCommandListenerIOS.h: Removed.
+ * platform/ios/RemoteCommandListenerIOS.mm: Removed.
+
2021-03-03 Alex Christensen <achristen...@webkit.org>
Limit HashTable entry size to 500 bytes
Modified: trunk/Source/WebCore/SourcesCocoa.txt (273872 => 273873)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-03-04 05:59:26 UTC (rev 273873)
@@ -251,6 +251,7 @@
platform/cocoa/PlatformPasteboardCocoa.mm
platform/cocoa/PlaybackSessionModelMediaElement.mm
platform/cocoa/PowerSourceNotifier.mm
+platform/cocoa/RemoteCommandListenerCocoa.mm
platform/cocoa/RuntimeApplicationChecksCocoa.mm
platform/cocoa/SearchPopupMenuCocoa.mm
platform/cocoa/SharedBufferCocoa.mm
@@ -452,7 +453,6 @@
platform/ios/PlaybackSessionInterfaceAVKit.mm @no-unify
platform/ios/PreviewConverterIOS.mm
platform/ios/QuickLook.mm
-platform/ios/RemoteCommandListenerIOS.mm
platform/ios/ScrollAnimatorIOS.mm
platform/ios/ScrollViewIOS.mm
platform/ios/ScrollbarThemeIOS.mm
@@ -500,7 +500,6 @@
platform/mac/PluginBlocklist.mm
platform/mac/PowerObserverMac.cpp
platform/mac/PublicSuffixMac.mm
-platform/mac/RemoteCommandListenerMac.mm
platform/mac/SSLKeyGeneratorMac.mm
platform/mac/ScrollAnimatorMac.mm @no-unify
platform/mac/ScrollController.mm
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (273872 => 273873)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-03-04 05:59:26 UTC (rev 273873)
@@ -1433,6 +1433,7 @@
510D4A37103165EE0049EA54 /* SocketStreamHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A31103165EE0049EA54 /* SocketStreamHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
510D4A38103165EE0049EA54 /* SocketStreamHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
5110FCFC1E03641D006F8D0B /* IDBCursorRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 5117F30E25E61020002A9F1E /* RemoteCommandListenerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 5117F30C25E6101F002A9F1E /* RemoteCommandListenerCocoa.h */; };
511EC1281C50AACA0032F983 /* IDBSerialization.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC1261C50AA570032F983 /* IDBSerialization.h */; };
511EC12C1C50ABBF0032F983 /* SQLiteIDBTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC12A1C50ABBA0032F983 /* SQLiteIDBTransaction.h */; };
511EC1301C50ABF50032F983 /* SQLiteIDBCursor.h in Headers */ = {isa = PBXBuildFile; fileRef = 511EC12E1C50ABEC0032F983 /* SQLiteIDBCursor.h */; };
@@ -4322,7 +4323,6 @@
CD83D36221122A210076E11C /* DeferrableTask.h in Headers */ = {isa = PBXBuildFile; fileRef = CD83D35A211110820076E11C /* DeferrableTask.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD8A7BBB197735FE00CBD643 /* AudioSourceProviderAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8A7BB9197735FE00CBD643 /* AudioSourceProviderAVFObjC.mm */; };
CD8A7BBC197735FE00CBD643 /* AudioSourceProviderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8A7BBA197735FE00CBD643 /* AudioSourceProviderAVFObjC.h */; settings = {ATTRIBUTES = (Private, ); }; };
- CD8ACA891D237AA200ECC59E /* RemoteCommandListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8ACA871D237AA200ECC59E /* RemoteCommandListenerMac.h */; };
CD8ACA8F1D23971900ECC59E /* MediaRemoteSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8ACA8D1D23971900ECC59E /* MediaRemoteSoftLink.h */; };
CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.mm */; };
CD8B5A43180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */; };
@@ -8569,6 +8569,8 @@
510D4A31103165EE0049EA54 /* SocketStreamHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandle.h; sourceTree = "<group>"; };
510D4A32103165EE0049EA54 /* SocketStreamHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStreamHandleClient.h; sourceTree = "<group>"; };
5110FCFB1E0362A5006F8D0B /* IDBCursorRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursorRecord.h; sourceTree = "<group>"; };
+ 5117F30A25E6101E002A9F1E /* RemoteCommandListenerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteCommandListenerCocoa.mm; sourceTree = "<group>"; };
+ 5117F30C25E6101F002A9F1E /* RemoteCommandListenerCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListenerCocoa.h; sourceTree = "<group>"; };
511EC1251C50AA570032F983 /* IDBSerialization.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBSerialization.cpp; sourceTree = "<group>"; };
511EC1261C50AA570032F983 /* IDBSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBSerialization.h; sourceTree = "<group>"; };
511EC1291C50ABBA0032F983 /* SQLiteIDBTransaction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteIDBTransaction.cpp; sourceTree = "<group>"; };
@@ -9698,7 +9700,6 @@
656D372B0ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NetscapePlugInStreamLoader.h; sourceTree = "<group>"; };
656D37300ADBA5DE00A4554D /* SubresourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SubresourceLoader.h; sourceTree = "<group>"; };
658436850AE01B7400E53753 /* FrameLoadRequest.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FrameLoadRequest.h; sourceTree = "<group>"; };
- 6593923909AE435C002C531F /* URLMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = URLMac.mm; sourceTree = "<group>"; };
659A7D120B6DB4D9001155B3 /* SubstituteData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SubstituteData.h; sourceTree = "<group>"; };
659DDC8009E198BA001BF3C6 /* JSDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocument.cpp; sourceTree = "<group>"; };
659DDC8109E198BA001BF3C6 /* JSDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSDocument.h; sourceTree = "<group>"; };
@@ -14811,8 +14812,6 @@
CD875A752411B79800B09F58 /* MediaSessionHelperIOS.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaSessionHelperIOS.mm; sourceTree = "<group>"; };
CD8A7BB9197735FE00CBD643 /* AudioSourceProviderAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioSourceProviderAVFObjC.mm; sourceTree = "<group>"; };
CD8A7BBA197735FE00CBD643 /* AudioSourceProviderAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioSourceProviderAVFObjC.h; sourceTree = "<group>"; };
- CD8ACA861D237AA200ECC59E /* RemoteCommandListenerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteCommandListenerMac.mm; sourceTree = "<group>"; };
- CD8ACA871D237AA200ECC59E /* RemoteCommandListenerMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListenerMac.h; sourceTree = "<group>"; };
CD8ACA8C1D23971900ECC59E /* MediaRemoteSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaRemoteSoftLink.mm; sourceTree = "<group>"; };
CD8ACA8D1D23971900ECC59E /* MediaRemoteSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaRemoteSoftLink.h; sourceTree = "<group>"; };
CD8B31A12379DC8300883FDE /* WebVideoContainerLayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebVideoContainerLayer.h; sourceTree = "<group>"; };
@@ -15096,8 +15095,6 @@
CDF994FF24C28136002EA062 /* VideoTrackPrivateWebM.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = VideoTrackPrivateWebM.cpp; sourceTree = "<group>"; };
CDF9950024C28149002EA062 /* AudioTrackPrivateWebM.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AudioTrackPrivateWebM.h; sourceTree = "<group>"; };
CDF9950124C28149002EA062 /* AudioTrackPrivateWebM.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AudioTrackPrivateWebM.cpp; sourceTree = "<group>"; };
- CDFC360118CA61630026E56F /* RemoteCommandListenerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListenerIOS.h; sourceTree = "<group>"; };
- CDFC360218CA61630026E56F /* RemoteCommandListenerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteCommandListenerIOS.mm; sourceTree = "<group>"; };
CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCommandListener.cpp; sourceTree = "<group>"; };
CDFC360418CA61C20026E56F /* RemoteCommandListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCommandListener.h; sourceTree = "<group>"; };
CDFD78BA2242C4FE00D7208A /* JSTextTrackCueGeneric.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTextTrackCueGeneric.h; sourceTree = "<group>"; };
@@ -22018,8 +22015,6 @@
4634592B1AC2271000ECB71C /* PowerObserverMac.cpp */,
46DBB64E1AB8C96F00D9A813 /* PowerObserverMac.h */,
0081FEFE16B0A2B6008AAA7A /* PublicSuffixMac.mm */,
- CD8ACA871D237AA200ECC59E /* RemoteCommandListenerMac.h */,
- CD8ACA861D237AA200ECC59E /* RemoteCommandListenerMac.mm */,
BCAE1FA512939DB7004CB026 /* ScrollAnimatorMac.h */,
BC51156D12B1749C00C96754 /* ScrollAnimatorMac.mm */,
BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */,
@@ -22035,7 +22030,6 @@
BCE659E50EA92FB2007E4533 /* ThemeMac.h */,
BCE659E80EA92FFA007E4533 /* ThemeMac.mm */,
51DF6D7F0B92A18E00C2DC85 /* ThreadCheck.mm */,
- 6593923909AE435C002C531F /* URLMac.mm */,
868160D3187669E70021E79D /* UserActivityMac.mm */,
A3AF9D84203256A3006CAD06 /* UserAgentMac.mm */,
83C45B8B1DC2B663008871BA /* ValidationBubbleMac.mm */,
@@ -24546,8 +24540,6 @@
A1C150771E3F2B3E0032C98C /* PreviewConverterIOS.mm */,
A15E31F11E0CB0AA004B371C /* QuickLook.h */,
A15E31F21E0CB0AA004B371C /* QuickLook.mm */,
- CDFC360118CA61630026E56F /* RemoteCommandListenerIOS.h */,
- CDFC360218CA61630026E56F /* RemoteCommandListenerIOS.mm */,
0F17747E1378B771009DA76A /* ScrollAnimatorIOS.h */,
0F17747F1378B772009DA76A /* ScrollAnimatorIOS.mm */,
44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */,
@@ -24709,6 +24701,8 @@
CDA29A0C1CBD9CFE00901CCF /* PlaybackSessionModelMediaElement.mm */,
CDC7470024BE267900C1868B /* PowerSourceNotifier.h */,
CDC7470124BE267900C1868B /* PowerSourceNotifier.mm */,
+ 5117F30C25E6101F002A9F1E /* RemoteCommandListenerCocoa.h */,
+ 5117F30A25E6101E002A9F1E /* RemoteCommandListenerCocoa.mm */,
465A8E781C8A24CE00E7D3E4 /* RuntimeApplicationChecksCocoa.mm */,
0E7058F31BC5CCD70045A507 /* SearchPopupMenuCocoa.h */,
0E7058ED1BC5BC190045A507 /* SearchPopupMenuCocoa.mm */,
@@ -34365,7 +34359,7 @@
51B914111FD2782D00EE2859 /* RegistrationStore.h in Headers */,
A578F43F1DE0B630003DFC6A /* RejectedPromiseTracker.h in Headers */,
CDFC360618CA61C20026E56F /* RemoteCommandListener.h in Headers */,
- CD8ACA891D237AA200ECC59E /* RemoteCommandListenerMac.h in Headers */,
+ 5117F30E25E61020002A9F1E /* RemoteCommandListenerCocoa.h in Headers */,
46B95199207D634D00A7D2DD /* RemoteDOMWindow.h in Headers */,
46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */,
7B90417025501142006EEB8C /* RemoteGraphicsContextGLProxyBase.h in Headers */,
Modified: trunk/Source/WebCore/platform/RemoteCommandListener.cpp (273872 => 273873)
--- trunk/Source/WebCore/platform/RemoteCommandListener.cpp 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/platform/RemoteCommandListener.cpp 2021-03-04 05:59:26 UTC (rev 273873)
@@ -26,14 +26,10 @@
#include "config.h"
#include "RemoteCommandListener.h"
-#if PLATFORM(MAC)
-#include "RemoteCommandListenerMac.h"
+#if PLATFORM(COCOA)
+#include "RemoteCommandListenerCocoa.h"
#endif
-#if PLATFORM(IOS_FAMILY)
-#include "RemoteCommandListenerIOS.h"
-#endif
-
namespace WebCore {
static RemoteCommandListener::CreationFunction& remoteCommandListenerCreationFunction()
@@ -50,10 +46,8 @@
void RemoteCommandListener::resetCreationFunction()
{
remoteCommandListenerCreationFunction() = [] (RemoteCommandListenerClient& client) {
-#if PLATFORM(MAC)
- return RemoteCommandListenerMac::create(client);
-#elif PLATFORM(IOS_FAMILY)
- return RemoteCommandListenerIOS::create(client);
+#if PLATFORM(COCOA)
+ return RemoteCommandListenerCocoa::create(client);
#else
return RemoteCommandListener::create(client);
#endif
Copied: trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.h (from rev 273872, trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h) (0 => 273873)
--- trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.h (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.h 2021-03-04 05:59:26 UTC (rev 273873)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016-2021 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
+
+#include "RemoteCommandListener.h"
+
+#if PLATFORM(COCOA)
+
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class RemoteCommandListenerCocoa : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerCocoa> {
+public:
+ static std::unique_ptr<RemoteCommandListenerCocoa> create(RemoteCommandListenerClient&);
+ RemoteCommandListenerCocoa(RemoteCommandListenerClient&);
+ virtual ~RemoteCommandListenerCocoa();
+
+private:
+ void updateSupportedCommands() final;
+
+ void* m_commandHandler { nullptr };
+
+ const RemoteCommandsSet& defaultCommands();
+ RemoteCommandsSet m_currentCommands;
+ bool m_supportsSeeking { false };
+};
+
+}
+
+#endif // PLATFORM(MAC)
Copied: trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.mm (from rev 273872, trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm) (0 => 273873)
--- trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.mm (rev 0)
+++ trunk/Source/WebCore/platform/cocoa/RemoteCommandListenerCocoa.mm 2021-03-04 05:59:26 UTC (rev 273873)
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2016-2021 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 "config.h"
+#import "RemoteCommandListenerCocoa.h"
+
+#if PLATFORM(COCOA)
+
+#import "Logging.h"
+#import <wtf/MainThread.h>
+
+#import "MediaRemoteSoftLink.h"
+
+namespace WebCore {
+
+static Optional<MRMediaRemoteCommand> mediaRemoteCommandForPlatformCommand(PlatformMediaSession::RemoteControlCommandType command)
+{
+ static const auto commandMap = makeNeverDestroyed([] {
+ using CommandToActionMap = HashMap<PlatformMediaSession::RemoteControlCommandType, MRMediaRemoteCommand, WTF::IntHash<PlatformMediaSession::RemoteControlCommandType>, WTF::StrongEnumHashTraits<PlatformMediaSession::RemoteControlCommandType>>;
+
+ return CommandToActionMap {
+ { PlatformMediaSession::PlayCommand, MRMediaRemoteCommandPlay },
+ { PlatformMediaSession::PauseCommand, MRMediaRemoteCommandPause },
+ { PlatformMediaSession::StopCommand, MRMediaRemoteCommandStop },
+ { PlatformMediaSession::TogglePlayPauseCommand, MRMediaRemoteCommandTogglePlayPause },
+ { PlatformMediaSession::BeginSeekingBackwardCommand, MRMediaRemoteCommandBeginRewind },
+ { PlatformMediaSession::EndSeekingBackwardCommand, MRMediaRemoteCommandEndRewind },
+ { PlatformMediaSession::BeginSeekingForwardCommand, MRMediaRemoteCommandBeginFastForward },
+ { PlatformMediaSession::EndSeekingForwardCommand, MRMediaRemoteCommandEndFastForward },
+ { PlatformMediaSession::SeekToPlaybackPositionCommand, MRMediaRemoteCommandSeekToPlaybackPosition },
+ { PlatformMediaSession::SkipForwardCommand, MRMediaRemoteCommandSkipForward },
+ { PlatformMediaSession::SkipBackwardCommand, MRMediaRemoteCommandSkipBackward },
+ { PlatformMediaSession::NextTrackCommand, MRMediaRemoteCommandNextTrack },
+ { PlatformMediaSession::PreviousTrackCommand, MRMediaRemoteCommandPreviousTrack },
+ };
+ }());
+
+ auto it = commandMap.get().find(command);
+ if (it != commandMap.get().end())
+ return { it->value };
+
+ return { };
+}
+
+std::unique_ptr<RemoteCommandListenerCocoa> RemoteCommandListenerCocoa::create(RemoteCommandListenerClient& client)
+{
+ return makeUnique<RemoteCommandListenerCocoa>(client);
+}
+
+const RemoteCommandListener::RemoteCommandsSet& RemoteCommandListenerCocoa::defaultCommands()
+{
+ static NeverDestroyed<RemoteCommandsSet> commands(std::initializer_list<PlatformMediaSession::RemoteControlCommandType> {
+ PlatformMediaSession::PlayCommand,
+ PlatformMediaSession::PauseCommand,
+ PlatformMediaSession::TogglePlayPauseCommand,
+ PlatformMediaSession::BeginSeekingForwardCommand,
+ PlatformMediaSession::EndSeekingForwardCommand,
+ PlatformMediaSession::BeginSeekingBackwardCommand,
+ PlatformMediaSession::EndSeekingBackwardCommand,
+ PlatformMediaSession::SeekToPlaybackPositionCommand,
+ PlatformMediaSession::SkipForwardCommand,
+ PlatformMediaSession::SkipBackwardCommand,
+ });
+
+ return commands;
+}
+
+static bool isSeekCommand(PlatformMediaSession::RemoteControlCommandType command)
+{
+ return command == PlatformMediaSession::SeekToPlaybackPositionCommand
+ || command == PlatformMediaSession::SkipForwardCommand
+ || command == PlatformMediaSession::SkipBackwardCommand
+ || command == PlatformMediaSession::BeginSeekingForwardCommand
+ || command == PlatformMediaSession::BeginSeekingBackwardCommand;
+}
+
+void RemoteCommandListenerCocoa::updateSupportedCommands()
+{
+ if (!isMediaRemoteFrameworkAvailable())
+ return;
+
+ auto& supportedCommands = !m_registeredCommands.isEmpty() ? m_registeredCommands : defaultCommands();
+ if (m_currentCommands == supportedCommands)
+ return;
+
+ auto commandInfoArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, supportedCommands.size(), &kCFTypeArrayCallBacks));
+ for (auto platformCommand : supportedCommands) {
+ if (isSeekCommand(platformCommand) && !m_supportsSeeking)
+ continue;
+
+ auto command = mediaRemoteCommandForPlatformCommand(platformCommand);
+ ASSERT(command);
+ if (!command)
+ continue;
+
+ auto commandInfo = adoptCF(MRMediaRemoteCommandInfoCreate(kCFAllocatorDefault));
+ MRMediaRemoteCommandInfoSetCommand(commandInfo.get(), command.value());
+ MRMediaRemoteCommandInfoSetEnabled(commandInfo.get(), true);
+ CFArrayAppendValue(commandInfoArray.get(), commandInfo.get());
+ }
+
+ MRMediaRemoteSetSupportedCommands(commandInfoArray.get(), MRMediaRemoteGetLocalOrigin(), nullptr, nullptr);
+ m_currentCommands = supportedCommands;
+}
+
+RemoteCommandListenerCocoa::RemoteCommandListenerCocoa(RemoteCommandListenerClient& client)
+ : RemoteCommandListener(client)
+{
+ if (!isMediaRemoteFrameworkAvailable())
+ return;
+
+ scheduleSupportedCommandsUpdate();
+
+ auto weakThis = makeWeakPtr(*this);
+ m_commandHandler = MRMediaRemoteAddAsyncCommandHandlerBlock(^(MRMediaRemoteCommand command, CFDictionaryRef options, void(^completion)(CFArrayRef)) {
+
+ LOG(Media, "RemoteCommandListenerCocoa::RemoteCommandListenerCocoa - received command %u", command);
+
+ PlatformMediaSession::RemoteControlCommandType platformCommand { PlatformMediaSession::NoCommand };
+ PlatformMediaSession::RemoteCommandArgument argument;
+ MRMediaRemoteCommandHandlerStatus status = MRMediaRemoteCommandHandlerStatusSuccess;
+
+ switch (command) {
+ case MRMediaRemoteCommandPlay:
+ platformCommand = PlatformMediaSession::PlayCommand;
+ break;
+ case MRMediaRemoteCommandPause:
+ platformCommand = PlatformMediaSession::PauseCommand;
+ break;
+ case MRMediaRemoteCommandStop:
+ platformCommand = PlatformMediaSession::StopCommand;
+ break;
+ case MRMediaRemoteCommandTogglePlayPause:
+ platformCommand = PlatformMediaSession::TogglePlayPauseCommand;
+ break;
+ case MRMediaRemoteCommandBeginFastForward:
+ platformCommand = PlatformMediaSession::BeginSeekingForwardCommand;
+ break;
+ case MRMediaRemoteCommandEndFastForward:
+ platformCommand = PlatformMediaSession::EndSeekingForwardCommand;
+ break;
+ case MRMediaRemoteCommandBeginRewind:
+ platformCommand = PlatformMediaSession::BeginSeekingBackwardCommand;
+ break;
+ case MRMediaRemoteCommandEndRewind:
+ platformCommand = PlatformMediaSession::EndSeekingBackwardCommand;
+ break;
+ case MRMediaRemoteCommandSeekToPlaybackPosition: {
+ if (!m_supportsSeeking) {
+ status = MRMediaRemoteCommandHandlerStatusCommandFailed;
+ break;
+ }
+
+ CFNumberRef positionRef = static_cast<CFNumberRef>(CFDictionaryGetValue(options, kMRMediaRemoteOptionPlaybackPosition));
+ if (!positionRef) {
+ status = MRMediaRemoteCommandHandlerStatusCommandFailed;
+ break;
+ }
+
+ double position = 0;
+ CFNumberGetValue(positionRef, kCFNumberDoubleType, &position);
+ argument.time = position;
+ platformCommand = PlatformMediaSession::SeekToPlaybackPositionCommand;
+ break;
+ }
+ case MRMediaRemoteCommandSkipForward:
+ case MRMediaRemoteCommandSkipBackward:
+ if (!m_supportsSeeking) {
+ status = MRMediaRemoteCommandHandlerStatusCommandFailed;
+ break;
+ }
+
+ if (auto positionRef = static_cast<CFNumberRef>(CFDictionaryGetValue(options, kMRMediaRemoteOptionSkipInterval))) {
+ double position = 0;
+ CFNumberGetValue(positionRef, kCFNumberDoubleType, &position);
+ argument.time = position;
+ }
+
+ platformCommand = (command == MRMediaRemoteCommandSkipForward) ? PlatformMediaSession::SkipForwardCommand : PlatformMediaSession::SkipBackwardCommand;
+ break;
+ case MRMediaRemoteCommandNextTrack:
+ platformCommand = PlatformMediaSession::NextTrackCommand;
+ break;
+ case MRMediaRemoteCommandPreviousTrack:
+ platformCommand = PlatformMediaSession::PreviousTrackCommand;
+ break;
+ default:
+ LOG(Media, "RemoteCommandListenerCocoa::RemoteCommandListenerCocoa - command %u not supported!", command);
+ status = MRMediaRemoteCommandHandlerStatusCommandFailed;
+ };
+
+ if (weakThis && status != MRMediaRemoteCommandHandlerStatusCommandFailed)
+ weakThis->m_client.didReceiveRemoteControlCommand(platformCommand, argument);
+
+ completion((__bridge CFArrayRef)@[@(status)]);
+ });
+}
+
+RemoteCommandListenerCocoa::~RemoteCommandListenerCocoa()
+{
+ if (m_commandHandler)
+ MRMediaRemoteRemoveCommandHandlerBlock(m_commandHandler);
+}
+
+}
+
+#endif
Deleted: trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h (273872 => 273873)
--- trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.h 2021-03-04 05:59:26 UTC (rev 273873)
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2014 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. ``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
- * 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.
- */
-
-#if PLATFORM(IOS_FAMILY)
-
-#include "RemoteCommandListener.h"
-#include <wtf/RetainPtr.h>
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class RemoteCommandListenerIOS final : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerIOS> {
-public:
- static std::unique_ptr<RemoteCommandListenerIOS> create(RemoteCommandListenerClient&);
- RemoteCommandListenerIOS(RemoteCommandListenerClient&);
- virtual ~RemoteCommandListenerIOS();
-
-protected:
- void updateSupportedCommands() final;
-
- RetainPtr<id> m_playTarget;
- RetainPtr<id> m_pauseTarget;
- RetainPtr<id> m_togglePlayPauseTarget;
- RetainPtr<id> m_seekForwardTarget;
- RetainPtr<id> m_seekBackwardTarget;
- RetainPtr<id> m_seekToTimeTarget;
-};
-
-}
-
-#endif // PLATFORM(IOS_FAMILY)
Deleted: trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm (273872 => 273873)
--- trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/platform/ios/RemoteCommandListenerIOS.mm 2021-03-04 05:59:26 UTC (rev 273873)
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2014 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. ``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
- * 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 "config.h"
-#import "RemoteCommandListenerIOS.h"
-
-#if PLATFORM(IOS_FAMILY)
-
-#import <MediaPlayer/MPRemoteCommand.h>
-#import <MediaPlayer/MPRemoteCommandCenter.h>
-#import <MediaPlayer/MPRemoteCommandEvent.h>
-#import <wtf/SoftLinking.h>
-
-SOFT_LINK_FRAMEWORK_OPTIONAL(MediaPlayer)
-SOFT_LINK_CLASS(MediaPlayer, MPRemoteCommandCenter)
-SOFT_LINK_CLASS(MediaPlayer, MPSeekCommandEvent)
-SOFT_LINK_CLASS(MediaPlayer, MPChangePlaybackPositionCommandEvent)
-
-namespace WebCore {
-
-std::unique_ptr<RemoteCommandListenerIOS> RemoteCommandListenerIOS::create(RemoteCommandListenerClient& client)
-{
- if (!MediaPlayerLibrary())
- return nullptr;
-
- return makeUnique<RemoteCommandListenerIOS>(client);
-}
-
-RemoteCommandListenerIOS::RemoteCommandListenerIOS(RemoteCommandListenerClient& client)
- : RemoteCommandListener(client)
-{
- MPRemoteCommandCenter *center = [getMPRemoteCommandCenterClass() sharedCommandCenter];
- auto weakThis = makeWeakPtr(*this);
-
- m_pauseTarget = [[center pauseCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) {
- callOnMainThread([weakThis] {
- if (!weakThis)
- return;
- weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PauseCommand, { });
- });
-
- return MPRemoteCommandHandlerStatusSuccess;
- }];
-
- m_playTarget = [[center playCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) {
- callOnMainThread([weakThis] {
- if (!weakThis)
- return;
- weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::PlayCommand, { });
- });
-
- return MPRemoteCommandHandlerStatusSuccess;
- }];
-
- m_togglePlayPauseTarget = [[center togglePlayPauseCommand] addTargetWithHandler:^(MPRemoteCommandEvent *) {
- callOnMainThread([weakThis] {
- if (!weakThis)
- return;
- weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::TogglePlayPauseCommand, { });
- });
-
- return MPRemoteCommandHandlerStatusSuccess;
- }];
-
- m_seekBackwardTarget = [[center seekBackwardCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) {
- ASSERT([event isKindOfClass:getMPSeekCommandEventClass()]);
-
- MPSeekCommandEvent* seekEvent = static_cast<MPSeekCommandEvent *>(event);
- PlatformMediaSession::RemoteControlCommandType command = [seekEvent type] == MPSeekCommandEventTypeBeginSeeking ? PlatformMediaSession::BeginSeekingBackwardCommand : PlatformMediaSession::EndSeekingBackwardCommand;
-
- callOnMainThread([weakThis, command] {
- if (!weakThis)
- return;
- weakThis->m_client.didReceiveRemoteControlCommand(command, { });
- });
-
- return MPRemoteCommandHandlerStatusSuccess;
- }];
-
- m_seekForwardTarget = [[center seekForwardCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) {
- ASSERT([event isKindOfClass:getMPSeekCommandEventClass()]);
- MPSeekCommandEvent* seekEvent = static_cast<MPSeekCommandEvent *>(event);
-
- PlatformMediaSession::RemoteControlCommandType command = [seekEvent type] == MPSeekCommandEventTypeBeginSeeking ? PlatformMediaSession::BeginSeekingForwardCommand : PlatformMediaSession::EndSeekingForwardCommand;
-
- callOnMainThread([weakThis, command] {
- if (!weakThis)
- return;
- weakThis->m_client.didReceiveRemoteControlCommand(command, { });
- });
-
- return MPRemoteCommandHandlerStatusSuccess;
- }];
-
- m_seekToTimeTarget = [[center changePlaybackPositionCommand] addTargetWithHandler:^(MPRemoteCommandEvent *event) {
- ASSERT([event isKindOfClass:getMPChangePlaybackPositionCommandEventClass()]);
-
- if (!m_supportsSeeking)
- return MPRemoteCommandHandlerStatusCommandFailed;
-
- MPChangePlaybackPositionCommandEvent* seekEvent = static_cast<MPChangePlaybackPositionCommandEvent *>(event);
- PlatformMediaSession::RemoteCommandArgument argument { [seekEvent positionTime], { } };
-
- callOnMainThread([weakThis, argument = WTFMove(argument)] {
- if (!weakThis)
- return;
- weakThis->m_client.didReceiveRemoteControlCommand(PlatformMediaSession::SeekToPlaybackPositionCommand, argument);
- });
-
- return MPRemoteCommandHandlerStatusSuccess;
- }];
-}
-
-RemoteCommandListenerIOS::~RemoteCommandListenerIOS()
-{
- MPRemoteCommandCenter *center = [getMPRemoteCommandCenterClass() sharedCommandCenter];
- [[center pauseCommand] removeTarget:m_pauseTarget.get()];
- [[center playCommand] removeTarget:m_playTarget.get()];
- [[center togglePlayPauseCommand] removeTarget:m_togglePlayPauseTarget.get()];
- [[center seekForwardCommand] removeTarget:m_seekForwardTarget.get()];
- [[center seekBackwardCommand] removeTarget:m_seekBackwardTarget.get()];
- [[center changePlaybackPositionCommand] removeTarget:m_seekToTimeTarget.get()];
-}
-
-void RemoteCommandListenerIOS::updateSupportedCommands()
-{
- [[[getMPRemoteCommandCenterClass() sharedCommandCenter] changePlaybackPositionCommand] setEnabled:m_supportsSeeking];
-}
-
-}
-
-#endif // PLATFORM(IOS_FAMILY)
Deleted: trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h (273872 => 273873)
--- trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.h 2021-03-04 05:59:26 UTC (rev 273873)
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2016-2021 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
-
-#include "RemoteCommandListener.h"
-
-#if PLATFORM(MAC)
-
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-class RemoteCommandListenerMac : public RemoteCommandListener, public CanMakeWeakPtr<RemoteCommandListenerMac> {
-public:
- static std::unique_ptr<RemoteCommandListenerMac> create(RemoteCommandListenerClient&);
- RemoteCommandListenerMac(RemoteCommandListenerClient&);
- virtual ~RemoteCommandListenerMac();
-
-protected:
- void updateSupportedCommands() final;
-
- void* m_commandHandler { nullptr };
-
- const RemoteCommandsSet& defaultCommands();
- RemoteCommandsSet m_currentCommands;
- bool m_supportsSeeking { false };
-};
-
-}
-
-#endif // PLATFORM(MAC)
Deleted: trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm (273872 => 273873)
--- trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm 2021-03-04 05:00:08 UTC (rev 273872)
+++ trunk/Source/WebCore/platform/mac/RemoteCommandListenerMac.mm 2021-03-04 05:59:26 UTC (rev 273873)
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2016-2021 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 "config.h"
-#import "RemoteCommandListenerMac.h"
-
-#if PLATFORM(MAC)
-
-#import "Logging.h"
-#import <wtf/MainThread.h>
-
-#import "MediaRemoteSoftLink.h"
-
-namespace WebCore {
-
-static Optional<MRMediaRemoteCommand> mediaRemoteCommandForPlatformCommand(PlatformMediaSession::RemoteControlCommandType command)
-{
- static const auto commandMap = makeNeverDestroyed([] {
- using CommandToActionMap = HashMap<PlatformMediaSession::RemoteControlCommandType, MRMediaRemoteCommand, WTF::IntHash<PlatformMediaSession::RemoteControlCommandType>, WTF::StrongEnumHashTraits<PlatformMediaSession::RemoteControlCommandType>>;
-
- return CommandToActionMap {
- { PlatformMediaSession::PlayCommand, MRMediaRemoteCommandPlay },
- { PlatformMediaSession::PauseCommand, MRMediaRemoteCommandPause },
- { PlatformMediaSession::StopCommand, MRMediaRemoteCommandStop },
- { PlatformMediaSession::TogglePlayPauseCommand, MRMediaRemoteCommandTogglePlayPause },
- { PlatformMediaSession::BeginSeekingBackwardCommand, MRMediaRemoteCommandBeginRewind },
- { PlatformMediaSession::EndSeekingBackwardCommand, MRMediaRemoteCommandEndRewind },
- { PlatformMediaSession::BeginSeekingForwardCommand, MRMediaRemoteCommandBeginFastForward },
- { PlatformMediaSession::EndSeekingForwardCommand, MRMediaRemoteCommandEndFastForward },
- { PlatformMediaSession::SeekToPlaybackPositionCommand, MRMediaRemoteCommandSeekToPlaybackPosition },
- { PlatformMediaSession::SkipForwardCommand, MRMediaRemoteCommandSkipForward },
- { PlatformMediaSession::SkipBackwardCommand, MRMediaRemoteCommandSkipBackward },
- { PlatformMediaSession::NextTrackCommand, MRMediaRemoteCommandNextTrack },
- { PlatformMediaSession::PreviousTrackCommand, MRMediaRemoteCommandPreviousTrack },
- };
- }());
-
- auto it = commandMap.get().find(command);
- if (it != commandMap.get().end())
- return { it->value };
-
- return { };
-}
-
-std::unique_ptr<RemoteCommandListenerMac> RemoteCommandListenerMac::create(RemoteCommandListenerClient& client)
-{
- return makeUnique<RemoteCommandListenerMac>(client);
-}
-
-const RemoteCommandListener::RemoteCommandsSet& RemoteCommandListenerMac::defaultCommands()
-{
- static NeverDestroyed<RemoteCommandsSet> commands(std::initializer_list<PlatformMediaSession::RemoteControlCommandType> {
- PlatformMediaSession::PlayCommand,
- PlatformMediaSession::PauseCommand,
- PlatformMediaSession::TogglePlayPauseCommand,
- PlatformMediaSession::BeginSeekingForwardCommand,
- PlatformMediaSession::EndSeekingForwardCommand,
- PlatformMediaSession::BeginSeekingBackwardCommand,
- PlatformMediaSession::EndSeekingBackwardCommand,
- PlatformMediaSession::SeekToPlaybackPositionCommand,
- PlatformMediaSession::SkipForwardCommand,
- PlatformMediaSession::SkipBackwardCommand,
- });
-
- return commands;
-}
-
-static bool isSeekCommand(PlatformMediaSession::RemoteControlCommandType command)
-{
- return command == PlatformMediaSession::SeekToPlaybackPositionCommand
- || command == PlatformMediaSession::SkipForwardCommand
- || command == PlatformMediaSession::SkipBackwardCommand
- || command == PlatformMediaSession::BeginSeekingForwardCommand
- || command == PlatformMediaSession::BeginSeekingBackwardCommand;
-}
-
-void RemoteCommandListenerMac::updateSupportedCommands()
-{
- if (!isMediaRemoteFrameworkAvailable())
- return;
-
- auto& supportedCommands = !m_registeredCommands.isEmpty() ? m_registeredCommands : defaultCommands();
- if (m_currentCommands == supportedCommands)
- return;
-
- auto commandInfoArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, supportedCommands.size(), &kCFTypeArrayCallBacks));
- for (auto platformCommand : supportedCommands) {
- if (isSeekCommand(platformCommand) && !m_supportsSeeking)
- continue;
-
- auto command = mediaRemoteCommandForPlatformCommand(platformCommand);
- ASSERT(command);
- if (!command)
- continue;
-
- auto commandInfo = adoptCF(MRMediaRemoteCommandInfoCreate(kCFAllocatorDefault));
- MRMediaRemoteCommandInfoSetCommand(commandInfo.get(), command.value());
- MRMediaRemoteCommandInfoSetEnabled(commandInfo.get(), true);
- CFArrayAppendValue(commandInfoArray.get(), commandInfo.get());
- }
-
- MRMediaRemoteSetSupportedCommands(commandInfoArray.get(), MRMediaRemoteGetLocalOrigin(), nullptr, nullptr);
- m_currentCommands = supportedCommands;
-}
-
-RemoteCommandListenerMac::RemoteCommandListenerMac(RemoteCommandListenerClient& client)
- : RemoteCommandListener(client)
-{
- if (!isMediaRemoteFrameworkAvailable())
- return;
-
- scheduleSupportedCommandsUpdate();
-
- auto weakThis = makeWeakPtr(*this);
- m_commandHandler = MRMediaRemoteAddAsyncCommandHandlerBlock(^(MRMediaRemoteCommand command, CFDictionaryRef options, void(^completion)(CFArrayRef)) {
-
- LOG(Media, "RemoteCommandListenerMac::RemoteCommandListenerMac - received command %u", command);
-
- PlatformMediaSession::RemoteControlCommandType platformCommand { PlatformMediaSession::NoCommand };
- PlatformMediaSession::RemoteCommandArgument argument;
- MRMediaRemoteCommandHandlerStatus status = MRMediaRemoteCommandHandlerStatusSuccess;
-
- switch (command) {
- case MRMediaRemoteCommandPlay:
- platformCommand = PlatformMediaSession::PlayCommand;
- break;
- case MRMediaRemoteCommandPause:
- platformCommand = PlatformMediaSession::PauseCommand;
- break;
- case MRMediaRemoteCommandStop:
- platformCommand = PlatformMediaSession::StopCommand;
- break;
- case MRMediaRemoteCommandTogglePlayPause:
- platformCommand = PlatformMediaSession::TogglePlayPauseCommand;
- break;
- case MRMediaRemoteCommandBeginFastForward:
- platformCommand = PlatformMediaSession::BeginSeekingForwardCommand;
- break;
- case MRMediaRemoteCommandEndFastForward:
- platformCommand = PlatformMediaSession::EndSeekingForwardCommand;
- break;
- case MRMediaRemoteCommandBeginRewind:
- platformCommand = PlatformMediaSession::BeginSeekingBackwardCommand;
- break;
- case MRMediaRemoteCommandEndRewind:
- platformCommand = PlatformMediaSession::EndSeekingBackwardCommand;
- break;
- case MRMediaRemoteCommandSeekToPlaybackPosition: {
- if (!m_supportsSeeking) {
- status = MRMediaRemoteCommandHandlerStatusCommandFailed;
- break;
- }
-
- CFNumberRef positionRef = static_cast<CFNumberRef>(CFDictionaryGetValue(options, kMRMediaRemoteOptionPlaybackPosition));
- if (!positionRef) {
- status = MRMediaRemoteCommandHandlerStatusCommandFailed;
- break;
- }
-
- double position = 0;
- CFNumberGetValue(positionRef, kCFNumberDoubleType, &position);
- argument.time = position;
- platformCommand = PlatformMediaSession::SeekToPlaybackPositionCommand;
- break;
- }
- case MRMediaRemoteCommandSkipForward:
- case MRMediaRemoteCommandSkipBackward:
- if (!m_supportsSeeking) {
- status = MRMediaRemoteCommandHandlerStatusCommandFailed;
- break;
- }
-
- if (auto positionRef = static_cast<CFNumberRef>(CFDictionaryGetValue(options, kMRMediaRemoteOptionSkipInterval))) {
- double position = 0;
- CFNumberGetValue(positionRef, kCFNumberDoubleType, &position);
- argument.time = position;
- }
-
- platformCommand = (command == MRMediaRemoteCommandSkipForward) ? PlatformMediaSession::SkipForwardCommand : PlatformMediaSession::SkipBackwardCommand;
- break;
- case MRMediaRemoteCommandNextTrack:
- platformCommand = PlatformMediaSession::NextTrackCommand;
- break;
- case MRMediaRemoteCommandPreviousTrack:
- platformCommand = PlatformMediaSession::PreviousTrackCommand;
- break;
- default:
- LOG(Media, "RemoteCommandListenerMac::RemoteCommandListenerMac - command %u not supported!", command);
- status = MRMediaRemoteCommandHandlerStatusCommandFailed;
- };
-
- if (weakThis && status != MRMediaRemoteCommandHandlerStatusCommandFailed)
- weakThis->m_client.didReceiveRemoteControlCommand(platformCommand, argument);
-
- completion((__bridge CFArrayRef)@[@(status)]);
- });
-}
-
-RemoteCommandListenerMac::~RemoteCommandListenerMac()
-{
- if (m_commandHandler)
- MRMediaRemoteRemoveCommandHandlerBlock(m_commandHandler);
-}
-
-}
-
-#endif