Skip to content
Permalink
Browse files
[iOS] Dynamically set capture attribution
https://bugs.webkit.org/show_bug.cgi?id=227871
rdar://70241665

Reviewed by Jer Noble.

Source/WebCore:

No new tests, tested manually.

* en.lproj/Localizable.strings:

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj:
* pal/ios/SystemStatusSoftLink.h: Added.
* pal/ios/SystemStatusSoftLink.mm: Added.

Source/WebKit:

* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::GPUConnectionToWebProcess): Initialize m_captureOrigin.
(WebKit::GPUConnectionToWebProcess::updateCaptureOrigin): Update.
(WebKit::GPUConnectionToWebProcess::setCaptureAttributionString const): Non-Cocoa stub.
* GPUProcess/GPUConnectionToWebProcess.h:

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::updateCaptureOrigin): Call same method in WebProcessConnection,
if it exists.
* GPUProcess/GPUProcess.h:
* GPUProcess/GPUProcess.messages.in:

* GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm: Added.
(WebKit::GPUConnectionToWebProcess::setCaptureAttributionString): Set the attribution
string to "[domain] in [application]".

* Platform/spi/ios/SystemStatusSPI.h: Added.
* Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb: Allow "com.apple.systemstatus.activityattribution"
to be looked up.

* Scripts/process-entitlements.sh: Add the entitlements required to use the
SystemStatus SPI.

* SourcesCocoa.txt:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::startProducingData): Fail capture
if setCaptureAttributionString returns false.
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
(WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setCaptureAttributionString):

* UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::updateCaptureOrigin): Call gpuProcess.updateCaptureOrigin
so the capture origin is correct when capture begins.
* UIProcess/GPU/GPUProcessProxy.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didChangeMainDocument): Update the capture origin.
(WebKit::WebPageProxy::willStartCapture): Ditto.
(WebKit::WebPageProxy::gpuProcessExited): Drive-by - update local variable names
to make their purpose clearer.
* WebKit.xcodeproj/project.pbxproj:


Canonical link: https://commits.webkit.org/239661@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eric-carlson committed Jul 14, 2021
1 parent 71ddf46 commit cb18053524fe55b69558477bf7d8f6344aeedf69
Showing 23 changed files with 357 additions and 10 deletions.
@@ -1,3 +1,15 @@
2021-07-14 Eric Carlson <eric.carlson@apple.com>

[iOS] Dynamically set capture attribution
https://bugs.webkit.org/show_bug.cgi?id=227871
rdar://70241665

Reviewed by Jer Noble.

No new tests, tested manually.

* en.lproj/Localizable.strings:

2021-07-14 Said Abou-Hallawa <said@apple.com>

RenderElement::updateFillImages must fix the clients of the CSS image whose URL is invalid
@@ -1,3 +1,15 @@
2021-07-14 Eric Carlson <eric.carlson@apple.com>

[iOS] Dynamically set capture attribution
https://bugs.webkit.org/show_bug.cgi?id=227871
rdar://70241665

Reviewed by Jer Noble.

* PAL.xcodeproj/project.pbxproj:
* pal/ios/SystemStatusSoftLink.h: Added.
* pal/ios/SystemStatusSoftLink.mm: Added.

2021-07-09 Jer Noble <jer.noble@apple.com>

[Cocoa] Make Coordinator playback commands more precise
@@ -25,6 +25,8 @@
07611DB7243FA5BF00D80704 /* UsageTrackingSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07611DB5243FA5BF00D80704 /* UsageTrackingSoftLink.mm */; };
077E87B1226A460200A2AFF0 /* AVFoundationSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 077E87AF226A460200A2AFF0 /* AVFoundationSoftLink.mm */; };
077E87B2226A460300A2AFF0 /* AVFoundationSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 077E87B0226A460200A2AFF0 /* AVFoundationSoftLink.h */; };
079D1D9726950DD700883577 /* SystemStatusSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 079D1D9526950DD700883577 /* SystemStatusSoftLink.h */; };
079D1D9826950DD700883577 /* SystemStatusSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 079D1D9626950DD700883577 /* SystemStatusSoftLink.mm */; };
0C00CFD41F68CE4600AAC26D /* MediaTimeAVFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C00CFD21F68CE4600AAC26D /* MediaTimeAVFoundation.h */; };
0C2D9E731EEF5AF600DBC317 /* ExportMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C2D9E721EEF5AF600DBC317 /* ExportMacros.h */; };
0C2DA06D1F33CA8400DBC317 /* CFLocaleSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C2DA0671F33CA8400DBC317 /* CFLocaleSPI.h */; };
@@ -236,6 +238,8 @@
07611DB5243FA5BF00D80704 /* UsageTrackingSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UsageTrackingSoftLink.mm; sourceTree = "<group>"; };
077E87AF226A460200A2AFF0 /* AVFoundationSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVFoundationSoftLink.mm; sourceTree = "<group>"; };
077E87B0226A460200A2AFF0 /* AVFoundationSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationSoftLink.h; sourceTree = "<group>"; };
079D1D9526950DD700883577 /* SystemStatusSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SystemStatusSoftLink.h; sourceTree = "<group>"; };
079D1D9626950DD700883577 /* SystemStatusSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemStatusSoftLink.mm; sourceTree = "<group>"; };
0C00CFD11F68CE4600AAC26D /* MediaTimeAVFoundation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTimeAVFoundation.cpp; sourceTree = "<group>"; };
0C00CFD21F68CE4600AAC26D /* MediaTimeAVFoundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTimeAVFoundation.h; sourceTree = "<group>"; };
0C2D9E721EEF5AF600DBC317 /* ExportMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExportMacros.h; sourceTree = "<group>"; };
@@ -764,6 +768,8 @@
5C7C787223AC3E770065F47E /* ManagedConfigurationSoftLink.mm */,
4450FC9E21F5F602004DFA56 /* QuickLookSoftLink.h */,
4450FC9D21F5F602004DFA56 /* QuickLookSoftLink.mm */,
079D1D9526950DD700883577 /* SystemStatusSoftLink.h */,
079D1D9626950DD700883577 /* SystemStatusSoftLink.mm */,
2E1342CA215AA10A007199D2 /* UIKitSoftLink.h */,
2E1342CB215AA10A007199D2 /* UIKitSoftLink.mm */,
);
@@ -997,6 +1003,7 @@
31308B1420A21705003FB929 /* SystemPreviewSPI.h in Headers */,
A3AB6E581F3D1DDB009C14B1 /* SystemSleepListener.h in Headers */,
A3AB6E641F3D217F009C14B1 /* SystemSleepListenerMac.h in Headers */,
079D1D9726950DD700883577 /* SystemStatusSoftLink.h in Headers */,
0C7785A11F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h in Headers */,
2E1342CC215AA10A007199D2 /* UIKitSoftLink.h in Headers */,
0C5AF9221F43A4C7002EAC02 /* UIKitSPI.h in Headers */,
@@ -1134,6 +1141,7 @@
93B38EC025821CD800198E63 /* SpeechSoftLink.mm in Sources */,
A3AB6E571F3D1DDB009C14B1 /* SystemSleepListener.cpp in Sources */,
A3AB6E651F3D217F009C14B1 /* SystemSleepListenerMac.mm in Sources */,
079D1D9826950DD700883577 /* SystemStatusSoftLink.mm in Sources */,
2E1342CD215AA10A007199D2 /* UIKitSoftLink.mm in Sources */,
07611DB7243FA5BF00D80704 /* UsageTrackingSoftLink.mm in Sources */,
41E1F344248A6A000022D5DE /* VideoToolboxSoftLink.cpp in Sources */,
@@ -0,0 +1,36 @@
/*
* Copyright (C) 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 PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)

#import <wtf/SoftLinking.h>

SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, SystemStatus)

SOFT_LINK_CLASS_FOR_HEADER(PAL, STDynamicActivityAttributionPublisher);

#endif
@@ -0,0 +1,36 @@
/*
* Copyright (C) 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"

#if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)

#import <wtf/SoftLinking.h>

SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE(PAL, SystemStatus)

SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, SystemStatus, STDynamicActivityAttributionPublisher, PAL_EXPORT);

#endif
@@ -1636,3 +1636,5 @@
/* Option in segmented control for choosing list type in text editing */
"•" = "•";

/* The domain and application using the camera and/or microphone. The first argument is domain, the second is the application name (iOS only). */
"“%@” in “%%@”" = "“%@” in “%%@”";
@@ -1,3 +1,53 @@
2021-07-14 Eric Carlson <eric.carlson@apple.com>

[iOS] Dynamically set capture attribution
https://bugs.webkit.org/show_bug.cgi?id=227871
rdar://70241665

Reviewed by Jer Noble.

* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::GPUConnectionToWebProcess): Initialize m_captureOrigin.
(WebKit::GPUConnectionToWebProcess::updateCaptureOrigin): Update.
(WebKit::GPUConnectionToWebProcess::setCaptureAttributionString const): Non-Cocoa stub.
* GPUProcess/GPUConnectionToWebProcess.h:

* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::updateCaptureOrigin): Call same method in WebProcessConnection,
if it exists.
* GPUProcess/GPUProcess.h:
* GPUProcess/GPUProcess.messages.in:

* GPUProcess/cocoa/GPUConnectionToWebProcessCocoa.mm: Added.
(WebKit::GPUConnectionToWebProcess::setCaptureAttributionString): Set the attribution
string to "[domain] in [application]".

* Platform/spi/ios/SystemStatusSPI.h: Added.
* Resources/SandboxProfiles/ios/com.apple.WebKit.GPU.sb: Allow "com.apple.systemstatus.activityattribution"
to be looked up.

* Scripts/process-entitlements.sh: Add the entitlements required to use the
SystemStatus SPI.

* SourcesCocoa.txt:
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp:
(WebKit::UserMediaCaptureManagerProxy::startProducingData): Fail capture
if setCaptureAttributionString returns false.
* UIProcess/Cocoa/UserMediaCaptureManagerProxy.h:
(WebKit::UserMediaCaptureManagerProxy::ConnectionProxy::setCaptureAttributionString):

* UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::updateCaptureOrigin): Call gpuProcess.updateCaptureOrigin
so the capture origin is correct when capture begins.
* UIProcess/GPU/GPUProcessProxy.h:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didChangeMainDocument): Update the capture origin.
(WebKit::WebPageProxy::willStartCapture): Ditto.
(WebKit::WebPageProxy::gpuProcessExited): Drive-by - update local variable names
to make their purpose clearer.
* WebKit.xcodeproj/project.pbxproj:

2021-07-13 Wenson Hsieh <wenson_hsieh@apple.com>

[WK2] Push OS state dumping logic down from WebProcess to AuxiliaryProcess
@@ -139,6 +139,10 @@
#include "LocalAudioSessionRoutingArbitrator.h"
#endif

#if ENABLE(MEDIA_STREAM)
#include <WebCore/SecurityOrigin.h>
#endif

namespace WebKit {
using namespace WebCore;

@@ -178,9 +182,15 @@ class GPUProxyForCapture final : public UserMediaCaptureManagerProxy::Connection
return m_process.allowsDisplayCapture();
}
}

bool setCaptureAttributionString() final
{
return m_process.setCaptureAttributionString();
}

GPUConnectionToWebProcess& m_process;
};

#endif

Ref<GPUConnectionToWebProcess> GPUConnectionToWebProcess::create(GPUProcess& gpuProcess, WebCore::ProcessIdentifier webProcessIdentifier, IPC::Connection::Identifier connectionIdentifier, PAL::SessionID sessionID, GPUProcessConnectionParameters&& parameters)
@@ -203,6 +213,9 @@ GPUConnectionToWebProcess::GPUConnectionToWebProcess(GPUProcess& gpuProcess, Web
#if PLATFORM(COCOA) && ENABLE(MEDIA_STREAM)
, m_sampleBufferDisplayLayerManager(RemoteSampleBufferDisplayLayerManager::create(*this))
#endif
#if ENABLE(MEDIA_STREAM)
, m_captureOrigin(SecurityOrigin::createUnique())
#endif
#if ENABLE(ROUTING_ARBITRATION) && HAVE(AVAUDIO_ROUTING_ARBITER)
, m_routingArbitrator(LocalAudioSessionRoutingArbitrator::create(*this))
#endif
@@ -820,7 +833,18 @@ void GPUConnectionToWebProcess::updateCaptureAccess(bool allowAudioCapture, bool
m_allowsVideoCapture |= allowVideoCapture;
m_allowsDisplayCapture |= allowDisplayCapture;
}

void GPUConnectionToWebProcess::updateCaptureOrigin(const WebCore::SecurityOriginData& originData)
{
m_captureOrigin = originData.securityOrigin();
}

#if !PLATFORM(COCOA)
bool GPUConnectionToWebProcess::setCaptureAttributionString() const
{
}
#endif
#endif // ENABLE(MEDIA_STREAM)

#if PLATFORM(MAC)
void GPUConnectionToWebProcess::displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags flags)
@@ -37,6 +37,7 @@
#include "ScopedActiveMessageReceiveQueue.h"
#include <WebCore/LibWebRTCEnumTraits.h>
#include <WebCore/NowPlayingManager.h>
#include <WebCore/PageIdentifier.h>
#include <WebCore/ProcessIdentifier.h>
#include <pal/SessionID.h>
#include <wtf/Logger.h>
@@ -52,6 +53,11 @@
#include <CoreGraphics/CGDisplayConfiguration.h>
#endif

namespace WebCore {
class SecurityOrigin;
struct SecurityOriginData;
}

namespace WebKit {

class GPUProcess;
@@ -111,6 +117,8 @@ class GPUConnectionToWebProcess
#if ENABLE(MEDIA_STREAM)
void setOrientationForMediaCapture(uint64_t orientation);
void updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture);
void updateCaptureOrigin(const WebCore::SecurityOriginData&);
bool setCaptureAttributionString();
bool allowsAudioCapture() const { return m_allowsAudioCapture; }
bool allowsVideoCapture() const { return m_allowsVideoCapture; }
bool allowsDisplayCapture() const { return m_allowsDisplayCapture; }
@@ -248,6 +256,7 @@ class GPUConnectionToWebProcess
std::unique_ptr<RemoteMediaRecorderManager> m_remoteMediaRecorderManager;
#endif
#if ENABLE(MEDIA_STREAM)
Ref<WebCore::SecurityOrigin> m_captureOrigin;
bool m_allowsAudioCapture { false };
bool m_allowsVideoCapture { false };
bool m_allowsDisplayCapture { false };
@@ -312,6 +312,12 @@ void GPUProcess::updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapt
completionHandler();
}

void GPUProcess::updateCaptureOrigin(const WebCore::SecurityOriginData& originData, ProcessIdentifier processID)
{
if (auto* connection = webProcessConnection(processID))
connection->updateCaptureOrigin(originData);
}

void GPUProcess::updateSandboxAccess(const Vector<SandboxExtension::Handle>& extensions)
{
for (auto& extension : extensions)
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
* Copyright (C) 2019-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
@@ -45,6 +45,7 @@
namespace WebCore {
class NowPlayingManager;
struct MockMediaDevice;
struct SecurityOriginData;
}

namespace WebKit {
@@ -124,11 +125,13 @@ class GPUProcess : public AuxiliaryProcess, public ThreadSafeRefCounted<GPUProce
void setMockCaptureDevicesEnabled(bool);
void setOrientationForMediaCapture(uint64_t orientation);
void updateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier, CompletionHandler<void()>&&);
void updateCaptureOrigin(const WebCore::SecurityOriginData&, WebCore::ProcessIdentifier);
void updateSandboxAccess(const Vector<SandboxExtension::Handle>&);
void addMockMediaDevice(const WebCore::MockMediaDevice&);
void clearMockMediaDevices();
void removeMockMediaDevice(const String& persistentId);
void resetMockMediaDevices();
bool setCaptureAttributionString(const String&);
#endif
#if PLATFORM(MAC)
void displayConfigurationChanged(CGDirectDisplayID, CGDisplayChangeSummaryFlags);
@@ -41,6 +41,7 @@ messages -> GPUProcess LegacyReceiver {
SetOrientationForMediaCapture(uint64_t orientation);
UpdateSandboxAccess(Vector<WebKit::SandboxExtension::Handle> extensions);
UpdateCaptureAccess(bool allowAudioCapture, bool allowVideoCapture, bool allowDisplayCapture, WebCore::ProcessIdentifier processID) -> () Async
UpdateCaptureOrigin(struct WebCore::SecurityOriginData originData, WebCore::ProcessIdentifier processID)
AddMockMediaDevice(struct WebCore::MockMediaDevice device);
ClearMockMediaDevices();
RemoveMockMediaDevice(String persistentId);

0 comments on commit cb18053

Please sign in to comment.