Title: [250569] branches/safari-608-branch/Source/WebCore
Revision
250569
Author
[email protected]
Date
2019-10-01 11:24:52 -0700 (Tue, 01 Oct 2019)

Log Message

Cherry-pick r250528. rdar://problem/55876838

    Refine restrictions for X-Temp-Tablet HTTP header experiment
    https://bugs.webkit.org/show_bug.cgi?id=202367
    <rdar://problem/55849139>

    Reviewed by Geoffrey Garen.

    Refine restrictions for X-Temp-Tablet HTTP header experiment:
    1. Only send the header if the embedding application is MobileSafari.
    2. Only send the header if the first party is google.com
    3. Only send the header if the current date is before 2/1/2020
    4. Send the header even if using an ephemeral session

    * loader/cache/CachedResourceLoader.cpp:
    (WebCore::isXTempTabletHeaderExperimentOver):
    (WebCore::CachedResourceLoader::CachedResourceLoader):
    (WebCore::isGoogleSearch):
    (WebCore::CachedResourceLoader::shouldSendXTempTabletHeader const):
    (WebCore::CachedResourceLoader::requestResource):
    * loader/cache/CachedResourceLoader.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250528 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (250568 => 250569)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-10-01 18:23:54 UTC (rev 250568)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-10-01 18:24:52 UTC (rev 250569)
@@ -1,3 +1,51 @@
+2019-10-01  Alan Coon  <[email protected]>
+
+        Cherry-pick r250528. rdar://problem/55876838
+
+    Refine restrictions for X-Temp-Tablet HTTP header experiment
+    https://bugs.webkit.org/show_bug.cgi?id=202367
+    <rdar://problem/55849139>
+    
+    Reviewed by Geoffrey Garen.
+    
+    Refine restrictions for X-Temp-Tablet HTTP header experiment:
+    1. Only send the header if the embedding application is MobileSafari.
+    2. Only send the header if the first party is google.com
+    3. Only send the header if the current date is before 2/1/2020
+    4. Send the header even if using an ephemeral session
+    
+    * loader/cache/CachedResourceLoader.cpp:
+    (WebCore::isXTempTabletHeaderExperimentOver):
+    (WebCore::CachedResourceLoader::CachedResourceLoader):
+    (WebCore::isGoogleSearch):
+    (WebCore::CachedResourceLoader::shouldSendXTempTabletHeader const):
+    (WebCore::CachedResourceLoader::requestResource):
+    * loader/cache/CachedResourceLoader.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-09-30  Chris Dumez  <[email protected]>
+
+            Refine restrictions for X-Temp-Tablet HTTP header experiment
+            https://bugs.webkit.org/show_bug.cgi?id=202367
+            <rdar://problem/55849139>
+
+            Reviewed by Geoffrey Garen.
+
+            Refine restrictions for X-Temp-Tablet HTTP header experiment:
+            1. Only send the header if the embedding application is MobileSafari.
+            2. Only send the header if the first party is google.com
+            3. Only send the header if the current date is before 2/1/2020
+            4. Send the header even if using an ephemeral session
+
+            * loader/cache/CachedResourceLoader.cpp:
+            (WebCore::isXTempTabletHeaderExperimentOver):
+            (WebCore::CachedResourceLoader::CachedResourceLoader):
+            (WebCore::isGoogleSearch):
+            (WebCore::CachedResourceLoader::shouldSendXTempTabletHeader const):
+            (WebCore::CachedResourceLoader::requestResource):
+            * loader/cache/CachedResourceLoader.h:
+
 2019-09-30  Kocsen Chung  <[email protected]>
 
         Cherry-pick r250483. rdar://problem/55825351

Modified: branches/safari-608-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp (250568 => 250569)


--- branches/safari-608-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2019-10-01 18:23:54 UTC (rev 250568)
+++ branches/safari-608-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2019-10-01 18:24:52 UTC (rev 250569)
@@ -45,6 +45,7 @@
 #include "CrossOriginAccessControl.h"
 #include "CustomHeaderFields.h"
 #include "DOMWindow.h"
+#include "DateComponents.h"
 #include "DiagnosticLoggingClient.h"
 #include "DiagnosticLoggingKeys.h"
 #include "Document.h"
@@ -65,6 +66,7 @@
 #include "RenderElement.h"
 #include "ResourceLoadInfo.h"
 #include "ResourceTiming.h"
+#include "RuntimeApplicationChecks.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScriptController.h"
 #include "SecurityOrigin.h"
@@ -150,6 +152,16 @@
     return nullptr;
 }
 
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+static bool isXTempTabletHeaderExperimentOver()
+{
+    DateComponents date;
+    date.setMillisecondsSinceEpochForMonth(WallTime::now().secondsSinceEpoch().milliseconds());
+    // End of experiment is 02-01-2020.
+    return date.fullYear() > 2020 || (date.fullYear() == 2020 && date.month() >= 1);
+}
+#endif
+
 CachedResourceLoader::CachedResourceLoader(DocumentLoader* documentLoader)
     : m_document(nullptr)
     , m_documentLoader(documentLoader)
@@ -159,6 +171,9 @@
     , m_autoLoadImages(true)
     , m_imagesEnabled(true)
     , m_allowStaleResources(false)
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+    , m_isXTempTabletHeaderExperimentOver(isXTempTabletHeaderExperimentOver())
+#endif
 {
 }
 
@@ -788,6 +803,36 @@
     return FetchOptions::Destination::EmptyString;
 }
 
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+static bool isGoogleSearch(const URL& url)
+{
+    if (!url.protocolIs("https"))
+        return false;
+
+    RegistrableDomain registrableDomain(url);
+    if (!registrableDomain.string().startsWith("google."))
+        return false;
+
+    auto host = url.host();
+    return host.startsWithIgnoringASCIICase("google.") || host.startsWithIgnoringASCIICase("www.google.") || host.startsWithIgnoringASCIICase("images.google.");
+}
+
+bool CachedResourceLoader::shouldSendXTempTabletHeader(CachedResource::Type type, Frame& frame, const URL& url) const
+{
+    if (m_isXTempTabletHeaderExperimentOver || !IOSApplication::isMobileSafari())
+        return false;
+
+    if (!isGoogleSearch(url))
+        return false;
+
+    if (type == CachedResource::Type::MainResource && frame.isMainFrame())
+        return true;
+
+    auto* topDocument = frame.mainFrame().document();
+    return topDocument && isGoogleSearch(topDocument->url());
+}
+#endif
+
 ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer)
 {
     request.setDestinationIfNotSet(destinationForType(type));
@@ -873,14 +918,8 @@
 
     // FIXME: This is temporary for <rdar://problem/55790994>.
 #if PLATFORM(IOS) && !PLATFORM(IOSMAC)
-    if (!sessionID().isEphemeral() && deviceHasIPadCapability() && request.resourceRequest().url().protocolIs("https")) {
-        RegistrableDomain registrableDomain(request.resourceRequest().url());
-        if (registrableDomain.string().startsWith("google.")) {
-            auto host = request.resourceRequest().url().host();
-            if (host.startsWithIgnoringASCIICase("google.") || host.startsWithIgnoringASCIICase("www.google.") || host.startsWithIgnoringASCIICase("images.google."))
-                request.resourceRequest().setHTTPHeaderField(HTTPHeaderName::XTempTablet, "1"_s);
-        }
-    }
+    if (deviceHasIPadCapability() && shouldSendXTempTabletHeader(type, frame, request.resourceRequest().url()))
+        request.resourceRequest().setHTTPHeaderField(HTTPHeaderName::XTempTablet, "1"_s);
 #endif
 
     LoadTiming loadTiming;

Modified: branches/safari-608-branch/Source/WebCore/loader/cache/CachedResourceLoader.h (250568 => 250569)


--- branches/safari-608-branch/Source/WebCore/loader/cache/CachedResourceLoader.h	2019-10-01 18:23:54 UTC (rev 250568)
+++ branches/safari-608-branch/Source/WebCore/loader/cache/CachedResourceLoader.h	2019-10-01 18:24:52 UTC (rev 250569)
@@ -192,6 +192,10 @@
     bool canRequestAfterRedirection(CachedResource::Type, const URL&, const ResourceLoaderOptions&) const;
     bool canRequestInContentDispositionAttachmentSandbox(CachedResource::Type, const URL&) const;
 
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+    bool shouldSendXTempTabletHeader(CachedResource::Type, Frame&, const URL&) const;
+#endif
+
     HashSet<String> m_validatedURLs;
     mutable DocumentResourceMap m_documentResources;
     WeakPtr<Document> m_document;
@@ -211,6 +215,9 @@
     bool m_autoLoadImages : 1;
     bool m_imagesEnabled : 1;
     bool m_allowStaleResources : 1;
+#if PLATFORM(IOS) && !PLATFORM(IOSMAC)
+    bool m_isXTempTabletHeaderExperimentOver : 1;
+#endif
 };
 
 class ResourceCacheValidationSuppressor {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to