Changeset 241049 in webkit


Ignore:
Timestamp:
Feb 6, 2019 2:02:15 PM (5 years ago)
Author:
wilander@apple.com
Message:

Forward Ad Click Attribution data from HTMLAnchorElement::handleClick() to WebKit::NavigationActionData
https://bugs.webkit.org/show_bug.cgi?id=194325
<rdar://problem/47840283>

Reviewed by Chris Dumez.

Source/WebCore:

No new tests. This is just data forwarding. Once the data is stored, I will create
test infrastructure to query it.

  • html/HTMLAnchorElement.cpp:

(WebCore::HTMLAnchorElement::handleClick):

  • loader/AdClickAttribution.h:

(WebCore::AdClickAttribution::encode const):
(WebCore::AdClickAttribution::decode):
(WebCore::AdClickAttribution::Conversion::encode const):
(WebCore::AdClickAttribution::Conversion::decode):

Infrastructure for IPC.

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::urlSelected):
(WebCore::FrameLoader::loadURLIntoChildFrame):
(WebCore::FrameLoader::loadFrameRequest):
(WebCore::FrameLoader::loadURL):

These functions forward the optional WebCore::AdClickAttribution object
FrameLoader::loadURL() creates the NavigationAction object and sets the
WebCore::AdClickAttribution object on there.

  • loader/FrameLoader.h:

(WebCore::FrameLoader::urlSelected):
(WebCore::FrameLoader::loadURL):

  • loader/NavigationAction.h:

(WebCore::NavigationAction::adClickAttribution):
(WebCore::NavigationAction::setAdClickAttribution):

Source/WebKit:

  • Shared/NavigationActionData.cpp:

(WebKit::NavigationActionData::encode const):
(WebKit::NavigationActionData::decode):

  • Shared/NavigationActionData.h:

Now holds an optional WebCore::AdClickAttribution object.

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r241048 r241049  
     12019-02-06  John Wilander  <wilander@apple.com>
     2
     3        Forward Ad Click Attribution data from HTMLAnchorElement::handleClick() to WebKit::NavigationActionData
     4        https://bugs.webkit.org/show_bug.cgi?id=194325
     5        <rdar://problem/47840283>
     6
     7        Reviewed by Chris Dumez.
     8
     9        No new tests. This is just data forwarding. Once the data is stored, I will create
     10        test infrastructure to query it.
     11
     12        * html/HTMLAnchorElement.cpp:
     13        (WebCore::HTMLAnchorElement::handleClick):
     14        * loader/AdClickAttribution.h:
     15        (WebCore::AdClickAttribution::encode const):
     16        (WebCore::AdClickAttribution::decode):
     17        (WebCore::AdClickAttribution::Conversion::encode const):
     18        (WebCore::AdClickAttribution::Conversion::decode):
     19            Infrastructure for IPC.
     20        * loader/FrameLoader.cpp:
     21        (WebCore::FrameLoader::urlSelected):
     22        (WebCore::FrameLoader::loadURLIntoChildFrame):
     23        (WebCore::FrameLoader::loadFrameRequest):
     24        (WebCore::FrameLoader::loadURL):
     25            These functions forward the optional WebCore::AdClickAttribution object
     26            FrameLoader::loadURL() creates the NavigationAction object and sets the
     27            WebCore::AdClickAttribution object on there.
     28        * loader/FrameLoader.h:
     29        (WebCore::FrameLoader::urlSelected):
     30        (WebCore::FrameLoader::loadURL):
     31        * loader/NavigationAction.h:
     32        (WebCore::NavigationAction::adClickAttribution):
     33        (WebCore::NavigationAction::setAdClickAttribution):
     34
    1352019-02-06  Justin Fan  <justin_fan@apple.com>
    236
  • trunk/Source/WebCore/html/HTMLAnchorElement.cpp

    r240911 r241049  
    489489
    490490    auto adClickAttribution = parseAdClickAttribution();
    491     // FIXME: The adClickAttribution should be forwarded to the loader and handled down the pipe. See
    492     // rdar://problem/47650118
    493491    // A matching conversion event needs to happen before the complete ad click attributionURL can be
    494492    // created. Thus, it should be empty for now.
    495     ASSERT_UNUSED(adClickAttribution, !adClickAttribution || adClickAttribution->url().isNull());
    496    
    497     frame->loader().urlSelected(completedURL, effectiveTarget, &event, LockHistory::No, LockBackForwardList::No, shouldSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), newFrameOpenerPolicy, downloadAttribute, systemPreviewInfo);
     493    ASSERT(!adClickAttribution || adClickAttribution->url().isNull());
     494   
     495    frame->loader().urlSelected(completedURL, effectiveTarget, &event, LockHistory::No, LockBackForwardList::No, shouldSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), newFrameOpenerPolicy, downloadAttribute, systemPreviewInfo, WTFMove(adClickAttribution));
    498496
    499497    sendPings(completedURL);
  • trunk/Source/WebCore/loader/AdClickAttribution.h

    r240911 r241049  
    109109        ConversionData data;
    110110        PriorityValue priority;
     111
     112        template<class Encoder> void encode(Encoder&) const;
     113        template<class Decoder> static Optional<Conversion> decode(Decoder&);
    111114    };
    112115
     
    124127    Optional<WallTime> earliestTimeToSend() const { return m_earliestTimeToSend; };
    125128
     129    template<class Encoder> void encode(Encoder&) const;
     130    template<class Decoder> static Optional<AdClickAttribution> decode(Decoder&);
     131
    126132private:
    127133    bool isValid() const;
     
    135141    Optional<WallTime> m_earliestTimeToSend;
    136142};
    137    
     143
     144template<class Encoder>
     145void AdClickAttribution::encode(Encoder& encoder) const
     146{
     147    encoder << m_campaign.id << m_source.registrableDomain << m_destination.registrableDomain << m_timeOfAdClick << m_conversion << m_earliestTimeToSend;
     148}
     149
     150template<class Decoder>
     151Optional<AdClickAttribution> AdClickAttribution::decode(Decoder& decoder)
     152{
     153    Optional<CampaignId> campaignId;
     154    decoder >> campaignId;
     155    if (!campaignId)
     156        return WTF::nullopt;
     157   
     158    Optional<String> sourceRegistrableDomain;
     159    decoder >> sourceRegistrableDomain;
     160    if (!sourceRegistrableDomain)
     161        return WTF::nullopt;
     162   
     163    Optional<String> destinationRegistrableDomain;
     164    decoder >> destinationRegistrableDomain;
     165    if (!destinationRegistrableDomain)
     166        return WTF::nullopt;
     167   
     168    Optional<WallTime> timeOfAdClick;
     169    decoder >> timeOfAdClick;
     170    if (!timeOfAdClick)
     171        return WTF::nullopt;
     172   
     173    Optional<Optional<Conversion>> conversion;
     174    decoder >> conversion;
     175    if (!conversion)
     176        return WTF::nullopt;
     177   
     178    Optional<Optional<WallTime>> earliestTimeToSend;
     179    decoder >> earliestTimeToSend;
     180    if (!earliestTimeToSend)
     181        return WTF::nullopt;
     182   
     183    AdClickAttribution attribution { Campaign { WTFMove(*campaignId) }, Source { WTFMove(*sourceRegistrableDomain) }, Destination { WTFMove(*destinationRegistrableDomain) } };
     184    attribution.m_conversion = WTFMove(*conversion);
     185    attribution.m_earliestTimeToSend = WTFMove(*earliestTimeToSend);
     186   
     187    return attribution;
     188}
     189
     190template<class Encoder>
     191void AdClickAttribution::Conversion::encode(Encoder& encoder) const
     192{
     193    encoder << data << priority;
     194}
     195
     196template<class Decoder>
     197Optional<AdClickAttribution::Conversion> AdClickAttribution::Conversion::decode(Decoder& decoder)
     198{
     199    Optional<ConversionData> data;
     200    decoder >> data;
     201    if (!data)
     202        return WTF::nullopt;
     203   
     204    Optional<PriorityValue> priority;
     205    decoder >> priority;
     206    if (!priority)
     207        return WTF::nullopt;
     208   
     209    return Conversion { WTFMove(*data), Priority { WTFMove(*priority) } };
     210}
     211
    138212} // namespace WebCore
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r241015 r241049  
    381381}
    382382
    383 void FrameLoader::urlSelected(const URL& url, const String& passedTarget, Event* triggeringEvent, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, Optional<NewFrameOpenerPolicy> openerPolicy, const AtomicString& downloadAttribute, const SystemPreviewInfo& systemPreviewInfo)
     383void FrameLoader::urlSelected(const URL& url, const String& passedTarget, Event* triggeringEvent, LockHistory lockHistory, LockBackForwardList lockBackForwardList, ShouldSendReferrer shouldSendReferrer, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, Optional<NewFrameOpenerPolicy> openerPolicy, const AtomicString& downloadAttribute, const SystemPreviewInfo& systemPreviewInfo, Optional<AdClickAttribution>&& adClickAttribution)
    384384{
    385385    auto* frame = lexicalFrameFromCommonVM();
     
    387387
    388388    NewFrameOpenerPolicy newFrameOpenerPolicy = openerPolicy.valueOr(shouldSendReferrer == NeverSendReferrer ? NewFrameOpenerPolicy::Suppress : NewFrameOpenerPolicy::Allow);
    389     urlSelected(FrameLoadRequest(*m_frame.document(), m_frame.document()->securityOrigin(), { url }, passedTarget, lockHistory, lockBackForwardList, shouldSendReferrer, AllowNavigationToInvalidURL::Yes, newFrameOpenerPolicy, shouldOpenExternalURLsPolicy, initiatedByMainFrame, DoNotReplaceDocumentIfJavaScriptURL, downloadAttribute, systemPreviewInfo), triggeringEvent);
    390 }
    391 
    392 void FrameLoader::urlSelected(FrameLoadRequest&& frameRequest, Event* triggeringEvent)
     389    urlSelected(FrameLoadRequest(*m_frame.document(), m_frame.document()->securityOrigin(), { url }, passedTarget, lockHistory, lockBackForwardList, shouldSendReferrer, AllowNavigationToInvalidURL::Yes, newFrameOpenerPolicy, shouldOpenExternalURLsPolicy, initiatedByMainFrame, DoNotReplaceDocumentIfJavaScriptURL, downloadAttribute, systemPreviewInfo), triggeringEvent, WTFMove(adClickAttribution));
     390}
     391
     392void FrameLoader::urlSelected(FrameLoadRequest&& frameRequest, Event* triggeringEvent, Optional<AdClickAttribution>&& adClickAttribution)
    393393{
    394394    RELEASE_LOG_IF_ALLOWED("urlSelected: frame load started (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame());
     
    405405    m_frame.document()->contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(frameRequest.resourceRequest(), ContentSecurityPolicy::InsecureRequestType::Navigation);
    406406
    407     loadFrameRequest(WTFMove(frameRequest), triggeringEvent, { });
     407    loadFrameRequest(WTFMove(frameRequest), triggeringEvent, { }, WTFMove(adClickAttribution));
    408408}
    409409
     
    985985
    986986    FrameLoadRequest frameLoadRequest { *m_frame.document(), m_frame.document()->securityOrigin(), { url }, "_self"_s, LockHistory::No, LockBackForwardList::Yes, ShouldSendReferrer::MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Suppress, ShouldOpenExternalURLsPolicy::ShouldNotAllow, initiatedByMainFrame };
    987     childFrame->loader().loadURL(WTFMove(frameLoadRequest), referer, FrameLoadType::RedirectWithLockedBackForwardList, nullptr, { }, [] { });
     987    childFrame->loader().loadURL(WTFMove(frameLoadRequest), referer, FrameLoadType::RedirectWithLockedBackForwardList, nullptr, { }, WTF::nullopt, [] { });
    988988}
    989989
     
    12411241}
    12421242
    1243 void FrameLoader::loadFrameRequest(FrameLoadRequest&& request, Event* event, RefPtr<FormState>&& formState)
     1243void FrameLoader::loadFrameRequest(FrameLoadRequest&& request, Event* event, RefPtr<FormState>&& formState, Optional<AdClickAttribution>&& adClickAttribution)
    12441244{
    12451245    RELEASE_LOG_IF_ALLOWED("loadFrameRequest: frame load started (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame());
     
    12881288        loadPostRequest(WTFMove(request), referrer, loadType, event, WTFMove(formState), WTFMove(completionHandler));
    12891289    else
    1290         loadURL(WTFMove(request), referrer, loadType, event, WTFMove(formState), WTFMove(completionHandler));
     1290        loadURL(WTFMove(request), referrer, loadType, event, WTFMove(formState), WTFMove(adClickAttribution), WTFMove(completionHandler));
    12911291}
    12921292
     
    13301330}
    13311331
    1332 void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& referrer, FrameLoadType newLoadType, Event* event, RefPtr<FormState>&& formState, CompletionHandler<void()>&& completionHandler)
     1332void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& referrer, FrameLoadType newLoadType, Event* event, RefPtr<FormState>&& formState, Optional<AdClickAttribution>&& adClickAttribution, CompletionHandler<void()>&& completionHandler)
    13331333{
    13341334    RELEASE_LOG_IF_ALLOWED("loadURL: frame load started (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame());
     
    13671367    if (targetFrame && targetFrame != &m_frame) {
    13681368        frameLoadRequest.setFrameName("_self");
    1369         targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, WTFMove(formState), completionHandlerCaller.release());
     1369        targetFrame->loader().loadURL(WTFMove(frameLoadRequest), referrer, newLoadType, event, WTFMove(formState), WTFMove(adClickAttribution), completionHandlerCaller.release());
    13701370        return;
    13711371    }
     
    13771377    action.setLockHistory(lockHistory);
    13781378    action.setLockBackForwardList(frameLoadRequest.lockBackForwardList());
     1379    if (adClickAttribution && m_frame.isMainFrame())
     1380        action.setAdClickAttribution(WTFMove(*adClickAttribution));
    13791381
    13801382    if (!targetFrame && !effectiveFrameName.isEmpty()) {
  • trunk/Source/WebCore/loader/FrameLoader.h

    r240909 r241049  
    3232#pragma once
    3333
     34#include "AdClickAttribution.h"
    3435#include "CachePolicy.h"
    3536#include "FrameLoaderStateMachine.h"
     
    116117    // FIXME: These are all functions which start loads. We have too many.
    117118    WEBCORE_EXPORT void loadURLIntoChildFrame(const URL&, const String& referer, Frame*);
    118     WEBCORE_EXPORT void loadFrameRequest(FrameLoadRequest&&, Event*, RefPtr<FormState>&&); // Called by submitForm, calls loadPostRequest and loadURL.
     119    WEBCORE_EXPORT void loadFrameRequest(FrameLoadRequest&&, Event*, RefPtr<FormState>&&, Optional<AdClickAttribution>&& = WTF::nullopt); // Called by submitForm, calls loadPostRequest and loadURL.
    119120
    120121    WEBCORE_EXPORT void load(FrameLoadRequest&&);
     
    126127
    127128    void changeLocation(FrameLoadRequest&&);
    128     WEBCORE_EXPORT void urlSelected(const URL&, const String& target, Event*, LockHistory, LockBackForwardList, ShouldSendReferrer, ShouldOpenExternalURLsPolicy, Optional<NewFrameOpenerPolicy> = WTF::nullopt, const AtomicString& downloadAttribute = nullAtom(), const SystemPreviewInfo& = { });
     129    WEBCORE_EXPORT void urlSelected(const URL&, const String& target, Event*, LockHistory, LockBackForwardList, ShouldSendReferrer, ShouldOpenExternalURLsPolicy, Optional<NewFrameOpenerPolicy> = WTF::nullopt, const AtomicString& downloadAttribute = nullAtom(), const SystemPreviewInfo& = { }, Optional<AdClickAttribution>&& = WTF::nullopt);
    129130    void submitForm(Ref<FormSubmission>&&);
    130131
     
    372373    void dispatchDidCommitLoad(Optional<HasInsecureContent> initialHasInsecureContent);
    373374
    374     void urlSelected(FrameLoadRequest&&, Event*);
     375    void urlSelected(FrameLoadRequest&&, Event*, Optional<AdClickAttribution>&& = WTF::nullopt);
    375376
    376377    void loadWithDocumentLoader(DocumentLoader*, FrameLoadType, RefPtr<FormState>&&, AllowNavigationToInvalidURL, ShouldTreatAsContinuingLoad, CompletionHandler<void()>&& = [] { }); // Calls continueLoadAfterNavigationPolicy
     
    380381
    381382    void loadPostRequest(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, RefPtr<FormState>&&, CompletionHandler<void()>&&);
    382     void loadURL(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, RefPtr<FormState>&&, CompletionHandler<void()>&&);
     383    void loadURL(FrameLoadRequest&&, const String& referrer, FrameLoadType, Event*, RefPtr<FormState>&&, Optional<AdClickAttribution>&&, CompletionHandler<void()>&&);
    383384
    384385    bool shouldReload(const URL& currentURL, const URL& destinationURL);
  • trunk/Source/WebCore/loader/NavigationAction.h

    r239427 r241049  
    2929#pragma once
    3030
     31#include "AdClickAttribution.h"
    3132#include "BackForwardItemIdentifier.h"
    3233#include "FrameLoaderTypes.h"
     
    3637#include "UserGestureIndicator.h"
    3738#include <wtf/Forward.h>
     39#include <wtf/Optional.h>
    3840
    3941namespace WebCore {
     
    134136    void setLockBackForwardList(LockBackForwardList lockBackForwardList) { m_lockBackForwardList = lockBackForwardList; }
    135137
     138    const Optional<AdClickAttribution>& adClickAttribution() { return m_adClickAttribution; };
     139    void setAdClickAttribution(AdClickAttribution&& adClickAttribution) { m_adClickAttribution = adClickAttribution; };
     140
    136141private:
    137142    // Do not add a strong reference to the originating document or a subobject that holds the
     
    152157    LockHistory m_lockHistory { LockHistory::No };
    153158    LockBackForwardList m_lockBackForwardList { LockBackForwardList::No };
     159    Optional<AdClickAttribution> m_adClickAttribution;
    154160};
    155161
  • trunk/Source/WebKit/ChangeLog

    r241046 r241049  
     12019-02-06  John Wilander  <wilander@apple.com>
     2
     3        Forward Ad Click Attribution data from HTMLAnchorElement::handleClick() to WebKit::NavigationActionData
     4        https://bugs.webkit.org/show_bug.cgi?id=194325
     5        <rdar://problem/47840283>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * Shared/NavigationActionData.cpp:
     10        (WebKit::NavigationActionData::encode const):
     11        (WebKit::NavigationActionData::decode):
     12        * Shared/NavigationActionData.h:
     13            Now holds an optional WebCore::AdClickAttribution object.
     14
    1152019-02-06  Daniel Bates  <dabates@apple.com>
    216
  • trunk/Source/WebKit/Shared/NavigationActionData.cpp

    r241000 r241049  
    5454    encoder.encodeEnum(lockBackForwardList);
    5555    encoder << clientRedirectSourceForHistory;
     56    encoder << adClickAttribution;
    5657}
    5758
     
    140141        return WTF::nullopt;
    141142
     143    Optional<Optional<WebCore::AdClickAttribution>> adClickAttribution;
     144    decoder >> adClickAttribution;
     145    if (!adClickAttribution)
     146        return WTF::nullopt;
     147
    142148    return {{ WTFMove(navigationType), modifiers, WTFMove(mouseButton), WTFMove(syntheticClickType), WTFMove(*userGestureTokenIdentifier),
    143149        WTFMove(*canHandleRequest), WTFMove(shouldOpenExternalURLsPolicy), WTFMove(*downloadAttribute), WTFMove(clickLocationInRootViewCoordinates),
    144150        WTFMove(*isRedirect), *treatAsSameOriginNavigation, *hasOpenedFrames, *openedByDOMWithOpener, WTFMove(*requesterOrigin),
    145         WTFMove(*targetBackForwardItemIdentifier), lockHistory, lockBackForwardList, WTFMove(*clientRedirectSourceForHistory) }};
     151        WTFMove(*targetBackForwardItemIdentifier), lockHistory, lockBackForwardList, WTFMove(*clientRedirectSourceForHistory), WTFMove(*adClickAttribution) }};
    146152}
    147153
  • trunk/Source/WebKit/Shared/NavigationActionData.h

    r241000 r241049  
    2727
    2828#include "WebEvent.h"
     29#include <WebCore/AdClickAttribution.h>
    2930#include <WebCore/BackForwardItemIdentifier.h>
    3031#include <WebCore/FloatPoint.h>
     
    6162    WebCore::LockBackForwardList lockBackForwardList;
    6263    WTF::String clientRedirectSourceForHistory;
     64    Optional<WebCore::AdClickAttribution> adClickAttribution;
    6365};
    6466
Note: See TracChangeset for help on using the changeset viewer.