0008-defang-AdClickAttribution.patch (12829B)
1 From 65d2f6b42f8baa812d7d62629c09d4e88c96888f Mon Sep 17 00:00:00 2001 2 From: "Haelwenn (lanodan) Monnier" <contact@hacktivis.me> 3 Date: Fri, 5 Apr 2019 06:44:31 +0200 4 Subject: [PATCH 8/9] defang AdClickAttribution 5 6 --- 7 Source/WebCore/html/HTMLAnchorElement.cpp | 52 -------------------- 8 Source/WebCore/html/HTMLAnchorElement.h | 3 -- 9 Source/WebCore/html/HTMLAnchorElement.idl | 2 - 10 Source/WebCore/loader/AdClickAttribution.cpp | 42 +--------------- 11 Source/WebCore/loader/AdClickAttribution.h | 48 +----------------- 12 Source/WebCore/loader/FrameLoader.cpp | 3 -- 13 Source/WebCore/page/RuntimeEnabledFeatures.h | 4 +- 14 lanodan-TODO | 7 +-- 15 8 files changed, 10 insertions(+), 151 deletions(-) 16 17 diff --git a/Source/WebCore/html/HTMLAnchorElement.cpp b/Source/WebCore/html/HTMLAnchorElement.cpp 18 index 815ed314..9f3691e1 100644 19 --- a/Source/WebCore/html/HTMLAnchorElement.cpp 20 +++ b/Source/WebCore/html/HTMLAnchorElement.cpp 21 @@ -24,7 +24,6 @@ 22 #include "config.h" 23 #include "HTMLAnchorElement.h" 24 25 -#include "AdClickAttribution.h" 26 #include "DOMTokenList.h" 27 #include "ElementIterator.h" 28 #include "EventHandler.h" 29 @@ -388,52 +387,6 @@ bool HTMLAnchorElement::isSystemPreviewLink() const 30 } 31 #endif 32 33 -Optional<AdClickAttribution> HTMLAnchorElement::parseAdClickAttribution() const 34 -{ 35 - using Campaign = AdClickAttribution::Campaign; 36 - using Source = AdClickAttribution::Source; 37 - using Destination = AdClickAttribution::Destination; 38 - 39 - if (!RuntimeEnabledFeatures::sharedFeatures().adClickAttributionEnabled() || !UserGestureIndicator::processingUserGesture()) 40 - return WTF::nullopt; 41 - 42 - if (!hasAttributeWithoutSynchronization(adcampaignidAttr) && !hasAttributeWithoutSynchronization(addestinationAttr)) 43 - return WTF::nullopt; 44 - 45 - auto adCampaignIDAttr = attributeWithoutSynchronization(adcampaignidAttr); 46 - auto adDestinationAttr = attributeWithoutSynchronization(addestinationAttr); 47 - 48 - if (adCampaignIDAttr.isEmpty() || adDestinationAttr.isEmpty()) { 49 - document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, "Both adcampaignid and addestination need to be set for Ad Click Attribution to work."_s); 50 - return WTF::nullopt; 51 - } 52 - 53 - RefPtr<Frame> frame = document().frame(); 54 - if (!frame || !frame->isMainFrame()) { 55 - document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, "Ad Click Attribution is only supported in the main frame."_s); 56 - return WTF::nullopt; 57 - } 58 - 59 - auto adCampaignID = parseHTMLNonNegativeInteger(adCampaignIDAttr); 60 - if (!adCampaignID) { 61 - document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, "adcampaignid can not be converted to a non-negative integer which is required for Ad Click Attribution."_s); 62 - return WTF::nullopt; 63 - } 64 - 65 - if (adCampaignID.value() >= AdClickAttribution::MaxEntropy) { 66 - document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, makeString("adcampaignid must have a non-negative value less than ", AdClickAttribution::MaxEntropy, " for Ad Click Attribution.")); 67 - return WTF::nullopt; 68 - } 69 - 70 - URL adDestinationURL { URL(), adDestinationAttr }; 71 - if (!adDestinationURL.isValid() || !adDestinationURL.protocolIsInHTTPFamily()) { 72 - document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, "adddestination could not be converted to a valid HTTP-family URL."_s); 73 - return WTF::nullopt; 74 - } 75 - 76 - return AdClickAttribution { Campaign(adCampaignID.value()), Source(document().domain()), Destination(adDestinationURL.host().toString()) }; 77 -} 78 - 79 void HTMLAnchorElement::handleClick(Event& event) 80 { 81 event.setDefaultHandled(); 82 @@ -478,11 +431,6 @@ void HTMLAnchorElement::handleClick(Event& event) 83 else if (hasRel(Relation::NoOpener) || (RuntimeEnabledFeatures::sharedFeatures().blankAnchorTargetImpliesNoOpenerEnabled() && equalIgnoringASCIICase(effectiveTarget, "_blank"))) 84 newFrameOpenerPolicy = NewFrameOpenerPolicy::Suppress; 85 86 - auto adClickAttribution = parseAdClickAttribution(); 87 - // A matching conversion event needs to happen before the complete ad click attributionURL can be 88 - // created. Thus, it should be empty for now. 89 - ASSERT(!adClickAttribution || adClickAttribution->url().isNull()); 90 - 91 frame->loader().urlSelected(completedURL, effectiveTarget, &event, LockHistory::No, LockBackForwardList::No, shouldSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), newFrameOpenerPolicy, downloadAttribute, systemPreviewInfo, WTFMove(adClickAttribution)); 92 } 93 94 diff --git a/Source/WebCore/html/HTMLAnchorElement.h b/Source/WebCore/html/HTMLAnchorElement.h 95 index 61315ced..7f41385c 100644 96 --- a/Source/WebCore/html/HTMLAnchorElement.h 97 +++ b/Source/WebCore/html/HTMLAnchorElement.h 98 @@ -32,7 +32,6 @@ 99 100 namespace WebCore { 101 102 -class AdClickAttribution; 103 class DOMTokenList; 104 105 // Link relation bitmask values. 106 @@ -97,8 +96,6 @@ private: 107 108 void sendPings(const URL& destinationURL); 109 110 - Optional<AdClickAttribution> parseAdClickAttribution() const; 111 - 112 void handleClick(Event&); 113 114 enum EventType { 115 diff --git a/Source/WebCore/html/HTMLAnchorElement.idl b/Source/WebCore/html/HTMLAnchorElement.idl 116 index 0d21fc7d..b7f59462 100644 117 --- a/Source/WebCore/html/HTMLAnchorElement.idl 118 +++ b/Source/WebCore/html/HTMLAnchorElement.idl 119 @@ -19,8 +19,6 @@ 120 */ 121 122 interface HTMLAnchorElement : HTMLElement { 123 - [CEReactions=NotNeeded, EnabledAtRuntime=AdClickAttribution, Reflect] attribute DOMString adcampaignid; 124 - [CEReactions=NotNeeded, EnabledAtRuntime=AdClickAttribution, Reflect] attribute DOMString addestination; 125 [CEReactions=NotNeeded, Reflect] attribute DOMString charset; 126 [CEReactions=NotNeeded, Reflect] attribute DOMString coords; 127 [CEReactions=NotNeeded, Conditional=DOWNLOAD_ATTRIBUTE, EnabledAtRuntime=DownloadAttribute, Reflect] attribute DOMString download; 128 diff --git a/Source/WebCore/loader/AdClickAttribution.cpp b/Source/WebCore/loader/AdClickAttribution.cpp 129 index bdc06393..2dab9617 100644 130 --- a/Source/WebCore/loader/AdClickAttribution.cpp 131 +++ b/Source/WebCore/loader/AdClickAttribution.cpp 132 @@ -34,59 +34,21 @@ namespace WebCore { 133 134 bool AdClickAttribution::isValid() const 135 { 136 - return m_conversion 137 - && m_conversion.value().isValid() 138 - && m_campaign.isValid() 139 - && !m_source.registrableDomain.isEmpty() 140 - && !m_destination.registrableDomain.isEmpty() 141 - && m_earliestTimeToSend; 142 + return false; 143 } 144 145 void AdClickAttribution::setConversion(Conversion&& conversion) 146 { 147 - if (!conversion.isValid() || (m_conversion && m_conversion->priority > conversion.priority)) 148 - return; 149 - 150 - m_conversion = WTFMove(conversion); 151 - // 24-48 hour delay before sending. This helps privacy since the conversion and the attribution 152 - // requests are detached and the time of the attribution does not reveal the time of the conversion. 153 - m_earliestTimeToSend = m_timeOfAdClick + 24_h + Seconds(randomNumber() * (24_h).value()); 154 + return; 155 } 156 157 URL AdClickAttribution::url() const 158 { 159 - if (!isValid()) 160 - return URL(); 161 - 162 - StringBuilder builder; 163 - builder.appendLiteral("https://"); 164 - builder.append(m_source.registrableDomain); 165 - builder.appendLiteral("/.well-known/ad-click-attribution/"); 166 - builder.appendNumber(m_conversion.value().data); 167 - builder.append('/'); 168 - builder.appendNumber(m_campaign.id); 169 - 170 - URL url { URL(), builder.toString() }; 171 - if (url.isValid()) 172 - return url; 173 - 174 return URL(); 175 } 176 177 URL AdClickAttribution::referrer() const 178 { 179 - if (!isValid()) 180 - return URL(); 181 - 182 - StringBuilder builder; 183 - builder.appendLiteral("https://"); 184 - builder.append(m_destination.registrableDomain); 185 - builder.append('/'); 186 - 187 - URL url { URL(), builder.toString() }; 188 - if (url.isValid()) 189 - return url; 190 - 191 return URL(); 192 } 193 194 diff --git a/Source/WebCore/loader/AdClickAttribution.h b/Source/WebCore/loader/AdClickAttribution.h 195 index 34af2f2d..af6bf69c 100644 196 --- a/Source/WebCore/loader/AdClickAttribution.h 197 +++ b/Source/WebCore/loader/AdClickAttribution.h 198 @@ -150,41 +150,7 @@ void AdClickAttribution::encode(Encoder& encoder) const 199 template<class Decoder> 200 Optional<AdClickAttribution> AdClickAttribution::decode(Decoder& decoder) 201 { 202 - Optional<CampaignId> campaignId; 203 - decoder >> campaignId; 204 - if (!campaignId) 205 - return WTF::nullopt; 206 - 207 - Optional<String> sourceRegistrableDomain; 208 - decoder >> sourceRegistrableDomain; 209 - if (!sourceRegistrableDomain) 210 - return WTF::nullopt; 211 - 212 - Optional<String> destinationRegistrableDomain; 213 - decoder >> destinationRegistrableDomain; 214 - if (!destinationRegistrableDomain) 215 - return WTF::nullopt; 216 - 217 - Optional<WallTime> timeOfAdClick; 218 - decoder >> timeOfAdClick; 219 - if (!timeOfAdClick) 220 - return WTF::nullopt; 221 - 222 - Optional<Optional<Conversion>> conversion; 223 - decoder >> conversion; 224 - if (!conversion) 225 - return WTF::nullopt; 226 - 227 - Optional<Optional<WallTime>> earliestTimeToSend; 228 - decoder >> earliestTimeToSend; 229 - if (!earliestTimeToSend) 230 - return WTF::nullopt; 231 - 232 - AdClickAttribution attribution { Campaign { WTFMove(*campaignId) }, Source { WTFMove(*sourceRegistrableDomain) }, Destination { WTFMove(*destinationRegistrableDomain) } }; 233 - attribution.m_conversion = WTFMove(*conversion); 234 - attribution.m_earliestTimeToSend = WTFMove(*earliestTimeToSend); 235 - 236 - return attribution; 237 + return WTF::nullopt; 238 } 239 240 template<class Encoder> 241 @@ -196,17 +162,7 @@ void AdClickAttribution::Conversion::encode(Encoder& encoder) const 242 template<class Decoder> 243 Optional<AdClickAttribution::Conversion> AdClickAttribution::Conversion::decode(Decoder& decoder) 244 { 245 - Optional<ConversionData> data; 246 - decoder >> data; 247 - if (!data) 248 - return WTF::nullopt; 249 - 250 - Optional<PriorityValue> priority; 251 - decoder >> priority; 252 - if (!priority) 253 - return WTF::nullopt; 254 - 255 - return Conversion { WTFMove(*data), Priority { WTFMove(*priority) } }; 256 + return WTF::nullopt; 257 } 258 259 } // namespace WebCore 260 diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp 261 index 109b7d35..2903d158 100644 262 --- a/Source/WebCore/loader/FrameLoader.cpp 263 +++ b/Source/WebCore/loader/FrameLoader.cpp 264 @@ -1376,9 +1376,6 @@ void FrameLoader::loadURL(FrameLoadRequest&& frameLoadRequest, const String& ref 265 NavigationAction action { frameLoadRequest.requester(), request, frameLoadRequest.initiatedByMainFrame(), newLoadType, isFormSubmission, event, frameLoadRequest.shouldOpenExternalURLsPolicy(), frameLoadRequest.downloadAttribute() }; 266 action.setLockHistory(lockHistory); 267 action.setLockBackForwardList(frameLoadRequest.lockBackForwardList()); 268 - if (adClickAttribution && m_frame.isMainFrame()) 269 - action.setAdClickAttribution(WTFMove(*adClickAttribution)); 270 - 271 if (!targetFrame && !effectiveFrameName.isEmpty()) { 272 action = action.copyWithShouldOpenExternalURLsPolicy(shouldOpenExternalURLsPolicyToApply(m_frame, frameLoadRequest)); 273 policyChecker().checkNewWindowPolicy(WTFMove(action), WTFMove(request), WTFMove(formState), effectiveFrameName, [this, allowNavigationToInvalidURL, openerPolicy, completionHandler = completionHandlerCaller.release()] (const ResourceRequest& request, WeakPtr<FormState>&& formState, const String& frameName, const NavigationAction& action, ShouldContinue shouldContinue) mutable { 274 diff --git a/Source/WebCore/page/RuntimeEnabledFeatures.h b/Source/WebCore/page/RuntimeEnabledFeatures.h 275 index 2030412e..f693ebd3 100644 276 --- a/Source/WebCore/page/RuntimeEnabledFeatures.h 277 +++ b/Source/WebCore/page/RuntimeEnabledFeatures.h 278 @@ -341,8 +341,8 @@ public: 279 void setCSSLogicalEnabled(bool isEnabled) { m_CSSLogicalEnabled = isEnabled; } 280 bool cssLogicalEnabled() const { return m_CSSLogicalEnabled; } 281 282 - bool adClickAttributionEnabled() const { return m_adClickAttributionEnabled; } 283 - void setAdClickAttributionEnabled(bool isEnabled) { m_adClickAttributionEnabled = isEnabled; } 284 + bool adClickAttributionEnabled() const { return false; } 285 + void setAdClickAttributionEnabled(bool isEnabled) { } 286 287 WEBCORE_EXPORT static RuntimeEnabledFeatures& sharedFeatures(); 288 289 diff --git a/lanodan-TODO b/lanodan-TODO 290 index d8acc42c..ef507ac4 100644 291 --- a/lanodan-TODO 292 +++ b/lanodan-TODO 293 @@ -40,9 +40,10 @@ 294 295 ## HTML 296 - [ ] noscript 297 -- [x] Link ping 298 -- [x] Link prefetch 299 -- [x] Link preloading 300 +- [x] Anchor ping 301 +- [x] Anchor prefetch 302 +- [x] Anchor preloading 303 +- [x] Anchor AdClickAttribution 304 - [x] Media preloading 305 - [x] custom elements 306 - [ ] DNS prefetch 307 -- 308 2.21.0 309