Need a mechanism to override navigator.userAgent
[WebKit-https.git] / Source / WebKit / Shared / WebsitePoliciesData.cpp
index 414cb42..1d1181b 100644 (file)
@@ -37,12 +37,14 @@ namespace WebKit {
 void WebsitePoliciesData::encode(IPC::Encoder& encoder) const
 {
     encoder << contentBlockersEnabled;
+    encoder << deviceOrientationEventEnabled;
     encoder << autoplayPolicy;
     encoder << allowedAutoplayQuirks;
     encoder << customHeaderFields;
     encoder << popUpPolicy;
     encoder << websiteDataStoreParameters;
     encoder << customUserAgent;
+    encoder << customJavaScriptUserAgent;
     encoder << customNavigatorPlatform;
 }
 
@@ -52,6 +54,11 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
     decoder >> contentBlockersEnabled;
     if (!contentBlockersEnabled)
         return WTF::nullopt;
+
+    Optional<bool> deviceOrientationEventEnabled;
+    decoder >> deviceOrientationEventEnabled;
+    if (!deviceOrientationEventEnabled)
+        return WTF::nullopt;
     
     Optional<WebsiteAutoplayPolicy> autoplayPolicy;
     decoder >> autoplayPolicy;
@@ -83,6 +90,11 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
     if (!customUserAgent)
         return WTF::nullopt;
 
+    Optional<String> customJavaScriptUserAgent;
+    decoder >> customJavaScriptUserAgent;
+    if (!customJavaScriptUserAgent)
+        return WTF::nullopt;
+
     Optional<String> customNavigatorPlatform;
     decoder >> customNavigatorPlatform;
     if (!customNavigatorPlatform)
@@ -90,12 +102,14 @@ Optional<WebsitePoliciesData> WebsitePoliciesData::decode(IPC::Decoder& decoder)
     
     return { {
         WTFMove(*contentBlockersEnabled),
+        WTFMove(*deviceOrientationEventEnabled),
         WTFMove(*allowedAutoplayQuirks),
         WTFMove(*autoplayPolicy),
         WTFMove(*customHeaderFields),
         WTFMove(*popUpPolicy),
         WTFMove(*websiteDataStoreParameters),
         WTFMove(*customUserAgent),
+        WTFMove(*customJavaScriptUserAgent),
         WTFMove(*customNavigatorPlatform),
     } };
 }
@@ -104,7 +118,9 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol
 {
     documentLoader.setCustomHeaderFields(WTFMove(websitePolicies.customHeaderFields));
     documentLoader.setCustomUserAgent(websitePolicies.customUserAgent);
+    documentLoader.setCustomJavaScriptUserAgent(websitePolicies.customJavaScriptUserAgent);
     documentLoader.setCustomNavigatorPlatform(websitePolicies.customNavigatorPlatform);
+    documentLoader.setDeviceOrientationEventEnabled(websitePolicies.deviceOrientationEventEnabled);
     
     // Only setUserContentExtensionsEnabled if it hasn't already been disabled by reloading without content blockers.
     if (documentLoader.userContentExtensionsEnabled())
@@ -122,6 +138,9 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol
     if (allowedQuirks.contains(WebsiteAutoplayQuirk::ArbitraryUserGestures))
         quirks.add(WebCore::AutoplayQuirk::ArbitraryUserGestures);
 
+    if (allowedQuirks.contains(WebsiteAutoplayQuirk::PerDocumentAutoplayBehavior))
+        quirks.add(WebCore::AutoplayQuirk::PerDocumentAutoplayBehavior);
+
     documentLoader.setAllowedAutoplayQuirks(quirks);
 
     switch (websitePolicies.autoplayPolicy) {
@@ -153,11 +172,8 @@ void WebsitePoliciesData::applyToDocumentLoader(WebsitePoliciesData&& websitePol
 
     if (websitePolicies.websiteDataStoreParameters) {
         if (auto* frame = documentLoader.frame()) {
-            if (auto* page = frame->page()) {
-                auto sessionID = websitePolicies.websiteDataStoreParameters->networkSessionParameters.sessionID;
-                WebProcess::singleton().addWebsiteDataStore(WTFMove(*websitePolicies.websiteDataStoreParameters));
-                page->setSessionID(sessionID);
-            }
+            if (auto* page = frame->page())
+                page->setSessionID(websitePolicies.websiteDataStoreParameters->networkSessionParameters.sessionID);
         }
     }
 }