⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 283316 in webkit


Ignore:
Timestamp:
Sep 30, 2021, 9:22:01 AM (5 years ago)
Author:
wilander@apple.com
Message:

PCM: Take app bundle ID into consideration when matching triggering events with pending clicks
https://bugs.webkit.org/show_bug.cgi?id=230778
<rdar://problem/83516528>

Reviewed by Alex Christensen.

https://commits.webkit.org/r282884 added app bundle IDs to unattributed
and attributed clicks in PCM. This patch makes sure we take those IDs
into consideration in PCM::Database::attributePrivateClickMeasurement().

Source/WebCore:

The WebCore part makes sure that a temporary app bundle ID can be set
on attributions that get stored in PCM's database.

Test: http/tests/privateClickMeasurement/multiple-app-bundle-ids.html

  • loader/PrivateClickMeasurement.cpp:

(WebCore::PrivateClickMeasurement::setSourceApplicationBundleIDForTesting):

  • loader/PrivateClickMeasurement.h:

Source/WebKit:

A lot of the WebKit part is:

  • Piping through app bundle IDs from the network session to the PCM

database where the ID will be matched against stored app bundle IDs.

  • Piping through test configuration for app bundle ID.

The real change is in PCM::Database which is explained below.

Test: http/tests/privateClickMeasurement/multiple-app-bundle-ids.html

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::setPrivateClickMeasurementAppBundleIDForTesting):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::handlePrivateClickMeasurementConversion):
(WebKit::NetworkSession::setPrivateClickMeasurementAppBundleIDForTesting):

  • NetworkProcess/NetworkSession.h:
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:

(WebKit::PCM::Database::findPrivateClickMeasurement):

Now takes an app bundle ID supplied from the network session and
includes it in the database query to find matching entries. If and
attribution was saved with app bundle ID XYZ, it should only be
be converted in an application with app bundle ID XYZ.

(WebKit::PCM::Database::attributePrivateClickMeasurement):

This function calls PCM::Database::findPrivateClickMeasurement()
which needs the app bundle ID so that ID is forwarded through.

(WebKit::PCM::Database::removeUnattributed):

Also needs to take the app bundle ID into consideration.

(WebKit::PCM::Database::clearSentAttribution):

Also needs to take the app bundle ID into consideration.

(WebKit::PCM::Database::markReportAsSentToDestination):

Also needs to take the app bundle ID into consideration.

(WebKit::PCM::Database::markReportAsSentToSource):

Also needs to take the app bundle ID into consideration.

(WebKit::PCM::Database::earliestTimesToSend):

Also needs to take the app bundle ID into consideration.

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h:
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp:

(WebKit::PrivateClickMeasurementManager::storeUnattributed):
(WebKit::PrivateClickMeasurementManager::handleAttribution):
(WebKit::PrivateClickMeasurementManager::setPrivateClickMeasurementAppBundleIDForTesting):
(WebKit::PrivateClickMeasurementManager::attribute):
(WebKit::PrivateClickMeasurementManager::clear):

Clears the test setting for app bundle ID.

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.h:
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp:

(WebKit::PCM::messageTypeSendsReply):
(WebKit::PCM::decodeMessageAndSendToManager):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h:
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp:

(WebKit::PCM::ManagerProxy::handleAttribution):
(WebKit::PCM::ManagerProxy::setPrivateClickMeasurementAppBundleIDForTesting):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h:
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp:

(WebKit::PCM::Store::attributePrivateClickMeasurement):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h:
  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPCMFraudPreventionValuesForTesting):
(WKPageSetPrivateClickMeasurementAppBundleIDForTesting):

  • UIProcess/API/C/WKPagePrivate.h:
  • UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
  • UIProcess/API/Cocoa/WKWebViewTesting.mm:

(-[WKWebView _setPrivateClickMeasurementAppBundleIDForTesting:completionHandler:]):

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::setPrivateClickMeasurementAppBundleIDForTesting):

  • UIProcess/WebPageProxy.h:

Tools:

The TestRunner changes are all test infrastructure to enable different
app bundle IDs in the eyes of PCM. The API test changes are to make use
of the app bundle ID test infrastructure.

  • TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:

(TestWebKitAPI::runBasicEventAttributionTest):
(TestWebKitAPI::TEST):

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setPrivateClickMeasurementAppBundleIDForTesting):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::setPrivateClickMeasurementAppBundleIDForTesting):

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

  • http/tests/privateClickMeasurement/multiple-app-bundle-ids-expected.txt: Added.
  • http/tests/privateClickMeasurement/multiple-app-bundle-ids.html: Added.
  • http/tests/privateClickMeasurement/resources/util.js:

(tearDownAndFinish):

Location:
trunk
Files:
2 added
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r283312 r283316  
     12021-09-30  John Wilander  <wilander@apple.com>
     2
     3        PCM: Take app bundle ID into consideration when matching triggering events with pending clicks
     4        https://bugs.webkit.org/show_bug.cgi?id=230778
     5        <rdar://problem/83516528>
     6
     7        Reviewed by Alex Christensen.
     8
     9        https://commits.webkit.org/r282884 added app bundle IDs to unattributed
     10        and attributed clicks in PCM. This patch makes sure we take those IDs
     11        into consideration in PCM::Database::attributePrivateClickMeasurement().
     12
     13        * http/tests/privateClickMeasurement/multiple-app-bundle-ids-expected.txt: Added.
     14        * http/tests/privateClickMeasurement/multiple-app-bundle-ids.html: Added.
     15        * http/tests/privateClickMeasurement/resources/util.js:
     16        (tearDownAndFinish):
     17
    1182021-09-30  Alan Bujtas  <zalan@apple.com>
    219
  • trunk/LayoutTests/http/tests/privateClickMeasurement/resources/util.js

    r281480 r283316  
    1616        testRunner.setPrivateClickMeasurementTokenSignatureURLForTesting("");
    1717        testRunner.setPrivateClickMeasurementTokenPublicKeyURLForTesting("");
     18        testRunner.setPrivateClickMeasurementAppBundleIDForTesting("");
    1819        testRunner.notifyDone();
    1920    }
  • trunk/Source/WebCore/ChangeLog

    r283315 r283316  
     12021-09-30  John Wilander  <wilander@apple.com>
     2
     3        PCM: Take app bundle ID into consideration when matching triggering events with pending clicks
     4        https://bugs.webkit.org/show_bug.cgi?id=230778
     5        <rdar://problem/83516528>
     6
     7        Reviewed by Alex Christensen.
     8
     9        https://commits.webkit.org/r282884 added app bundle IDs to unattributed
     10        and attributed clicks in PCM. This patch makes sure we take those IDs
     11        into consideration in PCM::Database::attributePrivateClickMeasurement().
     12
     13        The WebCore part makes sure that a temporary app bundle ID can be set
     14        on attributions that get stored in PCM's database.
     15
     16        Test: http/tests/privateClickMeasurement/multiple-app-bundle-ids.html
     17
     18        * loader/PrivateClickMeasurement.cpp:
     19        (WebCore::PrivateClickMeasurement::setSourceApplicationBundleIDForTesting):
     20        * loader/PrivateClickMeasurement.h:
     21
    1222021-09-30  Youenn Fablet  <youenn@apple.com>
    223
  • trunk/Source/WebCore/loader/PrivateClickMeasurement.cpp

    r283313 r283316  
    143143}
    144144
     145void PrivateClickMeasurement::setSourceApplicationBundleIDForTesting(const String& appBundleIDForTesting)
     146{
     147    m_sourceApplicationBundleID = appBundleIDForTesting;
     148}
     149
    145150static Seconds randomlyBetweenTwentyFourAndFortyEightHours()
    146151{
  • trunk/Source/WebCore/loader/PrivateClickMeasurement.h

    r283313 r283316  
    330330    void setAttribution(AttributionTriggerData&& attributionTriggerData) { m_attributionTriggerData = WTFMove(attributionTriggerData); }
    331331    const String& sourceApplicationBundleID() const { return m_sourceApplicationBundleID; }
     332    WEBCORE_EXPORT void setSourceApplicationBundleIDForTesting(const String&);
    332333
    333334    bool isEphemeral() const { return m_isEphemeral == AttributionEphemeral::Yes; }
  • trunk/Source/WebKit/ChangeLog

    r283313 r283316  
     12021-09-30  John Wilander  <wilander@apple.com>
     2
     3        PCM: Take app bundle ID into consideration when matching triggering events with pending clicks
     4        https://bugs.webkit.org/show_bug.cgi?id=230778
     5        <rdar://problem/83516528>
     6
     7        Reviewed by Alex Christensen.
     8
     9        https://commits.webkit.org/r282884 added app bundle IDs to unattributed
     10        and attributed clicks in PCM. This patch makes sure we take those IDs
     11        into consideration in PCM::Database::attributePrivateClickMeasurement().
     12
     13        A lot of the WebKit part is:
     14        - Piping through app bundle IDs from the network session to the PCM
     15            database where the ID will be matched against stored app bundle IDs.
     16        - Piping through test configuration for app bundle ID.
     17
     18        The real change is in PCM::Database which is explained below.
     19
     20        Test: http/tests/privateClickMeasurement/multiple-app-bundle-ids.html
     21
     22        * NetworkProcess/NetworkProcess.cpp:
     23        (WebKit::NetworkProcess::setPrivateClickMeasurementAppBundleIDForTesting):
     24        * NetworkProcess/NetworkProcess.h:
     25        * NetworkProcess/NetworkProcess.messages.in:
     26        * NetworkProcess/NetworkSession.cpp:
     27        (WebKit::NetworkSession::handlePrivateClickMeasurementConversion):
     28        (WebKit::NetworkSession::setPrivateClickMeasurementAppBundleIDForTesting):
     29        * NetworkProcess/NetworkSession.h:
     30        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
     31        (WebKit::PCM::Database::findPrivateClickMeasurement):
     32            Now takes an app bundle ID supplied from the network session and
     33            includes it in the database query to find matching entries. If and
     34            attribution was saved with app bundle ID XYZ, it should only be
     35            be converted in an application with app bundle ID XYZ.
     36        (WebKit::PCM::Database::attributePrivateClickMeasurement):
     37            This function calls PCM::Database::findPrivateClickMeasurement()
     38            which needs the app bundle ID so that ID is forwarded through.
     39        (WebKit::PCM::Database::removeUnattributed):
     40            Also needs to take the app bundle ID into consideration.
     41        (WebKit::PCM::Database::clearSentAttribution):
     42            Also needs to take the app bundle ID into consideration.
     43        (WebKit::PCM::Database::markReportAsSentToDestination):
     44            Also needs to take the app bundle ID into consideration.
     45        (WebKit::PCM::Database::markReportAsSentToSource):
     46            Also needs to take the app bundle ID into consideration.
     47        (WebKit::PCM::Database::earliestTimesToSend):
     48            Also needs to take the app bundle ID into consideration.
     49        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h:
     50        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp:
     51        (WebKit::PrivateClickMeasurementManager::storeUnattributed):
     52        (WebKit::PrivateClickMeasurementManager::handleAttribution):
     53        (WebKit::PrivateClickMeasurementManager::setPrivateClickMeasurementAppBundleIDForTesting):
     54        (WebKit::PrivateClickMeasurementManager::attribute):
     55        (WebKit::PrivateClickMeasurementManager::clear):
     56            Clears the test setting for app bundle ID.
     57        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.h:
     58        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp:
     59        (WebKit::PCM::messageTypeSendsReply):
     60        (WebKit::PCM::decodeMessageAndSendToManager):
     61        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h:
     62        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp:
     63        (WebKit::PCM::ManagerProxy::handleAttribution):
     64        (WebKit::PCM::ManagerProxy::setPrivateClickMeasurementAppBundleIDForTesting):
     65        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h:
     66        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp:
     67        (WebKit::PCM::Store::attributePrivateClickMeasurement):
     68        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h:
     69        * UIProcess/API/C/WKPage.cpp:
     70        (WKPageSetPCMFraudPreventionValuesForTesting):
     71        (WKPageSetPrivateClickMeasurementAppBundleIDForTesting):
     72        * UIProcess/API/C/WKPagePrivate.h:
     73        * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
     74        * UIProcess/API/Cocoa/WKWebViewTesting.mm:
     75        (-[WKWebView _setPrivateClickMeasurementAppBundleIDForTesting:completionHandler:]):
     76        * UIProcess/WebPageProxy.cpp:
     77        (WebKit::WebPageProxy::setPrivateClickMeasurementAppBundleIDForTesting):
     78        * UIProcess/WebPageProxy.h:
     79
    1802021-09-30  Alex Christensen  <achristensen@webkit.org>
    281
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r283295 r283316  
    26902690}
    26912691
     2692void NetworkProcess::setPrivateClickMeasurementAppBundleIDForTesting(PAL::SessionID sessionID, String&& appBundleIDForTesting, CompletionHandler<void()>&& completionHandler)
     2693{
     2694    if (auto* session = networkSession(sessionID))
     2695        session->setPrivateClickMeasurementAppBundleIDForTesting(WTFMove(appBundleIDForTesting));
     2696
     2697    completionHandler();
     2698}
     2699
    26922700void NetworkProcess::addKeptAliveLoad(Ref<NetworkResourceLoader>&& loader)
    26932701{
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r283183 r283316  
    351351    void markPrivateClickMeasurementsAsExpiredForTesting(PAL::SessionID, CompletionHandler<void()>&&);
    352352    void setPCMFraudPreventionValuesForTesting(PAL::SessionID, String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID, CompletionHandler<void()>&&);
     353    void setPrivateClickMeasurementAppBundleIDForTesting(PAL::SessionID, String&& appBundleIDForTesting, CompletionHandler<void()>&&);
    353354
    354355    RefPtr<WebCore::StorageQuotaManager> storageQuotaManager(PAL::SessionID, const WebCore::ClientOrigin&);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r283183 r283316  
    172172    MarkPrivateClickMeasurementsAsExpiredForTesting(PAL::SessionID sessionID) -> () Async
    173173    SetPCMFraudPreventionValuesForTesting(PAL::SessionID sessionID, String secretToken, String unlinkableToken, String signature, String keyID) -> () Async
     174    SetPrivateClickMeasurementAppBundleIDForTesting(PAL::SessionID sessionID, String appBundleIDForTesting) -> () Async
    174175    GetLocalStorageOriginDetails(PAL::SessionID sessionID) -> (Vector<WebKit::LocalStorageDatabaseTracker::OriginDetails> details) Async
    175176
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r283295 r283316  
    4545#include <WebCore/CookieJar.h>
    4646#include <WebCore/ResourceRequest.h>
     47#include <WebCore/RuntimeApplicationChecks.h>
    4748
    4849#if PLATFORM(COCOA)
     50#include "DefaultWebBrowserChecks.h"
    4951#include "NetworkSessionCocoa.h"
    5052#endif
     
    325327void NetworkSession::handlePrivateClickMeasurementConversion(PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData, const URL& requestURL, const WebCore::ResourceRequest& redirectRequest)
    326328{
    327     privateClickMeasurement().handleAttribution(WTFMove(attributionTriggerData), requestURL, RegistrableDomain(redirectRequest.url()), redirectRequest.firstPartyForCookies());
     329#if PLATFORM(COCOA)
     330    auto appBundleID = WebCore::applicationBundleIdentifier();
     331#else
     332    auto appBundleID = String();
     333#endif
     334    privateClickMeasurement().handleAttribution(WTFMove(attributionTriggerData), requestURL, RegistrableDomain(redirectRequest.url()), redirectRequest.firstPartyForCookies(), appBundleID);
    328335}
    329336
     
    392399{
    393400    privateClickMeasurement().allowTLSCertificateChainForLocalPCMTesting(certificateInfo);
     401}
     402
     403void NetworkSession::setPrivateClickMeasurementAppBundleIDForTesting(String&& appBundleIDForTesting)
     404{
     405#if PLATFORM(COCOA)
     406    RELEASE_ASSERT(isRunningTest(WebCore::applicationBundleIdentifier()));
     407#endif
     408    privateClickMeasurement().setPrivateClickMeasurementAppBundleIDForTesting(WTFMove(appBundleIDForTesting));
    394409}
    395410
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r283295 r283316  
    142142    void firePrivateClickMeasurementTimerImmediatelyForTesting();
    143143    void allowTLSCertificateChainForLocalPCMTesting(const WebCore::CertificateInfo&);
     144    void setPrivateClickMeasurementAppBundleIDForTesting(String&&);
    144145
    145146    void addKeptAliveLoad(Ref<NetworkResourceLoader>&&);
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp

    r283227 r283316  
    4444constexpr auto insertAttributedPrivateClickMeasurementQuery = "INSERT OR REPLACE INTO AttributedPrivateClickMeasurement (sourceSiteDomainID, destinationSiteDomainID, "
    4545    "sourceID, attributionTriggerData, priority, timeOfAdClick, earliestTimeToSendToSource, token, signature, keyID, earliestTimeToSendToDestination, sourceApplicationBundleID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s;
    46 constexpr auto findUnattributedQuery = "SELECT * FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
    47 constexpr auto findAttributedQuery = "SELECT * FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
    48 constexpr auto removeUnattributedQuery = "DELETE FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
     46constexpr auto findUnattributedQuery = "SELECT * FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s;
     47constexpr auto findAttributedQuery = "SELECT * FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s;
     48constexpr auto removeUnattributedQuery = "DELETE FROM UnattributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s;
    4949constexpr auto allAttributedPrivateClickMeasurementQuery = "SELECT *, MIN(earliestTimeToSendToSource, earliestTimeToSendToDestination) as minVal "
    5050    "FROM AttributedPrivateClickMeasurement WHERE earliestTimeToSendToSource IS NOT NULL AND earliestTimeToSendToDestination IS NOT NULL "
     
    5353constexpr auto allUnattributedPrivateClickMeasurementAttributionsQuery = "SELECT * FROM UnattributedPrivateClickMeasurement"_s;
    5454constexpr auto clearExpiredPrivateClickMeasurementQuery = "DELETE FROM UnattributedPrivateClickMeasurement WHERE ? > timeOfAdClick"_s;
    55 constexpr auto markReportAsSentToSourceQuery = "UPDATE AttributedPrivateClickMeasurement SET earliestTimeToSendToSource = null WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
    56 constexpr auto markReportAsSentToDestinationQuery = "UPDATE AttributedPrivateClickMeasurement SET earliestTimeToSendToDestination = null WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
    57 constexpr auto earliestTimesToSendQuery = "SELECT earliestTimeToSendToSource, earliestTimeToSendToDestination FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s;
     55constexpr auto markReportAsSentToSourceQuery = "UPDATE AttributedPrivateClickMeasurement SET earliestTimeToSendToSource = null WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s;
     56constexpr auto markReportAsSentToDestinationQuery = "UPDATE AttributedPrivateClickMeasurement SET earliestTimeToSendToDestination = null WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s;
     57constexpr auto earliestTimesToSendQuery = "SELECT earliestTimeToSendToSource, earliestTimeToSendToDestination FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s;
    5858constexpr auto domainIDFromStringQuery = "SELECT domainID FROM PCMObservedDomains WHERE registrableDomain = ?"_s;
    5959constexpr auto domainStringFromDomainIDQuery = "SELECT registrableDomain FROM PCMObservedDomains WHERE domainID = ?"_s;
     
    238238}
    239239
    240 std::pair<std::optional<Database::UnattributedPrivateClickMeasurement>, std::optional<Database::AttributedPrivateClickMeasurement>> Database::findPrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite& sourceSite, const WebCore::PrivateClickMeasurement::AttributionDestinationSite& destinationSite)
     240std::pair<std::optional<Database::UnattributedPrivateClickMeasurement>, std::optional<Database::AttributedPrivateClickMeasurement>> Database::findPrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite& sourceSite, const WebCore::PrivateClickMeasurement::AttributionDestinationSite& destinationSite, const ApplicationBundleIdentifier& applicationBundleIdentifier)
    241241{
    242242    ASSERT(!RunLoop::isMain());
     
    249249    if (!findUnattributedScopedStatement
    250250        || findUnattributedScopedStatement->bindInt(1, *sourceSiteDomainID) != SQLITE_OK
    251         || findUnattributedScopedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK) {
     251        || findUnattributedScopedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK
     252        || findUnattributedScopedStatement->bindText(3, applicationBundleIdentifier) != SQLITE_OK) {
    252253        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::findPrivateClickMeasurement findUnattributedQuery, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
    253254        ASSERT_NOT_REACHED();
     
    257258    if (!findAttributedScopedStatement
    258259        || findAttributedScopedStatement->bindInt(1, *sourceSiteDomainID) != SQLITE_OK
    259         || findAttributedScopedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK) {
     260        || findAttributedScopedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK
     261        || findAttributedScopedStatement->bindText(3, applicationBundleIdentifier) != SQLITE_OK) {
    260262        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::findPrivateClickMeasurement findAttributedQuery, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
    261263        ASSERT_NOT_REACHED();
     
    273275}
    274276
    275 std::pair<std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>, DebugInfo> Database::attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite& sourceSite, const WebCore::PrivateClickMeasurement::AttributionDestinationSite& destinationSite, WebCore::PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData)
     277std::pair<std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>, DebugInfo> Database::attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite& sourceSite, const WebCore::PrivateClickMeasurement::AttributionDestinationSite& destinationSite, const ApplicationBundleIdentifier& applicationBundleIdentifier, WebCore::PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData)
    276278{
    277279    ASSERT(!RunLoop::isMain());
     
    292294    WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData secondsUntilSend { std::nullopt, std::nullopt };
    293295
    294     auto attribution = findPrivateClickMeasurement(sourceSite, destinationSite);
     296    auto attribution = findPrivateClickMeasurement(sourceSite, destinationSite, applicationBundleIdentifier);
    295297    auto& previouslyUnattributed = attribution.first;
    296298    auto& previouslyAttributed = attribution.second;
     
    351353        || scopedStatement->bindInt(1, *sourceSiteDomainID) != SQLITE_OK
    352354        || scopedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK
     355        || scopedStatement->bindText(3, attribution.sourceApplicationBundleID()) != SQLITE_OK
    353356        || scopedStatement->step() != SQLITE_DONE) {
    354357        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::removeUnattributed, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
     
    523526    auto sourceSiteDomainID = domainID(attribution.sourceSite().registrableDomain);
    524527    auto destinationSiteDomainID = domainID(attribution.destinationSite().registrableDomain);
     528    auto sourceApplicationBundleID = attribution.sourceApplicationBundleID();
    525529
    526530    if (!sourceSiteDomainID || !destinationSiteDomainID)
     
    533537            return;
    534538        }
    535         markReportAsSentToSource(*sourceSiteDomainID, *destinationSiteDomainID);
     539        markReportAsSentToSource(*sourceSiteDomainID, *destinationSiteDomainID, sourceApplicationBundleID);
    536540        sourceEarliestTimeToSend = std::nullopt;
    537541        break;
     
    541545            return;
    542546        }
    543         markReportAsSentToDestination(*sourceSiteDomainID, *destinationSiteDomainID);
     547        markReportAsSentToDestination(*sourceSiteDomainID, *destinationSiteDomainID, sourceApplicationBundleID);
    544548        destinationEarliestTimeToSend = std::nullopt;
    545549    }
     
    549553        return;
    550554
    551     auto clearAttributedStatement = m_database.prepareStatement("DELETE FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ?"_s);
     555    auto clearAttributedStatement = m_database.prepareStatement("DELETE FROM AttributedPrivateClickMeasurement WHERE sourceSiteDomainID = ? AND destinationSiteDomainID = ? AND sourceApplicationBundleID = ?"_s);
    552556    if (!clearAttributedStatement
    553557        || clearAttributedStatement->bindInt(1, *sourceSiteDomainID) != SQLITE_OK
    554558        || clearAttributedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK
     559        || clearAttributedStatement->bindText(3, sourceApplicationBundleID) != SQLITE_OK
    555560        || clearAttributedStatement->step() != SQLITE_DONE) {
    556561        RELEASE_LOG_ERROR(PrivateClickMeasurement, "%p - Database::clearSentAttribution failed to step, error message: %" PRIVATE_LOG_STRING, this, m_database.lastErrorMsg());
     
    559564}
    560565
    561 void Database::markReportAsSentToDestination(SourceDomainID sourceSiteDomainID, DestinationDomainID destinationSiteDomainID)
     566void Database::markReportAsSentToDestination(SourceDomainID sourceSiteDomainID, DestinationDomainID destinationSiteDomainID, const ApplicationBundleIdentifier& sourceApplicationBundleID)
    562567{
    563568    ASSERT(!RunLoop::isMain());
     
    567572        || scopedStatement->bindInt(1, sourceSiteDomainID) != SQLITE_OK
    568573        || scopedStatement->bindInt(2, destinationSiteDomainID) != SQLITE_OK
     574        || scopedStatement->bindText(3, sourceApplicationBundleID) != SQLITE_OK
    569575        || scopedStatement->step() != SQLITE_DONE) {
    570576        RELEASE_LOG_ERROR(PrivateClickMeasurement, "Database::markReportAsSentToDestination, error message: %" PUBLIC_LOG_STRING, m_database.lastErrorMsg());
     
    573579}
    574580
    575 void Database::markReportAsSentToSource(SourceDomainID sourceSiteDomainID, DestinationDomainID destinationSiteDomainID)
     581void Database::markReportAsSentToSource(SourceDomainID sourceSiteDomainID, DestinationDomainID destinationSiteDomainID, const ApplicationBundleIdentifier& sourceApplicationBundleID)
    576582{
    577583    ASSERT(!RunLoop::isMain());
     
    581587        || scopedStatement->bindInt(1, sourceSiteDomainID) != SQLITE_OK
    582588        || scopedStatement->bindInt(2, destinationSiteDomainID) != SQLITE_OK
     589        || scopedStatement->bindText(3, sourceApplicationBundleID) != SQLITE_OK
    583590        || scopedStatement->step() != SQLITE_DONE) {
    584591        RELEASE_LOG_ERROR(PrivateClickMeasurement, "Database::markReportAsSentToSource, error message: %" PUBLIC_LOG_STRING, m_database.lastErrorMsg());
     
    601608        || scopedStatement->bindInt(1, *sourceSiteDomainID) != SQLITE_OK
    602609        || scopedStatement->bindInt(2, *destinationSiteDomainID) != SQLITE_OK
     610        || scopedStatement->bindText(3, attribution.sourceApplicationBundleID()) != SQLITE_OK
    603611        || scopedStatement->step() != SQLITE_ROW) {
    604612        RELEASE_LOG_ERROR(PrivateClickMeasurement, "Database::earliestTimesToSend, error message: %" PUBLIC_LOG_STRING, m_database.lastErrorMsg());
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.h

    r283227 r283316  
    4343    virtual ~Database();
    4444   
     45    using ApplicationBundleIdentifier = String;
     46
    4547    static void interruptAllDatabases();
    4648
    4749    void insertPrivateClickMeasurement(WebCore::PrivateClickMeasurement&&, PrivateClickMeasurementAttributionType);
    48     std::pair<std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>, DebugInfo> attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&, WebCore::PrivateClickMeasurement::AttributionTriggerData&&);
     50    std::pair<std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>, DebugInfo> attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&, const ApplicationBundleIdentifier&, WebCore::PrivateClickMeasurement::AttributionTriggerData&&);
    4951    Vector<WebCore::PrivateClickMeasurement> allAttributedPrivateClickMeasurement();
    5052    void clearPrivateClickMeasurement(std::optional<WebCore::RegistrableDomain>);
     
    6769    bool createSchema() final;
    6870    void destroyStatements() final;
    69     std::pair<std::optional<UnattributedPrivateClickMeasurement>, std::optional<AttributedPrivateClickMeasurement>> findPrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&);
     71    std::pair<std::optional<UnattributedPrivateClickMeasurement>, std::optional<AttributedPrivateClickMeasurement>> findPrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&, const ApplicationBundleIdentifier&);
    7072    void removeUnattributed(WebCore::PrivateClickMeasurement&);
    7173    String attributionToStringForTesting(const WebCore::PrivateClickMeasurement&) const;
    72     void markReportAsSentToDestination(SourceDomainID, DestinationDomainID);
    73     void markReportAsSentToSource(SourceDomainID, DestinationDomainID);
     74    void markReportAsSentToDestination(SourceDomainID, DestinationDomainID, const ApplicationBundleIdentifier&);
     75    void markReportAsSentToSource(SourceDomainID, DestinationDomainID, const ApplicationBundleIdentifier&);
    7476    std::pair<std::optional<SourceEarliestTimeToSend>, std::optional<DestinationEarliestTimeToSend>> earliestTimesToSend(const WebCore::PrivateClickMeasurement&);
    7577    std::optional<DomainID> ensureDomainID(const WebCore::RegistrableDomain&);
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp

    r283313 r283316  
    7878    clearExpired();
    7979
     80    if (m_privateClickMeasurementAppBundleIDForTesting)
     81        measurement.setSourceApplicationBundleIDForTesting(*m_privateClickMeasurementAppBundleIDForTesting);
     82
    8083    if (measurement.ephemeralSourceNonce()) {
    8184        auto measurementCopy = measurement;
     
    231234}
    232235
    233 void PrivateClickMeasurementManager::handleAttribution(AttributionTriggerData&& attributionTriggerData, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL)
     236void PrivateClickMeasurementManager::handleAttribution(AttributionTriggerData&& attributionTriggerData, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL, const ApplicationBundleIdentifier& applicationBundleIdentifier)
    234237{
    235238    if (!featureEnabled())
     
    248251    m_client->broadcastConsoleMessage(MessageLevel::Log, "[Private Click Measurement] Triggering event accepted."_s);
    249252
    250     attribute(SourceSite { WTFMove(redirectDomain) }, AttributionDestinationSite { firstPartyURL }, WTFMove(attributionTriggerData));
     253    attribute(SourceSite { WTFMove(redirectDomain) }, AttributionDestinationSite { firstPartyURL }, WTFMove(attributionTriggerData), m_privateClickMeasurementAppBundleIDForTesting ? *m_privateClickMeasurementAppBundleIDForTesting : applicationBundleIdentifier);
    251254}
    252255
     
    256259}
    257260
     261void PrivateClickMeasurementManager::setPrivateClickMeasurementAppBundleIDForTesting(ApplicationBundleIdentifier&& appBundleID)
     262{
     263    if (appBundleID.isEmpty())
     264        m_privateClickMeasurementAppBundleIDForTesting = std::nullopt;
     265    else
     266        m_privateClickMeasurementAppBundleIDForTesting = WTFMove(appBundleID);
     267}
     268
    258269void PrivateClickMeasurementManager::startTimer(Seconds seconds)
    259270{
     
    261272}
    262273
    263 void PrivateClickMeasurementManager::attribute(const SourceSite& sourceSite, const AttributionDestinationSite& destinationSite, AttributionTriggerData&& attributionTriggerData)
     274void PrivateClickMeasurementManager::attribute(const SourceSite& sourceSite, const AttributionDestinationSite& destinationSite, AttributionTriggerData&& attributionTriggerData, const ApplicationBundleIdentifier& applicationBundleIdentifier)
    264275{
    265276    if (!featureEnabled())
     
    274285    }
    275286       
    276     store().attributePrivateClickMeasurement(sourceSite, destinationSite, WTFMove(attributionTriggerData), std::exchange(m_ephemeralMeasurement, std::nullopt), [this, weakThis = makeWeakPtr(*this)] (auto attributionSecondsUntilSendData, auto debugInfo) {
     287    store().attributePrivateClickMeasurement(sourceSite, destinationSite, applicationBundleIdentifier, WTFMove(attributionTriggerData), std::exchange(m_ephemeralMeasurement, std::nullopt), [this, weakThis = makeWeakPtr(*this)] (auto attributionSecondsUntilSendData, auto debugInfo) {
    277288        if (!weakThis)
    278289            return;
     
    437448    m_ephemeralMeasurement = std::nullopt;
    438449    m_isRunningEphemeralMeasurementTest = false;
     450    m_privateClickMeasurementAppBundleIDForTesting = std::nullopt;
    439451
    440452    if (!featureEnabled())
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.h

    r282269 r283316  
    4646    ~PrivateClickMeasurementManager();
    4747
     48    using ApplicationBundleIdentifier = String;
     49
    4850    void storeUnattributed(PrivateClickMeasurement&&) final;
    49     void handleAttribution(AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL) final;
     51    void handleAttribution(AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL, const ApplicationBundleIdentifier&) final;
    5052    void clear(CompletionHandler<void()>&&) final;
    5153    void clearForRegistrableDomain(const RegistrableDomain&, CompletionHandler<void()>&&) final;
     
    6264    void setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID) final;
    6365    void startTimerImmediatelyForTesting() final;
     66    void setPrivateClickMeasurementAppBundleIDForTesting(ApplicationBundleIdentifier&&);
    6467    void destroyStoreForTesting(CompletionHandler<void()>&&) final;
    6568    void allowTLSCertificateChainForLocalPCMTesting(const WebCore::CertificateInfo&) final;
     
    7376    void insertPrivateClickMeasurement(PrivateClickMeasurement&&, PrivateClickMeasurementAttributionType);
    7477    void clearSentAttribution(PrivateClickMeasurement&&, PrivateClickMeasurement::AttributionReportEndpoint);
    75     void attribute(const SourceSite&, const AttributionDestinationSite&, AttributionTriggerData&&);
     78    void attribute(const SourceSite&, const AttributionDestinationSite&, AttributionTriggerData&&, const ApplicationBundleIdentifier&);
    7679    void fireConversionRequest(const PrivateClickMeasurement&, PrivateClickMeasurement::AttributionReportEndpoint);
    7780    void fireConversionRequestImpl(const PrivateClickMeasurement&, PrivateClickMeasurement::AttributionReportEndpoint);
     
    8790    std::optional<URL> m_tokenPublicKeyURLForTesting;
    8891    std::optional<URL> m_tokenSignatureURLForTesting;
     92    std::optional<ApplicationBundleIdentifier> m_privateClickMeasurementAppBundleIDForTesting;
    8993    mutable RefPtr<PCM::Store> m_store;
    9094    String m_storageDirectory;
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp

    r282368 r283316  
    5252
    5353FUNCTION(handleAttribution)
    54 ARGUMENTS(PrivateClickMeasurementManager::AttributionTriggerData, URL, WebCore::RegistrableDomain, URL)
     54ARGUMENTS(PrivateClickMeasurementManager::AttributionTriggerData, URL, WebCore::RegistrableDomain, URL, String)
    5555END
    5656
     
    109109FUNCTION(startTimerImmediatelyForTesting)
    110110ARGUMENTS()
     111END
     112
     113FUNCTION(setPrivateClickMeasurementAppBundleIDForTesting)
     114ARGUMENTS(String)
    111115END
    112116
     
    155159    case MessageType::SetPCMFraudPreventionValuesForTesting:
    156160    case MessageType::StartTimerImmediatelyForTesting:
     161    case MessageType::SetPrivateClickMeasurementAppBundleIDForTesting:
    157162    case MessageType::AllowTLSCertificateChainForLocalPCMTesting:
    158163        return false;
     
    265270        handlePCMMessage<MessageInfo::startTimerImmediatelyForTesting>(WTFMove(encodedMessage));
    266271        break;
     272    case PCM::MessageType::SetPrivateClickMeasurementAppBundleIDForTesting:
     273        handlePCMMessage<MessageInfo::setPrivateClickMeasurementAppBundleIDForTesting>(WTFMove(encodedMessage));
     274        break;
    267275    case PCM::MessageType::DestroyStoreForTesting:
    268276        handlePCMMessageWithReply<MessageInfo::destroyStoreForTesting>(WTFMove(encodedMessage), WTFMove(replySender));
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h

    r282368 r283316  
    5151    using RegistrableDomain = WebCore::RegistrableDomain;
    5252    using SourceSite = WebCore::PrivateClickMeasurement::SourceSite;
     53    using ApplicationBundleIdentifier = String;
    5354
    5455    virtual void storeUnattributed(PrivateClickMeasurement&&) = 0;
    55     virtual void handleAttribution(AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL) = 0;
     56    virtual void handleAttribution(AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL, const ApplicationBundleIdentifier&) = 0;
    5657    virtual void clear(CompletionHandler<void()>&&) = 0;
    5758    virtual void clearForRegistrableDomain(const RegistrableDomain&, CompletionHandler<void()>&&) = 0;
     
    6869    virtual void setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID) = 0;
    6970    virtual void startTimerImmediatelyForTesting() = 0;
     71    virtual void setPrivateClickMeasurementAppBundleIDForTesting(ApplicationBundleIdentifier&&) = 0;
    7072    virtual void destroyStoreForTesting(CompletionHandler<void()>&&) = 0;
    7173    virtual void allowTLSCertificateChainForLocalPCMTesting(const WebCore::CertificateInfo&) = 0;
     
    9294    SetPCMFraudPreventionValuesForTesting,
    9395    StartTimerImmediatelyForTesting,
     96    SetPrivateClickMeasurementAppBundleIDForTesting,
    9497    DestroyStoreForTesting,
    9598    AllowTLSCertificateChainForLocalPCMTesting
     
    128131        WebKit::PCM::MessageType::SetPCMFraudPreventionValuesForTesting,
    129132        WebKit::PCM::MessageType::StartTimerImmediatelyForTesting,
     133        WebKit::PCM::MessageType::SetPrivateClickMeasurementAppBundleIDForTesting,
    130134        WebKit::PCM::MessageType::DestroyStoreForTesting,
    131135        WebKit::PCM::MessageType::AllowTLSCertificateChainForLocalPCMTesting
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp

    r282430 r283316  
    8181}
    8282
    83 void ManagerProxy::handleAttribution(WebCore::PrivateClickMeasurement::AttributionTriggerData&& triggerData, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL)
     83void ManagerProxy::handleAttribution(WebCore::PrivateClickMeasurement::AttributionTriggerData&& triggerData, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL, const ApplicationBundleIdentifier& applicationBundleIdentifier)
    8484{
    85     sendMessage<MessageType::HandleAttribution>(triggerData, requestURL, redirectDomain, firstPartyURL);
     85    sendMessage<MessageType::HandleAttribution>(triggerData, requestURL, redirectDomain, firstPartyURL, applicationBundleIdentifier);
    8686}
    8787
     
    151151}
    152152
     153void ManagerProxy::setPrivateClickMeasurementAppBundleIDForTesting(ApplicationBundleIdentifier&& appBundleID)
     154{
     155    sendMessage<MessageType::SetPrivateClickMeasurementAppBundleIDForTesting>(appBundleID);
     156}
     157
    153158void ManagerProxy::destroyStoreForTesting(CompletionHandler<void()>&& completionHandler)
    154159{
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h

    r282368 r283316  
    4040    ManagerProxy(const String& machServiceName);
    4141
     42    using ApplicationBundleIdentifier = String;
     43
    4244    void storeUnattributed(WebCore::PrivateClickMeasurement&&) final;
    43     void handleAttribution(WebCore::PrivateClickMeasurement::AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL) final;
     45    void handleAttribution(WebCore::PrivateClickMeasurement::AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL, const ApplicationBundleIdentifier&) final;
    4446    void clear(CompletionHandler<void()>&&) final;
    4547    void clearForRegistrableDomain(const WebCore::RegistrableDomain&, CompletionHandler<void()>&&) final;
     
    5658    void setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID) final;
    5759    void startTimerImmediatelyForTesting() final;
     60    void setPrivateClickMeasurementAppBundleIDForTesting(ApplicationBundleIdentifier&&) final;
    5861    void destroyStoreForTesting(CompletionHandler<void()>&&) final;
    5962    void allowTLSCertificateChainForLocalPCMTesting(const WebCore::CertificateInfo&) final;
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp

    r282882 r283316  
    9696}
    9797
    98 void Store::attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite& sourceSite, const WebCore::PrivateClickMeasurement::AttributionDestinationSite& destinationSite, WebCore::PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData, std::optional<WebCore::PrivateClickMeasurement>&& ephemeralMeasurement, CompletionHandler<void(std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>&&, DebugInfo&&)>&& completionHandler)
     98void Store::attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite& sourceSite, const WebCore::PrivateClickMeasurement::AttributionDestinationSite& destinationSite, const ApplicationBundleIdentifier& applicationBundleIdentifier, WebCore::PrivateClickMeasurement::AttributionTriggerData&& attributionTriggerData, std::optional<WebCore::PrivateClickMeasurement>&& ephemeralMeasurement, CompletionHandler<void(std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>&&, DebugInfo&&)>&& completionHandler)
    9999{
    100     postTask([this, protectedThis = Ref { *this }, sourceSite = sourceSite.isolatedCopy(), destinationSite = destinationSite.isolatedCopy(), attributionTriggerData = WTFMove(attributionTriggerData), ephemeralMeasurement = crossThreadCopy(ephemeralMeasurement), completionHandler = WTFMove(completionHandler)] () mutable {
     100    postTask([this, protectedThis = Ref { *this }, sourceSite = sourceSite.isolatedCopy(), destinationSite = destinationSite.isolatedCopy(), applicationBundleIdentifier = applicationBundleIdentifier.isolatedCopy(), attributionTriggerData = WTFMove(attributionTriggerData), ephemeralMeasurement = crossThreadCopy(ephemeralMeasurement), completionHandler = WTFMove(completionHandler)] () mutable {
    101101        if (!m_database) {
    102102            return postTaskReply([completionHandler = WTFMove(completionHandler)] () mutable {
     
    111111        }
    112112
    113         auto [seconds, debugInfo] = m_database->attributePrivateClickMeasurement(sourceSite, destinationSite, WTFMove(attributionTriggerData));
     113        auto [seconds, debugInfo] = m_database->attributePrivateClickMeasurement(sourceSite, destinationSite, applicationBundleIdentifier, WTFMove(attributionTriggerData));
    114114
    115115        postTaskReply([seconds = WTFMove(seconds), debugInfo = debugInfo.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.h

    r281886 r283316  
    4848    ~Store();
    4949
     50    using ApplicationBundleIdentifier = String;
     51
    5052    static void prepareForProcessToSuspend(CompletionHandler<void()>&&);
    5153    static void processDidResume();
    5254
    5355    void insertPrivateClickMeasurement(WebCore::PrivateClickMeasurement&&, WebKit::PrivateClickMeasurementAttributionType);
    54     void attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&, WebCore::PrivateClickMeasurement::AttributionTriggerData&&, std::optional<WebCore::PrivateClickMeasurement>&& ephemeralMeasurement, CompletionHandler<void(std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>&&, DebugInfo&&)>&&);
     56    void attributePrivateClickMeasurement(const WebCore::PrivateClickMeasurement::SourceSite&, const WebCore::PrivateClickMeasurement::AttributionDestinationSite&, const ApplicationBundleIdentifier&, WebCore::PrivateClickMeasurement::AttributionTriggerData&&, std::optional<WebCore::PrivateClickMeasurement>&& ephemeralMeasurement, CompletionHandler<void(std::optional<WebCore::PrivateClickMeasurement::AttributionSecondsUntilSendData>&&, DebugInfo&&)>&&);
    5557
    5658    void privateClickMeasurementToStringForTesting(CompletionHandler<void(String)>&&) const;
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r283033 r283316  
    31393139}
    31403140
     3141void WKPageSetPrivateClickMeasurementAppBundleIDForTesting(WKPageRef pageRef, WKStringRef appBundleIDForTesting, WKPageSetPrivateClickMeasurementAppBundleIDForTestingFunction callback, void* callbackContext)
     3142{
     3143    CRASH_IF_SUSPENDED;
     3144    toImpl(pageRef)->setPrivateClickMeasurementAppBundleIDForTesting(toWTFString(appBundleIDForTesting), [callbackContext, callback] () {
     3145        callback(callbackContext);
     3146    });
     3147}
     3148
    31413149void WKPageSetMockCameraOrientation(WKPageRef pageRef, uint64_t orientation)
    31423150{
  • trunk/Source/WebKit/UIProcess/API/C/WKPagePrivate.h

    r283033 r283316  
    193193typedef void (*WKPageSetPCMFraudPreventionValuesForTestingFunction)(void* functionContext);
    194194WK_EXPORT void WKPageSetPCMFraudPreventionValuesForTesting(WKPageRef page, WKStringRef secretToken, WKStringRef unlinkableToken, WKStringRef signature, WKStringRef keyID, WKPageSetPCMFraudPreventionValuesForTestingFunction callback, void* callbackContext);
     195typedef void (*WKPageSetPrivateClickMeasurementAppBundleIDForTestingFunction)(void* functionContext);
     196WK_EXPORT void WKPageSetPrivateClickMeasurementAppBundleIDForTesting(WKPageRef pageRef, WKStringRef appBundleIDForTesting, WKPageSetPrivateClickMeasurementAppBundleIDForTestingFunction callback, void* callbackContext);
    195197
    196198WK_EXPORT void WKPageSetMockCameraOrientation(WKPageRef page, uint64_t orientation);
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h

    r282884 r283316  
    104104- (void)_setPrivateClickMeasurementAttributionTokenPublicKeyURLForTesting:(NSURL *)url completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
    105105- (void)_setPrivateClickMeasurementAttributionTokenSignatureURLForTesting:(NSURL *)url completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(12.0), ios(15.0));
     106- (void)_setPrivateClickMeasurementAppBundleIDForTesting:(NSString *)appBundleID completionHandler:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    106107- (void)_dumpPrivateClickMeasurement:(void(^)(NSString *))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    107108
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm

    r283313 r283316  
    355355}
    356356
     357- (void)_setPrivateClickMeasurementAppBundleIDForTesting:(NSString *)appBundleID completionHandler:(void(^)(void))completionHandler
     358{
     359    _page->setPrivateClickMeasurementAppBundleIDForTesting(appBundleID, [completionHandler = makeBlockPtr(completionHandler)] {
     360        completionHandler();
     361    });
     362}
     363
    357364- (void)_dumpPrivateClickMeasurement:(void(^)(NSString *))completionHandler
    358365{
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r283313 r283316  
    1051410514}
    1051510515
     10516void WebPageProxy::setPrivateClickMeasurementAppBundleIDForTesting(const String& appBundleIDForTesting, CompletionHandler<void()>&& completionHandler)
     10517{
     10518    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::SetPrivateClickMeasurementAppBundleIDForTesting(m_websiteDataStore->sessionID(), appBundleIDForTesting), WTFMove(completionHandler));
     10519}
     10520
    1051610521#if ENABLE(SPEECH_SYNTHESIS)
    1051710522
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r283313 r283316  
    17781778    void markPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&&);
    17791779    void setPCMFraudPreventionValuesForTesting(const String& unlinkableToken, const String& secretToken, const String& signature, const String& keyID, CompletionHandler<void()>&&);
     1780    void setPrivateClickMeasurementAppBundleIDForTesting(const String& appBundleIDForTesting, CompletionHandler<void()>&&);
    17801781
    17811782#if ENABLE(SPEECH_SYNTHESIS)
  • trunk/Tools/ChangeLog

    r283313 r283316  
     12021-09-30  John Wilander  <wilander@apple.com>
     2
     3        PCM: Take app bundle ID into consideration when matching triggering events with pending clicks
     4        https://bugs.webkit.org/show_bug.cgi?id=230778
     5        <rdar://problem/83516528>
     6
     7        Reviewed by Alex Christensen.
     8
     9        https://commits.webkit.org/r282884 added app bundle IDs to unattributed
     10        and attributed clicks in PCM. This patch makes sure we take those IDs
     11        into consideration in PCM::Database::attributePrivateClickMeasurement().
     12
     13        The TestRunner changes are all test infrastructure to enable different
     14        app bundle IDs in the eyes of PCM. The API test changes are to make use
     15        of the app bundle ID test infrastructure.
     16
     17        * TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm:
     18        (TestWebKitAPI::runBasicEventAttributionTest):
     19        (TestWebKitAPI::TEST):
     20        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
     21        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     22        (WTR::TestRunner::setPrivateClickMeasurementAppBundleIDForTesting):
     23        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     24        * WebKitTestRunner/TestController.cpp:
     25        (WTR::TestController::setPrivateClickMeasurementAppBundleIDForTesting):
     26        * WebKitTestRunner/TestController.h:
     27        * WebKitTestRunner/TestInvocation.cpp:
     28        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     29
    1302021-09-30  Alex Christensen  <achristensen@webkit.org>
    231
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/EventAttribution.mm

    r283313 r283316  
    154154    [webView _setPrivateClickMeasurementAttributionReportURLsForTesting:serverURL destinationURL:exampleURL() completionHandler:^{
    155155        [webView _setPrivateClickMeasurementOverrideTimerForTesting:YES completionHandler:^{
    156             NSString *html = [NSString stringWithFormat:@"<script>fetch('%@conversionRequestBeforeRedirect',{mode:'no-cors'})</script>", serverURL];
    157             [webView loadHTMLString:html baseURL:exampleURL()];
     156            [webView _setPrivateClickMeasurementAppBundleIDForTesting:@"test.bundle.id" completionHandler:^{
     157                NSString *html = [NSString stringWithFormat:@"<script>fetch('%@conversionRequestBeforeRedirect',{mode:'no-cors'})</script>", serverURL];
     158                [webView loadHTMLString:html baseURL:exampleURL()];
     159            }];
    158160        }];
    159161    }];
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r283114 r283316  
    417417    undefined markPrivateClickMeasurementsAsExpiredForTesting();
    418418    undefined setPrivateClickMeasurementFraudPreventionValuesForTesting(DOMString unlinkableToken, DOMString secretToken, DOMString signature, DOMString keyID);
     419    undefined setPrivateClickMeasurementAppBundleIDForTesting(DOMString appBundleID);
    419420
    420421    // SpeechRecognition
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r283114 r283316  
    21152115}
    21162116
     2117void TestRunner::setPrivateClickMeasurementAppBundleIDForTesting(JSStringRef appBundleID)
     2118{
     2119    postSynchronousPageMessage("SetPrivateClickMeasurementAppBundleIDForTesting",
     2120        toWK(appBundleID));
     2121}
     2122
    21172123bool TestRunner::hasAppBoundSession()
    21182124{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r283114 r283316  
    533533    void setPrivateClickMeasurementEphemeralMeasurementForTesting(bool value);
    534534    void setPrivateClickMeasurementFraudPreventionValuesForTesting(JSStringRef unlinkableToken, JSStringRef secretToken, JSStringRef signature, JSStringRef keyID);
     535    void setPrivateClickMeasurementAppBundleIDForTesting(JSStringRef);
    535536    void simulateResourceLoadStatisticsSessionRestart();
    536537
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r283114 r283316  
    37503750}
    37513751
     3752void TestController::setPrivateClickMeasurementAppBundleIDForTesting(WKStringRef appBundleID)
     3753{
     3754    PrivateClickMeasurementVoidCallbackContext callbackContext(*this);
     3755    WKPageSetPrivateClickMeasurementAppBundleIDForTesting(m_mainWebView->page(), appBundleID, privateClickMeasurementVoidCallback, &callbackContext);
     3756    runUntil(callbackContext.done, noTimeout);
     3757}
     3758
    37523759WKURLRef TestController::currentTestURL() const
    37533760{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r283114 r283316  
    356356    void markPrivateClickMeasurementsAsExpiredForTesting();
    357357    void setPCMFraudPreventionValuesForTesting(WKStringRef unlinkableToken, WKStringRef secretToken, WKStringRef signature, WKStringRef keyID);
     358    void setPrivateClickMeasurementAppBundleIDForTesting(WKStringRef);
    358359
    359360    void didSetAppBoundDomains() const;
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r283114 r283316  
    14241424    }
    14251425
     1426    if (WKStringIsEqualToUTF8CString(messageName, "SetPrivateClickMeasurementAppBundleIDForTesting")) {
     1427        TestController::singleton().setPrivateClickMeasurementAppBundleIDForTesting(stringValue(messageBody));
     1428        return nullptr;
     1429    }
     1430
    14261431    if (WKStringIsEqualToUTF8CString(messageName, "SyncLocalStorage")) {
    14271432        TestController::singleton().syncLocalStorage();
Note: See TracChangeset for help on using the changeset viewer.