Unreviewed, rolling out r245401.
[WebKit-https.git] / Source / WebKit / UIProcess / API / APIWebsitePolicies.cpp
index 65918a8..99e830c 100644 (file)
@@ -42,6 +42,34 @@ WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::
     , m_websiteDataStore(WTFMove(websiteDataStore))
 { }
 
+Ref<WebsitePolicies> WebsitePolicies::copy() const
+{
+    auto policies = WebsitePolicies::create();
+    policies->setContentBlockersEnabled(m_contentBlockersEnabled);
+    policies->setAllowedAutoplayQuirks(m_allowedAutoplayQuirks);
+    policies->setAutoplayPolicy(m_autoplayPolicy);
+#if ENABLE(DEVICE_ORIENTATION)
+    policies->setDeviceOrientationAndMotionAccessState(m_deviceOrientationAndMotionAccessState);
+#endif
+    policies->setPopUpPolicy(m_popUpPolicy);
+    policies->setWebsiteDataStore(m_websiteDataStore.get());
+    policies->setCustomUserAgent(m_customUserAgent);
+    policies->setCustomJavaScriptUserAgentAsSiteSpecificQuirks(m_customJavaScriptUserAgentAsSiteSpecificQuirks);
+    policies->setCustomNavigatorPlatform(m_customNavigatorPlatform);
+    policies->setPreferredCompatibilityMode(m_preferredCompatibilityMode);
+    policies->setMetaViewportPolicy(m_metaViewportPolicy);
+    policies->setMediaSourcePolicy(m_mediaSourcePolicy);
+    policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy);
+    Vector<WebCore::HTTPHeaderField> customHeaderFields;
+    customHeaderFields.reserveInitialCapacity(m_customHeaderFields.size());
+    for (auto& field : m_customHeaderFields)
+        customHeaderFields.append(WebCore::HTTPHeaderField(field));
+    policies->setCustomHeaderFields(WTFMove(customHeaderFields));
+    policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode);
+    policies->setApplicationNameForUserAgentWithModernCompatibility(m_applicationNameForUserAgentWithModernCompatibility);
+    return policies;
+}
+
 WebsitePolicies::~WebsitePolicies()
 {
 }
@@ -53,10 +81,23 @@ void WebsitePolicies::setWebsiteDataStore(RefPtr<WebsiteDataStore>&& websiteData
 
 WebKit::WebsitePoliciesData WebsitePolicies::data()
 {
-    Optional<WebKit::WebsiteDataStoreParameters> parameters;
-    if (m_websiteDataStore)
-        parameters = m_websiteDataStore->websiteDataStore().parameters();
-    return { contentBlockersEnabled(), allowedAutoplayQuirks(), autoplayPolicy(), customHeaderFields(), popUpPolicy(), WTFMove(parameters), m_customUserAgent, m_customNavigatorPlatform };
+    return {
+        contentBlockersEnabled(),
+        allowedAutoplayQuirks(),
+        autoplayPolicy(),
+#if ENABLE(DEVICE_ORIENTATION)
+        deviceOrientationAndMotionAccessState(),
+#endif
+        customHeaderFields(),
+        popUpPolicy(),
+        m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->websiteDataStore().parameters() } : WTF::nullopt,
+        m_customUserAgent,
+        m_customJavaScriptUserAgentAsSiteSpecificQuirks,
+        m_customNavigatorPlatform,
+        m_metaViewportPolicy,
+        m_mediaSourcePolicy,
+        m_simulatedMouseEventsDispatchPolicy,
+    };
 }
 
 }