Title: [287333] trunk/Source/WebKit
Revision
287333
Author
[email protected]
Date
2021-12-21 15:16:52 -0800 (Tue, 21 Dec 2021)

Log Message

Fix Safari-side SafeBrowsing telemetry
https://bugs.webkit.org/show_bug.cgi?id=234439

Patch by Eliot Hsu <[email protected]> on 2021-12-21
Reviewed by Alex Christensen.

Fix old (and privacy-preserving) telemetry for Safe Browsing,
which were previously reported from the Safari side.

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::showSafeBrowsingWarning):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (287332 => 287333)


--- trunk/Source/WebKit/ChangeLog	2021-12-21 22:40:14 UTC (rev 287332)
+++ trunk/Source/WebKit/ChangeLog	2021-12-21 23:16:52 UTC (rev 287333)
@@ -1,3 +1,16 @@
+2021-12-21  Eliot Hsu  <[email protected]>
+
+        Fix Safari-side SafeBrowsing telemetry
+        https://bugs.webkit.org/show_bug.cgi?id=234439
+
+        Reviewed by Alex Christensen.
+
+        Fix old (and privacy-preserving) telemetry for Safe Browsing,
+        which were previously reported from the Safari side.
+
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::showSafeBrowsingWarning):
+
 2021-12-21  Kate Cheney  <[email protected]>
 
         Harden PCM and ITP databases against crashes

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (287332 => 287333)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-12-21 22:40:14 UTC (rev 287332)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-12-21 23:16:52 UTC (rev 287333)
@@ -1776,6 +1776,11 @@
     if (!m_view)
         return completionHandler(ContinueUnsafeLoad::Yes);
 
+    WebCore::DiagnosticLoggingClient::ValueDictionary showedWarningDictionary;
+    showedWarningDictionary.set("source"_s, String("service"));
+
+    m_page->logDiagnosticMessageWithValueDictionary("SafeBrowsing.ShowedWarning"_s, "Safari"_s, showedWarningDictionary, ShouldSample::No);
+
     m_safeBrowsingWarning = adoptNS([[WKSafeBrowsingWarning alloc] initWithFrame:[m_view bounds] safeBrowsingWarning:warning completionHandler:[weakThis = WeakPtr { *this }, completionHandler = WTFMove(completionHandler)] (auto&& result) mutable {
         completionHandler(WTFMove(result));
         if (!weakThis)
@@ -1785,10 +1790,28 @@
             [] (const URL&) { return true; }
         );
         bool forMainFrameNavigation = [weakThis->m_safeBrowsingWarning forMainFrameNavigation];
+
+        WebCore::DiagnosticLoggingClient::ValueDictionary dictionary;
+        dictionary.set("source"_s, String("service"));
         if (navigatesFrame && forMainFrameNavigation) {
             // The safe browsing warning will be hidden once the next page is shown.
+            bool continuingUnsafeLoad = WTF::switchOn(result,
+                [] (ContinueUnsafeLoad continueUnsafeLoad) { return continueUnsafeLoad == ContinueUnsafeLoad::Yes; },
+                [] (const URL&) { return false; }
+            );
+
+            if (continuingUnsafeLoad)
+                dictionary.set("action"_s, String("visit website"));
+            else
+                dictionary.set("action"_s, String("redirect to url"));
+
+            weakThis->m_page->logDiagnosticMessageWithValueDictionary("SafeBrowsing.PerformedAction"_s, "Safari"_s, dictionary, ShouldSample::No);
             return;
         }
+
+        dictionary.set("action"_s, String("go back"));
+        weakThis->m_page->logDiagnosticMessageWithValueDictionary("SafeBrowsing.PerformedAction"_s, "Safari"_s, dictionary, ShouldSample::No);
+
         if (!navigatesFrame && weakThis->m_safeBrowsingWarning && !forMainFrameNavigation) {
             weakThis->m_page->goBack();
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to