Title: [284946] branches/safari-612-branch/Source
Revision
284946
Author
[email protected]
Date
2021-10-27 14:05:46 -0700 (Wed, 27 Oct 2021)

Log Message

Cherry-pick r284220. rdar://problem/84625558

    Adopt attribution AVCaptureSession SPI for GPU process
    https://bugs.webkit.org/show_bug.cgi?id=231621
    <rdar://problem/80748535>

    Reviewed by Eric Carlson.

    Source/WebCore:

    No new tests. Manually tested by checking App Privacy Report data.

    * SourcesCocoa.txt:
    * WebCore.xcodeproj/project.pbxproj:
    * platform/mediastream/RealtimeMediaSourceCenter.h:
    * platform/mediastream/mac/AVVideoCaptureSource.mm:
    (WebCore::AVVideoCaptureSource::setupSession):

    Source/WebCore/PAL:

    * PAL.xcodeproj/project.pbxproj:
    * pal/spi/cocoa/AVFoundationSPI.h:
    * pal/spi/cocoa/TCCSPI.h: Renamed from Source/WebKit/Platform/spi/ios/TCCSPI.h.

    Source/WebKit:

    Add SPI to attribute camera access to host app in the GPU process.

    * GPUProcess/GPUConnectionToWebProcess.cpp:
    * GPUProcess/GPUConnectionToWebProcess.h:
    * GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm:
    (WebKit::GPUConnectionToWebProcess::setTCCIdentity):
    * Shared/Cocoa/TCCSoftLink.h:
    * Shared/Cocoa/TCCSoftLink.mm:
    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
    (WebKit::UserMediaCaptureManagerProxy::startProducingData):
    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
    (WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setTCCIdentity):
    * WebKit.xcodeproj/project.pbxproj:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284220 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-27 21:05:46 UTC (rev 284946)
@@ -1,5 +1,65 @@
 2021-10-26  Alan Coon  <[email protected]>
 
+        Cherry-pick r284220. rdar://problem/84625558
+
+    Adopt attribution AVCaptureSession SPI for GPU process
+    https://bugs.webkit.org/show_bug.cgi?id=231621
+    <rdar://problem/80748535>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    No new tests. Manually tested by checking App Privacy Report data.
+    
+    * SourcesCocoa.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * platform/mediastream/RealtimeMediaSourceCenter.h:
+    * platform/mediastream/mac/AVVideoCaptureSource.mm:
+    (WebCore::AVVideoCaptureSource::setupSession):
+    
+    Source/WebCore/PAL:
+    
+    * PAL.xcodeproj/project.pbxproj:
+    * pal/spi/cocoa/AVFoundationSPI.h:
+    * pal/spi/cocoa/TCCSPI.h: Renamed from Source/WebKit/Platform/spi/ios/TCCSPI.h.
+    
+    Source/WebKit:
+    
+    Add SPI to attribute camera access to host app in the GPU process.
+    
+    * GPUProcess/GPUConnectionToWebProcess.cpp:
+    * GPUProcess/GPUConnectionToWebProcess.h:
+    * GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm:
+    (WebKit::GPUConnectionToWebProcess::setTCCIdentity):
+    * Shared/Cocoa/TCCSoftLink.h:
+    * Shared/Cocoa/TCCSoftLink.mm:
+    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+    (WebKit::UserMediaCaptureManagerProxy::startProducingData):
+    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+    (WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setTCCIdentity):
+    * WebKit.xcodeproj/project.pbxproj:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-14  Kate Cheney  <[email protected]>
+
+            Adopt attribution AVCaptureSession SPI for GPU process
+            https://bugs.webkit.org/show_bug.cgi?id=231621
+            <rdar://problem/80748535>
+
+            Reviewed by Eric Carlson.
+
+            No new tests. Manually tested by checking App Privacy Report data.
+
+            * SourcesCocoa.txt:
+            * WebCore.xcodeproj/project.pbxproj:
+            * platform/mediastream/RealtimeMediaSourceCenter.h:
+            * platform/mediastream/mac/AVVideoCaptureSource.mm:
+            (WebCore::AVVideoCaptureSource::setupSession):
+
+2021-10-26  Alan Coon  <[email protected]>
+
         Cherry-pick r283583. rdar://problem/83606128
 
     REGRESSION (Monterey): paramountplus.com: Cannot enter fullscreen in Safari

Modified: branches/safari-612-branch/Source/WebCore/PAL/ChangeLog (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/PAL/ChangeLog	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/PAL/ChangeLog	2021-10-27 21:05:46 UTC (rev 284946)
@@ -1,3 +1,59 @@
+2021-10-26  Alan Coon  <[email protected]>
+
+        Cherry-pick r284220. rdar://problem/84625558
+
+    Adopt attribution AVCaptureSession SPI for GPU process
+    https://bugs.webkit.org/show_bug.cgi?id=231621
+    <rdar://problem/80748535>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    No new tests. Manually tested by checking App Privacy Report data.
+    
+    * SourcesCocoa.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * platform/mediastream/RealtimeMediaSourceCenter.h:
+    * platform/mediastream/mac/AVVideoCaptureSource.mm:
+    (WebCore::AVVideoCaptureSource::setupSession):
+    
+    Source/WebCore/PAL:
+    
+    * PAL.xcodeproj/project.pbxproj:
+    * pal/spi/cocoa/AVFoundationSPI.h:
+    * pal/spi/cocoa/TCCSPI.h: Renamed from Source/WebKit/Platform/spi/ios/TCCSPI.h.
+    
+    Source/WebKit:
+    
+    Add SPI to attribute camera access to host app in the GPU process.
+    
+    * GPUProcess/GPUConnectionToWebProcess.cpp:
+    * GPUProcess/GPUConnectionToWebProcess.h:
+    * GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm:
+    (WebKit::GPUConnectionToWebProcess::setTCCIdentity):
+    * Shared/Cocoa/TCCSoftLink.h:
+    * Shared/Cocoa/TCCSoftLink.mm:
+    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+    (WebKit::UserMediaCaptureManagerProxy::startProducingData):
+    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+    (WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setTCCIdentity):
+    * WebKit.xcodeproj/project.pbxproj:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-14  Kate Cheney  <[email protected]>
+
+            Adopt attribution AVCaptureSession SPI for GPU process
+            https://bugs.webkit.org/show_bug.cgi?id=231621
+            <rdar://problem/80748535>
+
+            Reviewed by Eric Carlson.
+
+            * PAL.xcodeproj/project.pbxproj:
+            * pal/spi/cocoa/AVFoundationSPI.h:
+            * pal/spi/cocoa/TCCSPI.h: Renamed from Source/WebKit/Platform/spi/ios/TCCSPI.h.
+
 2021-10-25  Null  <[email protected]>
 
         Cherry-pick r283592. rdar://problem/84625519

Modified: branches/safari-612-branch/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2021-10-27 21:05:46 UTC (rev 284946)
@@ -137,6 +137,7 @@
 		4450FCA021F5F602004DFA56 /* QuickLookSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 4450FC9E21F5F602004DFA56 /* QuickLookSoftLink.h */; };
 		44E1A8AF21FA54E600C3048E /* LookupSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E1A8AD21FA54DA00C3048E /* LookupSoftLink.h */; };
 		44E1A8B021FA54EB00C3048E /* LookupSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44E1A8AE21FA54DA00C3048E /* LookupSoftLink.mm */; };
+		4996C0F32717644C002C125D /* TCCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4996C0F22717642B002C125D /* TCCSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		517E03F924B7C0070054895A /* IOKitSPIMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 517E03F824B7C0060054895A /* IOKitSPIMac.h */; };
 		570AB8F120AE2E8D00B8BE87 /* SecKeyProxySPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */; };
 		570AB8F920AF6E3D00B8BE87 /* NSXPCConnectionSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 570AB8F820AF6E3D00B8BE87 /* NSXPCConnectionSPI.h */; };
@@ -359,6 +360,7 @@
 		4450FC9E21F5F602004DFA56 /* QuickLookSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuickLookSoftLink.h; sourceTree = "<group>"; };
 		44E1A8AD21FA54DA00C3048E /* LookupSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LookupSoftLink.h; sourceTree = "<group>"; };
 		44E1A8AE21FA54DA00C3048E /* LookupSoftLink.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LookupSoftLink.mm; sourceTree = "<group>"; };
+		4996C0F22717642B002C125D /* TCCSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TCCSPI.h; sourceTree = "<group>"; };
 		517E03F824B7C0060054895A /* IOKitSPIMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOKitSPIMac.h; sourceTree = "<group>"; };
 		570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SecKeyProxySPI.h; sourceTree = "<group>"; };
 		570AB8F820AF6E3D00B8BE87 /* NSXPCConnectionSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSXPCConnectionSPI.h; sourceTree = "<group>"; };
@@ -569,6 +571,7 @@
 				570AB8F020AE2E8D00B8BE87 /* SecKeyProxySPI.h */,
 				0C2DA13C1F3BEB4900DBC317 /* ServersSPI.h */,
 				93B38EC125821D2200198E63 /* SpeechSPI.h */,
+				4996C0F22717642B002C125D /* TCCSPI.h */,
 				0C2DA12B1F3BEB4900DBC317 /* URLFormattingSPI.h */,
 				F46B8C4E26740AD8007A6554 /* VisionKitCoreSPI.h */,
 				0C2DA13D1F3BEB4900DBC317 /* WebFilterEvaluatorSPI.h */,
@@ -1005,6 +1008,7 @@
 				A3AB6E581F3D1DDB009C14B1 /* SystemSleepListener.h in Headers */,
 				A3AB6E641F3D217F009C14B1 /* SystemSleepListenerMac.h in Headers */,
 				079D1D9726950DD700883577 /* SystemStatusSoftLink.h in Headers */,
+				4996C0F32717644C002C125D /* TCCSPI.h in Headers */,
 				0C7785A11F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h in Headers */,
 				2E1342CC215AA10A007199D2 /* UIKitSoftLink.h in Headers */,
 				0C5AF9221F43A4C7002EAC02 /* UIKitSPI.h in Headers */,

Modified: branches/safari-612-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -31,9 +31,12 @@
 #import <AVFoundation/AVContentKeySession.h>
 #endif
 
+#import <pal/spi/cocoa/TCCSPI.h>
+
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <AVFoundation/AVAssetCache_Private.h>
+#import <AVFoundation/AVCaptureSession_Private.h>
 #import <AVFoundation/AVOutputContext_Private.h>
 #import <AVFoundation/AVOutputDevice.h>
 #import <AVFoundation/AVPlayer_Private.h>
@@ -54,6 +57,7 @@
 
 #else
 
+#import <AVFoundation/AVCaptureSession.h>
 #import <AVFoundation/AVPlayer.h>
 #import <AVFoundation/AVPlayerItem.h>
 
@@ -437,4 +441,14 @@
 #endif
 
 #endif // USE(APPLE_INTERNAL_SDK)
+
+NS_ASSUME_NONNULL_BEGIN
+
+// FIXME: Move this inside the #if USE(APPLE_INTERNAL_SDK) once rdar://81297776 has been in the build for awhile.
+@interface AVCaptureSession (AVCaptureSessionPrivate)
+- (instancetype)initWithAssumedIdentity:(tcc_identity_t)tccIdentity SPI_AVAILABLE(ios(15.0)) API_UNAVAILABLE(macos, macCatalyst, watchos, tvos);
+@end
+
+NS_ASSUME_NONNULL_END
+
 #endif // HAVE(AVSAMPLEBUFFERVIDEOOUTPUT)

Copied: branches/safari-612-branch/Source/WebCore/PAL/pal/spi/cocoa/TCCSPI.h (from rev 284945, branches/safari-612-branch/Source/WebKit/Platform/spi/ios/TCCSPI.h) (0 => 284946)


--- branches/safari-612-branch/Source/WebCore/PAL/pal/spi/cocoa/TCCSPI.h	                        (rev 0)
+++ branches/safari-612-branch/Source/WebCore/PAL/pal/spi/cocoa/TCCSPI.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014-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
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <TCC/TCC.h>
+
+#else
+
+typedef enum {
+    kTCCAccessPreflightGranted,
+    kTCCAccessPreflightDenied,
+} TCCAccessPreflightResult;
+
+typedef uint64_t tcc_identity_type_t;
+typedef struct { } tcc_identity_t;
+
+#endif

Modified: branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-10-27 21:05:46 UTC (rev 284946)
@@ -1346,6 +1346,7 @@
 		494BD7950F55C8EE00747828 /* WebKitPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 494BD7930F55C8EE00747828 /* WebKitPoint.h */; };
 		494BD79E0F55C94C00747828 /* JSWebKitPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 494BD79C0F55C94C00747828 /* JSWebKitPoint.h */; };
 		4969B0F313D0B33F00DF3521 /* HitTestingTransformState.h in Headers */ = {isa = PBXBuildFile; fileRef = 4969B0F113D0B33F00DF3521 /* HitTestingTransformState.h */; };
+		4996C0F627177488002C125D /* AVVideoCaptureSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 070363DF181A1CDC00C074A5 /* AVVideoCaptureSource.mm */; };
 		4998AEC613F9D0EA0090B1AA /* RequestAnimationFrameCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 4998AEC413F9D0EA0090B1AA /* RequestAnimationFrameCallback.h */; };
 		4998AECE13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 4998AECC13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.h */; };
 		4998AED213FB224D0090B1AA /* ScriptedAnimationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4998AED013FB224D0090B1AA /* ScriptedAnimationController.h */; };
@@ -36043,7 +36044,7 @@
 				07CB9E72249C36B200A69489 /* AVRoutePickerViewTargetPicker.mm in Sources */,
 				CD11B3E1227CE6F30023AFC7 /* AVStreamDataParserMIMETypeCache.mm in Sources */,
 				CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */,
-				070363E7181A1CDC00C074A5 /* AVVideoCaptureSource.mm in Sources */,
+				4996C0F627177488002C125D /* AVVideoCaptureSource.mm in Sources */,
 				CDF4B7151E00B7E500E235A2 /* CDM.cpp in Sources */,
 				CDB7045B1F7465A1003923DF /* CDMFairPlayStreaming.cpp in Sources */,
 				CDC224281F756966005F077B /* CDMInstanceFairPlayStreamingAVFObjC.mm in Sources */,

Modified: branches/safari-612-branch/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -45,6 +45,10 @@
 #include <wtf/RunLoop.h>
 #include <wtf/text/WTFString.h>
 
+#if PLATFORM(COCOA)
+#include <pal/spi/cocoa/TCCSPI.h>
+#endif
+
 namespace WebCore {
 
 class CaptureDevice;
@@ -100,6 +104,11 @@
 
     WEBCORE_EXPORT static bool shouldInterruptAudioOnPageVisibilityChange();
 
+#if ENABLE(APP_PRIVACY_REPORT)
+    void setIdentity(std::optional<tcc_identity_t> identity) { m_identity = identity; }
+    std::optional<tcc_identity_t> identity() const { return m_identity; }
+#endif
+
 private:
     RealtimeMediaSourceCenter();
     friend class NeverDestroyed<RealtimeMediaSourceCenter>;
@@ -130,6 +139,10 @@
     DisplayCaptureFactory* m_displayCaptureFactoryOverride { nullptr };
 
     bool m_shouldInterruptAudioOnPageVisibilityChange { false };
+
+#if ENABLE(APP_PRIVACY_REPORT)
+    std::optional<tcc_identity_t> m_identity;
+#endif
 };
 
 } // namespace WebCore

Modified: branches/safari-612-branch/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm (284945 => 284946)


--- branches/safari-612-branch/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm	2021-10-27 21:05:46 UTC (rev 284946)
@@ -45,6 +45,7 @@
 #import <AVFoundation/AVCaptureSession.h>
 #import <AVFoundation/AVError.h>
 #import <objc/runtime.h>
+#import <pal/spi/cocoa/AVFoundationSPI.h>
 
 #import "CoreVideoSoftLink.h"
 #import <pal/cocoa/AVFoundationSoftLink.h>
@@ -422,7 +423,15 @@
 
     ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER);
 
+#if ENABLE(APP_PRIVACY_REPORT)
+    auto identity = RealtimeMediaSourceCenter::singleton().identity();
+    if (identity && [PAL::allocAVCaptureSessionInstance() respondsToSelector:@selector(initWithAssumedIdentity:)])
+        m_session = adoptNS([PAL::allocAVCaptureSessionInstance() initWithAssumedIdentity:*identity]);
+    else
+        m_session = adoptNS([PAL::allocAVCaptureSessionInstance() init]);
+#else
     m_session = adoptNS([PAL::allocAVCaptureSessionInstance() init]);
+#endif
 #if PLATFORM(IOS_FAMILY)
     PAL::AVCaptureSessionSetAuthorizedToUseCameraInMultipleForegroundAppLayout(m_session.get());
 #endif

Modified: branches/safari-612-branch/Source/WebKit/ChangeLog (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/ChangeLog	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/ChangeLog	2021-10-27 21:05:46 UTC (rev 284946)
@@ -1,3 +1,69 @@
+2021-10-26  Alan Coon  <[email protected]>
+
+        Cherry-pick r284220. rdar://problem/84625558
+
+    Adopt attribution AVCaptureSession SPI for GPU process
+    https://bugs.webkit.org/show_bug.cgi?id=231621
+    <rdar://problem/80748535>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/WebCore:
+    
+    No new tests. Manually tested by checking App Privacy Report data.
+    
+    * SourcesCocoa.txt:
+    * WebCore.xcodeproj/project.pbxproj:
+    * platform/mediastream/RealtimeMediaSourceCenter.h:
+    * platform/mediastream/mac/AVVideoCaptureSource.mm:
+    (WebCore::AVVideoCaptureSource::setupSession):
+    
+    Source/WebCore/PAL:
+    
+    * PAL.xcodeproj/project.pbxproj:
+    * pal/spi/cocoa/AVFoundationSPI.h:
+    * pal/spi/cocoa/TCCSPI.h: Renamed from Source/WebKit/Platform/spi/ios/TCCSPI.h.
+    
+    Source/WebKit:
+    
+    Add SPI to attribute camera access to host app in the GPU process.
+    
+    * GPUProcess/GPUConnectionToWebProcess.cpp:
+    * GPUProcess/GPUConnectionToWebProcess.h:
+    * GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm:
+    (WebKit::GPUConnectionToWebProcess::setTCCIdentity):
+    * Shared/Cocoa/TCCSoftLink.h:
+    * Shared/Cocoa/TCCSoftLink.mm:
+    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+    (WebKit::UserMediaCaptureManagerProxy::startProducingData):
+    * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+    (WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setTCCIdentity):
+    * WebKit.xcodeproj/project.pbxproj:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-14  Kate Cheney  <[email protected]>
+
+            Adopt attribution AVCaptureSession SPI for GPU process
+            https://bugs.webkit.org/show_bug.cgi?id=231621
+            <rdar://problem/80748535>
+
+            Reviewed by Eric Carlson.
+
+            Add SPI to attribute camera access to host app in the GPU process.
+
+            * GPUProcess/GPUConnectionToWebProcess.cpp:
+            * GPUProcess/GPUConnectionToWebProcess.h:
+            * GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm:
+            (WebKit::GPUConnectionToWebProcess::setTCCIdentity):
+            * Shared/Cocoa/TCCSoftLink.h:
+            * Shared/Cocoa/TCCSoftLink.mm:
+            * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
+            (WebKit::UserMediaCaptureManagerProxy::startProducingData):
+            * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
+            (WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setTCCIdentity):
+            * WebKit.xcodeproj/project.pbxproj:
+
 2021-10-27  Alan Coon  <[email protected]>
 
         Cherry-pick r283662. rdar://problem/84717723

Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2021-10-27 21:05:46 UTC (rev 284946)
@@ -189,6 +189,13 @@
         return m_process.setCaptureAttributionString();
     }
 
+#if ENABLE(APP_PRIVACY_REPORT)
+    void setTCCIdentity() final
+    {
+        m_process.setTCCIdentity();
+    }
+#endif
+
     GPUConnectionToWebProcess& m_process;
 };
 

Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -53,6 +53,10 @@
 #include <CoreGraphics/CGDisplayConfiguration.h>
 #endif
 
+#if PLATFORM(COCOA)
+#include <pal/spi/cocoa/TCCSPI.h>
+#endif
+
 namespace WebCore {
 class SecurityOrigin;
 struct SecurityOriginData;
@@ -123,6 +127,11 @@
     bool allowsVideoCapture() const { return m_allowsVideoCapture; }
     bool allowsDisplayCapture() const { return m_allowsDisplayCapture; }
 #endif
+
+#if ENABLE(APP_PRIVACY_REPORT)
+    void setTCCIdentity();
+#endif
+
 #if PLATFORM(MAC)
     void displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags);
 #endif

Modified: branches/safari-612-branch/Source/WebKit/GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm	2021-10-27 21:05:46 UTC (rev 284946)
@@ -31,8 +31,12 @@
 #import "MediaPermissionUtilities.h"
 #import "SystemStatusSPI.h"
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/RealtimeMediaSourceCenter.h>
 #import <WebCore/RegistrableDomain.h>
 #import <WebCore/SecurityOrigin.h>
+#import <pal/spi/cocoa/LaunchServicesSPI.h>
+
+#import "TCCSoftLink.h"
 #import <pal/ios/SystemStatusSoftLink.h>
 
 namespace WebKit {
@@ -61,6 +65,26 @@
 }
 #endif // ENABLE(MEDIA_STREAM)
 
+#if ENABLE(APP_PRIVACY_REPORT)
+void GPUConnectionToWebProcess::setTCCIdentity()
+{
+    auto auditToken = gpuProcess().parentProcessConnection()->getAuditToken();
+    if (!auditToken)
+        return;
+
+    NSError *error = nil;
+    auto bundleProxy = [LSBundleProxy bundleProxyWithAuditToken:*auditToken error:&error];
+    if (error)
+        return;
+
+    tcc_identity_t identity = nil;
+    identity = tcc_identity_create(TCC_IDENTITY_CODE_BUNDLE_ID, [bundleProxy.bundleIdentifier UTF8String]);
+    if (!identity)
+        return;
+
+    WebCore::RealtimeMediaSourceCenter::singleton().setIdentity(identity);
+}
+#endif
 } // namespace WebKit
 
 #endif // ENABLE(GPU_PROCESS)

Deleted: branches/safari-612-branch/Source/WebKit/Platform/spi/ios/TCCSPI.h (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/Platform/spi/ios/TCCSPI.h	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/Platform/spi/ios/TCCSPI.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2014-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.
- */
-
-#if USE(APPLE_INTERNAL_SDK)
-
-#import <TCC/TCC.h>
-
-#else
-
-typedef enum {
-    kTCCAccessPreflightGranted,
-    kTCCAccessPreflightDenied,
-} TCCAccessPreflightResult;
-
-#endif

Modified: branches/safari-612-branch/Source/WebKit/Shared/Cocoa/TCCSoftLink.h (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/Shared/Cocoa/TCCSoftLink.h	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/Shared/Cocoa/TCCSoftLink.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#import "TCCSPI.h"
+#import <pal/spi/cocoa/TCCSPI.h>
 
 #import <wtf/SoftLinking.h>
 
@@ -43,3 +43,5 @@
 #define TCCAccessPreflight WebKit::softLink_TCC_TCCAccessPreflight
 SOFT_LINK_FUNCTION_FOR_HEADER(WebKit, TCC, TCCAccessPreflightWithAuditToken, TCCAccessPreflightResult, (CFStringRef service, audit_token_t token, CFDictionaryRef options), (service, token, options))
 #define TCCAccessPreflightWithAuditToken WebKit::softLink_TCC_TCCAccessPreflightWithAuditToken
+SOFT_LINK_FUNCTION_FOR_HEADER(WebKit, TCC, tcc_identity_create, tcc_identity_t, (tcc_identity_type_t type, const char * identifier), (type, identifier));
+#define tcc_identity_create WebKit::softLink_TCC_tcc_identity_create

Modified: branches/safari-612-branch/Source/WebKit/Shared/Cocoa/TCCSoftLink.mm (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/Shared/Cocoa/TCCSoftLink.mm	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/Shared/Cocoa/TCCSoftLink.mm	2021-10-27 21:05:46 UTC (rev 284946)
@@ -25,7 +25,7 @@
 
 #import "config.h"
 
-#import "TCCSPI.h"
+#import <pal/spi/cocoa/TCCSPI.h>
 
 #import <wtf/SoftLinking.h>
 
@@ -40,3 +40,4 @@
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebKit, TCC, TCCAccessCheckAuditToken, Boolean, (CFStringRef service, audit_token_t auditToken, CFDictionaryRef options), (service, auditToken, options))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebKit, TCC, TCCAccessPreflight, TCCAccessPreflightResult, (CFStringRef service, CFDictionaryRef options), (service, options))
 SOFT_LINK_FUNCTION_FOR_SOURCE(WebKit, TCC, TCCAccessPreflightWithAuditToken, TCCAccessPreflightResult, (CFStringRef service, audit_token_t token, CFDictionaryRef options), (service, token, options))
+SOFT_LINK_FUNCTION_FOR_SOURCE(WebKit, TCC, tcc_identity_create, tcc_identity_t, (tcc_identity_type_t type, const char * identifier), (type, identifier));

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp	2021-10-27 21:05:46 UTC (rev 284946)
@@ -331,6 +331,9 @@
         return;
     }
 
+#if ENABLE(APP_PRIVACY_REPORT)
+    m_connectionProxy->setTCCIdentity();
+#endif
     proxy->start();
 }
 

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h	2021-10-27 21:05:46 UTC (rev 284946)
@@ -34,6 +34,7 @@
 #include <WebCore/OrientationNotifier.h>
 #include <WebCore/RealtimeMediaSource.h>
 #include <WebCore/RealtimeMediaSourceIdentifier.h>
+#include <pal/spi/cocoa/TCCSPI.h>
 #include <wtf/UniqueRef.h>
 
 namespace WebCore {
@@ -58,6 +59,9 @@
         virtual bool willStartCapture(WebCore::CaptureDevice::DeviceType) const = 0;
         virtual Logger& logger() = 0;
         virtual bool setCaptureAttributionString() { return true; }
+#if ENABLE(APP_PRIVACY_REPORT)
+        virtual void setTCCIdentity() { }
+#endif
     };
     explicit UserMediaCaptureManagerProxy(UniqueRef<ConnectionProxy>&&);
     ~UserMediaCaptureManagerProxy();

Modified: branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/UIProcess/Cocoa/UserMediaPermissionRequestManagerProxy.mm	2021-10-27 21:05:46 UTC (rev 284946)
@@ -28,10 +28,10 @@
 
 #import "MediaPermissionUtilities.h"
 #import "SandboxUtilities.h"
-#import "TCCSPI.h"
 #import "WebPageProxy.h"
 #import "WebPreferences.h"
 #import <WebCore/RuntimeApplicationChecks.h>
+#import <pal/spi/cocoa/TCCSPI.h>
 #import <wtf/BlockPtr.h>
 #import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
 

Modified: branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2021-10-27 21:05:46 UTC (rev 284946)
@@ -1960,7 +1960,6 @@
 		CDF1B915266F396A0007EC10 /* WKGroupSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF1B90D266F395E0007EC10 /* WKGroupSession.swift */; };
 		CDF1B91B267025550007EC10 /* WebKitSwiftSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDF1B91A267021D60007EC10 /* WebKitSwiftSoftLink.mm */; };
 		CE11AD521CBC482F00681EE5 /* CodeSigning.h in Headers */ = {isa = PBXBuildFile; fileRef = CE11AD511CBC482F00681EE5 /* CodeSigning.h */; };
-		CE1A0BD61A48E6C60054EF74 /* TCCSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */; };
 		CE1A0BD71A48E6C60054EF74 /* TextInputSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */; };
 		CE21215F240EE571006ED443 /* WKTextPlaceholder.h in Headers */ = {isa = PBXBuildFile; fileRef = CE21215D240EE571006ED443 /* WKTextPlaceholder.h */; };
 		CE212160240EE571006ED443 /* WKTextPlaceholder.mm in Sources */ = {isa = PBXBuildFile; fileRef = CE21215E240EE571006ED443 /* WKTextPlaceholder.mm */; };
@@ -5904,7 +5903,6 @@
 		CDF1B91A267021D60007EC10 /* WebKitSwiftSoftLink.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitSwiftSoftLink.mm; sourceTree = "<group>"; };
 		CE11AD4F1CBC47F800681EE5 /* CodeSigning.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CodeSigning.mm; sourceTree = "<group>"; };
 		CE11AD511CBC482F00681EE5 /* CodeSigning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeSigning.h; sourceTree = "<group>"; };
-		CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCCSPI.h; sourceTree = "<group>"; };
 		CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextInputSPI.h; sourceTree = "<group>"; };
 		CE21215D240EE571006ED443 /* WKTextPlaceholder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKTextPlaceholder.h; path = ios/WKTextPlaceholder.h; sourceTree = "<group>"; };
 		CE21215E240EE571006ED443 /* WKTextPlaceholder.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKTextPlaceholder.mm; path = ios/WKTextPlaceholder.mm; sourceTree = "<group>"; };
@@ -11710,7 +11708,6 @@
 				2D279E1826955768004B3EEB /* PrototypeToolsSPI.h */,
 				46F38E8B2416E66D0059375A /* RunningBoardServicesSPI.h */,
 				079D1D9926960CD300883577 /* SystemStatusSPI.h */,
-				CE1A0BD01A48E6C60054EF74 /* TCCSPI.h */,
 				CE1A0BD11A48E6C60054EF74 /* TextInputSPI.h */,
 				CEE4AE2A1A5DCF430002F49B /* UIKitSPI.h */,
 			);
@@ -12560,7 +12557,6 @@
 				079D1D9A26960CD300883577 /* SystemStatusSPI.h in Headers */,
 				F4D985CB2691096600BBCCBE /* TapHandlingResult.h in Headers */,
 				44C51844266BE8C4006DD522 /* TCCSoftLink.h in Headers */,
-				CE1A0BD61A48E6C60054EF74 /* TCCSPI.h in Headers */,
 				1AA417CB12C00CCA002BE67B /* TextChecker.h in Headers */,
 				53CFBBC82224D1B500266546 /* TextCheckerCompletion.h in Headers */,
 				1A5E4DA412D3BD3D0099A2BB /* TextCheckerState.h in Headers */,

Modified: branches/safari-612-branch/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp (284945 => 284946)


--- branches/safari-612-branch/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2021-10-27 21:05:39 UTC (rev 284945)
+++ branches/safari-612-branch/Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp	2021-10-27 21:05:46 UTC (rev 284946)
@@ -71,6 +71,7 @@
 
 void UserMediaCaptureManager::setupCaptureProcesses(bool shouldCaptureAudioInUIProcess, bool shouldCaptureAudioInGPUProcess, bool shouldCaptureVideoInUIProcess, bool shouldCaptureVideoInGPUProcess, bool shouldCaptureDisplayInUIProcess)
 {
+    // FIXME(rdar://84278146): Adopt AVCaptureSession attribution API for camera access in the web process if shouldCaptureVideoInGPUProcess is false.
     MockRealtimeMediaSourceCenter::singleton().setMockAudioCaptureEnabled(!shouldCaptureAudioInUIProcess && !shouldCaptureAudioInGPUProcess);
     MockRealtimeMediaSourceCenter::singleton().setMockVideoCaptureEnabled(!shouldCaptureVideoInUIProcess && !shouldCaptureVideoInGPUProcess);
     MockRealtimeMediaSourceCenter::singleton().setMockDisplayCaptureEnabled(!shouldCaptureDisplayInUIProcess);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to