Title: [259307] trunk
Revision
259307
Author
[email protected]
Date
2020-03-31 13:13:48 -0700 (Tue, 31 Mar 2020)

Log Message

Add SPI WKWebpagePreferences._userContentController
https://bugs.webkit.org/show_bug.cgi?id=209795

Reviewed by Tim Hatcher.

Source/WebKit:

This will allow us to switch which WKUserContentController we are using at decidePolicyForNavigationAction time
like we do WKWebsiteDataStores.  This is only allowed with main frame navigations.

To do this I moved UserContentControllerParameters into their own struct.
I remove unused WebsitePoliciesData.websiteDataStoreParameters.
I pass an API::WebsitePolicies* further down the chain instead of switching to Optional<WebsitePoliciesData>,
which allows us to access the WebUserContentControllerProxy* from the former in WebPageProxy::creationParameters.
I removed an unused WebsitePolicies constructor.
I added a missing copied member variable in WebsitePolicies::copy.

* NetworkProcess/NetworkSession.cpp:
* Shared/UserContentControllerParameters.cpp: Added.
(WebKit::UserContentControllerParameters::encode const):
(WebKit::UserContentControllerParameters::decode):
* Shared/UserContentControllerParameters.h: Added.
* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::encode const):
(WebKit::WebsitePoliciesData::decode):
* Shared/WebsitePoliciesData.h:
* Sources.txt:
* UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::copy const):
(API::WebsitePolicies::setUserContentController):
(API::WebsitePolicies::data):
(API::WebsitePolicies::WebsitePolicies): Deleted.
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageUpdateWebsitePolicies):
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _updateWebpagePreferences:]):
* UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences _userContentController]):
(-[WKWebpagePreferences _setUserContentController:]):
* UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
* UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
(WebKit::ProvisionalPageProxy::initializeWebPage):
(WebKit::ProvisionalPageProxy::goToBackForwardItem):
* UIProcess/ProvisionalPageProxy.h:
* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::addProcess):
(WebKit::WebUserContentControllerProxy::parameters const):
(WebKit::WebUserContentControllerProxy::contentRuleListData const):
(WebKit::WebUserContentControllerProxy::contentRuleListData): Deleted.
* UIProcess/UserContent/WebUserContentControllerProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedNavigationPolicyDecision):
(WebKit::WebPageProxy::receivedPolicyDecision):
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::WebPageProxy::decidePolicyForNewWindowAction):
(WebKit::WebPageProxy::decidePolicyForResponseShared):
* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addWebUserContentControllerProxy):
* UIProcess/WebProcessProxy.h:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_processDisplayName):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didReceiveMessage):

Tools:

* TestWebKitAPI/SourcesCocoa.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
(-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): Deleted.
* TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
* TestWebKitAPI/cocoa/TestUIDelegate.h: Added.
* TestWebKitAPI/cocoa/TestUIDelegate.mm: Added.
(-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[TestUIDelegate waitForAlert]):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (259306 => 259307)


--- trunk/Source/WebKit/ChangeLog	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/ChangeLog	2020-03-31 20:13:48 UTC (rev 259307)
@@ -1,5 +1,80 @@
 2020-03-31  Alex Christensen  <[email protected]>
 
+        Add SPI WKWebpagePreferences._userContentController
+        https://bugs.webkit.org/show_bug.cgi?id=209795
+
+        Reviewed by Tim Hatcher.
+
+        This will allow us to switch which WKUserContentController we are using at decidePolicyForNavigationAction time
+        like we do WKWebsiteDataStores.  This is only allowed with main frame navigations.
+
+        To do this I moved UserContentControllerParameters into their own struct.
+        I remove unused WebsitePoliciesData.websiteDataStoreParameters.
+        I pass an API::WebsitePolicies* further down the chain instead of switching to Optional<WebsitePoliciesData>,
+        which allows us to access the WebUserContentControllerProxy* from the former in WebPageProxy::creationParameters.
+        I removed an unused WebsitePolicies constructor.
+        I added a missing copied member variable in WebsitePolicies::copy.
+
+        * NetworkProcess/NetworkSession.cpp:
+        * Shared/UserContentControllerParameters.cpp: Added.
+        (WebKit::UserContentControllerParameters::encode const):
+        (WebKit::UserContentControllerParameters::decode):
+        * Shared/UserContentControllerParameters.h: Added.
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * Shared/WebsitePoliciesData.cpp:
+        (WebKit::WebsitePoliciesData::encode const):
+        (WebKit::WebsitePoliciesData::decode):
+        * Shared/WebsitePoliciesData.h:
+        * Sources.txt:
+        * UIProcess/API/APIWebsitePolicies.cpp:
+        (API::WebsitePolicies::copy const):
+        (API::WebsitePolicies::setUserContentController):
+        (API::WebsitePolicies::data):
+        (API::WebsitePolicies::WebsitePolicies): Deleted.
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageUpdateWebsitePolicies):
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _updateWebpagePreferences:]):
+        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+        (-[WKWebpagePreferences _userContentController]):
+        (-[WKWebpagePreferences _setUserContentController:]):
+        * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+        * UIProcess/ProvisionalPageProxy.cpp:
+        (WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
+        (WebKit::ProvisionalPageProxy::initializeWebPage):
+        (WebKit::ProvisionalPageProxy::goToBackForwardItem):
+        * UIProcess/ProvisionalPageProxy.h:
+        * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
+        (WebKit::WebUserContentControllerProxy::addProcess):
+        (WebKit::WebUserContentControllerProxy::parameters const):
+        (WebKit::WebUserContentControllerProxy::contentRuleListData const):
+        (WebKit::WebUserContentControllerProxy::contentRuleListData): Deleted.
+        * UIProcess/UserContent/WebUserContentControllerProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
+        (WebKit::WebPageProxy::receivedPolicyDecision):
+        (WebKit::WebPageProxy::continueNavigationInNewProcess):
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+        (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
+        (WebKit::WebPageProxy::decidePolicyForResponseShared):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::addWebUserContentControllerProxy):
+        * UIProcess/WebProcessProxy.h:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_processDisplayName):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::didReceiveMessage):
+
+2020-03-31  Alex Christensen  <[email protected]>
+
         Remove call to PageConfiguration::setUserContentController added in r225765
         https://bugs.webkit.org/show_bug.cgi?id=209828
         <rdar://problem/61114052>

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (259306 => 259307)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -32,6 +32,7 @@
 #include "NetworkProcessProxyMessages.h"
 #include "NetworkResourceLoadParameters.h"
 #include "NetworkResourceLoader.h"
+#include "NetworkSessionCreationParameters.h"
 #include "PingLoad.h"
 #include "WebPageProxy.h"
 #include "WebPageProxyMessages.h"

Added: trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp (0 => 259307)


--- trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp	                        (rev 0)
+++ trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UserContentControllerParameters.h"
+
+#include "Decoder.h"
+#include "Encoder.h"
+
+namespace WebKit {
+
+void UserContentControllerParameters::encode(IPC::Encoder& encoder) const
+{
+    encoder << userContentWorlds;
+    encoder << userScripts;
+    encoder << userStyleSheets;
+    encoder << messageHandlers;
+#if ENABLE(CONTENT_EXTENSIONS)
+    encoder << contentRuleLists;
+#endif
+}
+
+Optional<UserContentControllerParameters> UserContentControllerParameters::decode(IPC::Decoder& decoder)
+{
+    Optional<Vector<std::pair<ContentWorldIdentifier, String>>> userContentWorlds;
+    decoder >> userContentWorlds;
+    if (!userContentWorlds)
+        return WTF::nullopt;
+
+    Optional<Vector<WebUserScriptData>> userScripts;
+    decoder >> userScripts;
+    if (!userScripts)
+        return WTF::nullopt;
+    
+    Optional<Vector<WebUserStyleSheetData>> userStyleSheets;
+    decoder >> userStyleSheets;
+    if (!userStyleSheets)
+        return WTF::nullopt;
+    
+    Optional<Vector<WebScriptMessageHandlerData>> messageHandlers;
+    decoder >> messageHandlers;
+    if (!messageHandlers)
+        return WTF::nullopt;
+    
+#if ENABLE(CONTENT_EXTENSIONS)
+    Optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
+    decoder >> contentRuleLists;
+    if (!contentRuleLists)
+        return WTF::nullopt;
+#endif
+
+    return {{
+        WTFMove(*userContentWorlds),
+        WTFMove(*userScripts),
+        WTFMove(*userStyleSheets),
+        WTFMove(*messageHandlers),
+#if ENABLE(CONTENT_EXTENSIONS)
+        WTFMove(*contentRuleLists),
+#endif
+    }};
+}
+    
+} // namespace WebKit

Added: trunk/Source/WebKit/Shared/UserContentControllerParameters.h (0 => 259307)


--- trunk/Source/WebKit/Shared/UserContentControllerParameters.h	                        (rev 0)
+++ trunk/Source/WebKit/Shared/UserContentControllerParameters.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "WebCompiledContentRuleListData.h"
+#include "WebUserContentControllerDataTypes.h"
+
+namespace IPC {
+class Encoder;
+class Decoder;
+}
+
+namespace WebKit {
+
+struct UserContentControllerParameters {
+
+    Vector<std::pair<ContentWorldIdentifier, String>> userContentWorlds;
+    Vector<WebUserScriptData> userScripts;
+    Vector<WebUserStyleSheetData> userStyleSheets;
+    Vector<WebScriptMessageHandlerData> messageHandlers;
+#if ENABLE(CONTENT_EXTENSIONS)
+    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
+#endif
+
+    void encode(IPC::Encoder&) const;
+    static Optional<UserContentControllerParameters> decode(IPC::Decoder&);
+};
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (259306 => 259307)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -129,13 +129,7 @@
     encoder << needsFontAttributes;
     encoder << iceCandidateFilteringEnabled;
     encoder << enumeratingAllNetworkInterfacesEnabled;
-    encoder << userContentWorlds;
-    encoder << userScripts;
-    encoder << userStyleSheets;
-    encoder << messageHandlers;
-#if ENABLE(CONTENT_EXTENSIONS)
-    encoder << contentRuleLists;
-#endif
+    encoder << userContentControllerParameters;
     encoder << backgroundColor;
     encoder << oldPageID;
     encoder << overriddenMediaType;
@@ -402,38 +396,12 @@
     if (!decoder.decode(parameters.enumeratingAllNetworkInterfacesEnabled))
         return WTF::nullopt;
 
-    Optional<Vector<std::pair<ContentWorldIdentifier, String>>> userContentWorlds;
-    decoder >> userContentWorlds;
-    if (!userContentWorlds)
+    Optional<UserContentControllerParameters> userContentControllerParameters;
+    decoder >> userContentControllerParameters;
+    if (!userContentControllerParameters)
         return WTF::nullopt;
-    parameters.userContentWorlds = WTFMove(*userContentWorlds);
+    parameters.userContentControllerParameters = WTFMove(*userContentControllerParameters);
 
-    Optional<Vector<WebUserScriptData>> userScripts;
-    decoder >> userScripts;
-    if (!userScripts)
-        return WTF::nullopt;
-    parameters.userScripts = WTFMove(*userScripts);
-    
-    Optional<Vector<WebUserStyleSheetData>> userStyleSheets;
-    decoder >> userStyleSheets;
-    if (!userStyleSheets)
-        return WTF::nullopt;
-    parameters.userStyleSheets = WTFMove(*userStyleSheets);
-    
-    Optional<Vector<WebScriptMessageHandlerData>> messageHandlers;
-    decoder >> messageHandlers;
-    if (!messageHandlers)
-        return WTF::nullopt;
-    parameters.messageHandlers = WTFMove(*messageHandlers);
-    
-#if ENABLE(CONTENT_EXTENSIONS)
-    Optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
-    decoder >> contentRuleLists;
-    if (!contentRuleLists)
-        return WTF::nullopt;
-    parameters.contentRuleLists = WTFMove(*contentRuleLists);
-#endif
-
     Optional<Optional<WebCore::Color>> backgroundColor;
     decoder >> backgroundColor;
     if (!backgroundColor)

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (259306 => 259307)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -28,12 +28,11 @@
 #include "DrawingAreaInfo.h"
 #include "LayerTreeContext.h"
 #include "SessionState.h"
-#include "WebCompiledContentRuleListData.h"
+#include "UserContentControllerParameters.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebPageGroupData.h"
 #include "WebPageProxyIdentifier.h"
 #include "WebPreferencesStore.h"
-#include "WebUserContentControllerDataTypes.h"
 #include <WebCore/ActivityState.h>
 #include <WebCore/Color.h>
 #include <WebCore/FloatSize.h>
@@ -196,14 +195,7 @@
     bool iceCandidateFilteringEnabled { true };
     bool enumeratingAllNetworkInterfacesEnabled { false };
 
-    // UserContentController members
-    Vector<std::pair<ContentWorldIdentifier, String>> userContentWorlds;
-    Vector<WebUserScriptData> userScripts;
-    Vector<WebUserStyleSheetData> userStyleSheets;
-    Vector<WebScriptMessageHandlerData> messageHandlers;
-#if ENABLE(CONTENT_EXTENSIONS)
-    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
-#endif
+    UserContentControllerParameters userContentControllerParameters;
 
     Optional<WebCore::Color> backgroundColor;
 

Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp (259306 => 259307)


--- trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -45,7 +45,6 @@
     encoder << allowedAutoplayQuirks;
     encoder << customHeaderFields;
     encoder << popUpPolicy;
-    encoder << websiteDataStoreParameters;
     encoder << customUserAgent;
     encoder << customUserAgentAsSiteSpecificQuirks;
     encoder << customNavigatorPlatform;
@@ -91,11 +90,6 @@
     if (!popUpPolicy)
         return WTF::nullopt;
 
-    Optional<Optional<WebsiteDataStoreParameters>> websiteDataStoreParameters;
-    decoder >> websiteDataStoreParameters;
-    if (!websiteDataStoreParameters)
-        return WTF::nullopt;
-
     Optional<String> customUserAgent;
     decoder >> customUserAgent;
     if (!customUserAgent)
@@ -150,7 +144,6 @@
 #endif
         WTFMove(*customHeaderFields),
         WTFMove(*popUpPolicy),
-        WTFMove(*websiteDataStoreParameters),
         WTFMove(*customUserAgent),
         WTFMove(*customUserAgentAsSiteSpecificQuirks),
         WTFMove(*customNavigatorPlatform),

Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.h (259306 => 259307)


--- trunk/Source/WebKit/Shared/WebsitePoliciesData.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -27,7 +27,6 @@
 
 #include "WebsiteAutoplayPolicy.h"
 #include "WebsiteAutoplayQuirk.h"
-#include "WebsiteDataStoreParameters.h"
 #include "WebsiteLegacyOverflowScrollingTouchPolicy.h"
 #include "WebsiteMediaSourcePolicy.h"
 #include "WebsiteMetaViewportPolicy.h"
@@ -60,7 +59,6 @@
 #endif
     Vector<WebCore::CustomHeaderFields> customHeaderFields;
     WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default };
-    Optional<WebsiteDataStoreParameters> websiteDataStoreParameters;
     String customUserAgent;
     String customUserAgentAsSiteSpecificQuirks;
     String customNavigatorPlatform;

Modified: trunk/Source/WebKit/Sources.txt (259306 => 259307)


--- trunk/Source/WebKit/Sources.txt	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/Sources.txt	2020-03-31 20:13:48 UTC (rev 259307)
@@ -181,6 +181,7 @@
 Shared/URLSchemeTaskParameters.cpp
 Shared/UpdateInfo.cpp
 Shared/UserData.cpp
+Shared/UserContentControllerParameters.cpp
 Shared/WebBackForwardListItem.cpp
 Shared/WebCompiledContentRuleList.cpp
 Shared/WebCompiledContentRuleListData.cpp

Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "APIWebsitePolicies.h"
 
+#include "WebUserContentControllerProxy.h"
 #include "WebsiteDataStore.h"
 #include "WebsitePoliciesData.h"
 
@@ -33,16 +34,6 @@
 
 WebsitePolicies::WebsitePolicies() = default;
 
-WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& legacyCustomHeaderFields, Vector<WebCore::CustomHeaderFields>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebKit::WebsiteDataStore>&& websiteDataStore)
-    : m_contentBlockersEnabled(contentBlockersEnabled)
-    , m_allowedAutoplayQuirks(allowedAutoplayQuirks)
-    , m_autoplayPolicy(autoplayPolicy)
-    , m_legacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields))
-    , m_customHeaderFields(WTFMove(customHeaderFields))
-    , m_popUpPolicy(popUpPolicy)
-    , m_websiteDataStore(WTFMove(websiteDataStore))
-{ }
-
 Ref<WebsitePolicies> WebsitePolicies::copy() const
 {
     auto policies = WebsitePolicies::create();
@@ -63,6 +54,8 @@
     policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy);
     policies->setLegacyOverflowScrollingTouchPolicy(m_legacyOverflowScrollingTouchPolicy);
     policies->setAllowContentChangeObserverQuirk(m_allowContentChangeObserverQuirk);
+    policies->setWebsiteDataStore(m_websiteDataStore.get());
+    policies->setUserContentController(m_userContentController.get());
     
     Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields;
     legacyCustomHeaderFields.reserveInitialCapacity(m_legacyCustomHeaderFields.size());
@@ -89,6 +82,11 @@
     m_websiteDataStore = WTFMove(websiteDataStore);
 }
 
+void WebsitePolicies::setUserContentController(RefPtr<WebKit::WebUserContentControllerProxy>&& controller)
+{
+    m_userContentController = WTFMove(controller);
+}
+
 WebKit::WebsitePoliciesData WebsitePolicies::data()
 {
     bool hasLegacyCustomHeaderFields = legacyCustomHeaderFields().size();
@@ -108,7 +106,6 @@
 #endif
         WTFMove(customHeaderFields),
         popUpPolicy(),
-        m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->parameters() } : WTF::nullopt,
         m_customUserAgent,
         m_customUserAgentAsSiteSpecificQuirks,
         m_customNavigatorPlatform,

Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -27,6 +27,7 @@
 
 #include "APIObject.h"
 #include "WebContentMode.h"
+#include "WebUserContentControllerProxy.h"
 #include "WebsiteAutoplayPolicy.h"
 #include "WebsiteAutoplayQuirk.h"
 #include "WebsiteLegacyOverflowScrollingTouchPolicy.h"
@@ -56,6 +57,8 @@
 
     Ref<WebsitePolicies> copy() const;
 
+    WebKit::WebsitePoliciesData data();
+
     bool contentBlockersEnabled() const { return m_contentBlockersEnabled; }
     void setContentBlockersEnabled(bool enabled) { m_contentBlockersEnabled = enabled; }
     
@@ -81,9 +84,10 @@
 
     WebKit::WebsiteDataStore* websiteDataStore() const { return m_websiteDataStore.get(); }
     void setWebsiteDataStore(RefPtr<WebKit::WebsiteDataStore>&&);
+    
+    WebKit::WebUserContentControllerProxy* userContentController() const { return m_userContentController.get(); }
+    void setUserContentController(RefPtr<WebKit::WebUserContentControllerProxy>&&);
 
-    WebKit::WebsitePoliciesData data();
-
     void setCustomUserAgent(const WTF::String& customUserAgent) { m_customUserAgent = customUserAgent; }
     const WTF::String& customUserAgent() const { return m_customUserAgent; }
 
@@ -121,8 +125,6 @@
     void setAllowsContentJavaScript(WebCore::AllowsContentJavaScript allows) { m_allowsContentJavaScript = allows; }
 
 private:
-    WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebKit::WebsiteDataStore>&&);
-
     bool m_contentBlockersEnabled { true };
     OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks;
     WebKit::WebsiteAutoplayPolicy m_autoplayPolicy { WebKit::WebsiteAutoplayPolicy::Default };
@@ -133,6 +135,7 @@
     Vector<WebCore::CustomHeaderFields> m_customHeaderFields;
     WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default };
     RefPtr<WebKit::WebsiteDataStore> m_websiteDataStore;
+    RefPtr<WebKit::WebUserContentControllerProxy> m_userContentController;
     WTF::String m_customUserAgent;
     WTF::String m_customUserAgentAsSiteSpecificQuirks;
     WTF::String m_customNavigatorPlatform;

Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -367,8 +367,9 @@
 
 void WKPageUpdateWebsitePolicies(WKPageRef pageRef, WKWebsitePoliciesRef websitePoliciesRef)
 {
+    RELEASE_ASSERT_WITH_MESSAGE(!toImpl(websitePoliciesRef)->websiteDataStore(), "Setting WebsitePolicies.websiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
+    RELEASE_ASSERT_WITH_MESSAGE(!toImpl(websitePoliciesRef)->userContentController(), "Setting WebsitePolicies.userContentController is only supported during WKFramePolicyListenerUseWithPolicies().");
     auto data = ""
-    RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
     toImpl(pageRef)->updateWebsitePolicies(WTFMove(data));
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-03-31 20:13:48 UTC (rev 259307)
@@ -2315,9 +2315,11 @@
 
 - (void)_updateWebpagePreferences:(WKWebpagePreferences *)webpagePreferences
 {
+    if (webpagePreferences._websiteDataStore)
+        [NSException raise:NSInvalidArgumentException format:@"Updating WKWebsiteDataStore is only supported during decidePolicyForNavigationAction."];
+    if (webpagePreferences._userContentController)
+        [NSException raise:NSInvalidArgumentException format:@"Updating WKUserContentController is only supported during decidePolicyForNavigationAction."];
     auto data = ""
-    if (data.websiteDataStoreParameters)
-        [NSException raise:NSInvalidArgumentException format:@"Updating WKWebsiteDataStore is only supported during decidePolicyForNavigationAction."];
     _page->updateWebsitePolicies(WTFMove(data));
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm	2020-03-31 20:13:48 UTC (rev 259307)
@@ -27,6 +27,7 @@
 #import "WKWebpagePreferences.h"
 
 #import "APICustomHeaderFields.h"
+#import "WKUserContentControllerInternal.h"
 #import "WKWebpagePreferencesInternal.h"
 #import "WKWebsiteDataStoreInternal.h"
 #import "WebContentMode.h"
@@ -276,6 +277,16 @@
     _websitePolicies->setWebsiteDataStore(websiteDataStore->_websiteDataStore.get());
 }
 
+- (WKUserContentController *)_userContentController
+{
+    return wrapper(_websitePolicies->userContentController());
+}
+
+- (void)_setUserContentController:(WKUserContentController *)userContentController
+{
+    _websitePolicies->setUserContentController(userContentController->_userContentControllerProxy.get());
+}
+
 - (void)_setCustomUserAgent:(NSString *)customUserAgent
 {
     _websitePolicies->setCustomUserAgent(customUserAgent);

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -27,7 +27,6 @@
 
 #import <WebKit/WKFoundation.h>
 #import <WebKit/WKWebpagePreferences.h>
-#import <WebKit/WKWebsiteDataStore.h>
 
 typedef NS_ENUM(NSInteger, _WKWebsiteAutoplayPolicy) {
     _WKWebsiteAutoplayPolicyDefault,
@@ -56,6 +55,8 @@
 } WK_API_AVAILABLE(macos(10.14), ios(12.0));
 
 @class _WKCustomHeaderFields;
+@class WKUserContentController;
+@class WKWebsiteDataStore;
 
 @interface WKWebpagePreferences (WKPrivate)
 
@@ -65,6 +66,7 @@
 @property (nonatomic, copy, setter=_setCustomHeaderFields:) NSArray<_WKCustomHeaderFields *> *_customHeaderFields;
 @property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy;
 @property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore;
+@property (nonatomic, strong, setter=_setUserContentController:) WKUserContentController *_userContentController WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
 @property (nonatomic, copy, setter=_setCustomUserAgentAsSiteSpecificQuirks:) NSString *_customUserAgentAsSiteSpecificQuirks;
 @property (nonatomic, copy, setter=_setCustomNavigatorPlatform:) NSString *_customNavigatorPlatform;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2020-03-31 20:13:48 UTC (rev 259307)
@@ -606,10 +606,10 @@
             apiWebsitePolicies = defaultWebsitePolicies;
 
         if (apiWebsitePolicies) {
-            if (auto* websiteDataStore = apiWebsitePolicies->websiteDataStore()) {
-                if (subframeNavigation)
-                    [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._websiteDataStore must be nil for subframe navigations."];
-            }
+            if (apiWebsitePolicies->websiteDataStore() && subframeNavigation)
+                [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._websiteDataStore must be nil for subframe navigations."];
+            if (apiWebsitePolicies->userContentController() && subframeNavigation)
+                [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._userContentController must be nil for subframe navigations."];
             if (!apiWebsitePolicies->customUserAgent().isNull() && subframeNavigation)
                 [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._customUserAgent must be nil for subframe navigations."];
             if (!apiWebsitePolicies->customNavigatorPlatform().isNull() && subframeNavigation)

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -27,6 +27,7 @@
 #include "ProvisionalPageProxy.h"
 
 #include "APINavigation.h"
+#include "APIWebsitePolicies.h"
 #include "DrawingAreaProxy.h"
 #include "FormDataReference.h"
 #include "Logging.h"
@@ -54,7 +55,7 @@
 #define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(m_page.isAlwaysOnLoggingAllowed(), channel, "%p - ProvisionalPageProxy::" fmt, this, ##__VA_ARGS__)
 #define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(m_page.isAlwaysOnLoggingAllowed(), channel, "%p - ProvisionalPageProxy::" fmt, this, ##__VA_ARGS__)
 
-ProvisionalPageProxy::ProvisionalPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, std::unique_ptr<SuspendedPageProxy> suspendedPage, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest& request, ProcessSwapRequestedByClient processSwapRequestedByClient)
+ProvisionalPageProxy::ProvisionalPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, std::unique_ptr<SuspendedPageProxy> suspendedPage, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest& request, ProcessSwapRequestedByClient processSwapRequestedByClient, API::WebsitePolicies* websitePolicies)
     : m_page(page)
     , m_webPageID(suspendedPage ? suspendedPage->webPageID() : PageIdentifier::generate())
     , m_process(WTFMove(process))
@@ -88,7 +89,7 @@
         m_process->frameCreated(suspendedPage->mainFrameID(), *m_mainFrame);
     }
 
-    initializeWebPage();
+    initializeWebPage(websitePolicies);
 
     m_page.inspectorController().didCreateProvisionalPage(*this);
 }
@@ -135,11 +136,11 @@
     didFailProvisionalLoadForFrame(m_mainFrame->frameID(), { }, { }, m_navigationID, m_provisionalLoadURL, error, WebCore::WillContinueLoading::No, UserData { }); // Will delete |this|.
 }
 
-void ProvisionalPageProxy::initializeWebPage()
+void ProvisionalPageProxy::initializeWebPage(RefPtr<API::WebsitePolicies>&& websitePolicies)
 {
     m_drawingArea = m_page.pageClient().createDrawingAreaProxy(m_process);
 
-    auto parameters = m_page.creationParameters(m_process, *m_drawingArea);
+    auto parameters = m_page.creationParameters(m_process, *m_drawingArea, WTFMove(websitePolicies));
     parameters.isProcessSwap = true;
     m_process->send(Messages::WebProcess::CreateWebPage(m_webPageID, parameters), 0);
     m_process->addVisitedLinkStoreUser(m_page.visitedLinkStore(), m_page.identifier());
@@ -168,7 +169,7 @@
     m_page.loadRequestWithNavigationShared(m_process.copyRef(), m_webPageID, navigation, WTFMove(request), navigation.lastNavigationAction().shouldOpenExternalURLsPolicy, userData, WebCore::ShouldTreatAsContinuingLoad::Yes, isNavigatingToAppBoundDomain, hasNavigatedAwayFromAppBoundDomain, WTFMove(websitePolicies));
 }
 
-void ProvisionalPageProxy::goToBackForwardItem(API::Navigation& navigation, WebBackForwardListItem& item, Optional<WebsitePoliciesData>&& websitePolicies)
+void ProvisionalPageProxy::goToBackForwardItem(API::Navigation& navigation, WebBackForwardListItem& item, RefPtr<API::WebsitePolicies>&& websitePolicies)
 {
     RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "goToBackForwardItem: pageProxyID=%" PRIu64 " webPageID=%" PRIu64, m_page.identifier().toUInt64(), m_webPageID.toUInt64());
 
@@ -179,8 +180,13 @@
         }
         return &item != targetItem;
     });
+    
+    Optional<WebsitePoliciesData> websitePoliciesData;
+    if (websitePolicies)
+        websitePoliciesData = websitePolicies->data();
+    
     send(Messages::WebPage::UpdateBackForwardListForReattach(WTFMove(itemStates)));
-    send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePolicies)));
+    send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePoliciesData)));
     m_process->startResponsivenessTimer();
 }
 

Modified: trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -69,7 +69,7 @@
 class ProvisionalPageProxy : public IPC::MessageReceiver, public IPC::MessageSender, public CanMakeWeakPtr<ProvisionalPageProxy> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    ProvisionalPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest&, ProcessSwapRequestedByClient);
+    ProvisionalPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest&, ProcessSwapRequestedByClient, API::WebsitePolicies*);
     ~ProvisionalPageProxy();
 
     WebPageProxy& page() const { return m_page; }
@@ -94,7 +94,7 @@
 
     void loadData(API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, NavigatingToAppBoundDomain, NavigatedAwayFromAppBoundDomain, Optional<WebsitePoliciesData>&& = WTF::nullopt);
     void loadRequest(API::Navigation&, WebCore::ResourceRequest&&, API::Object* userData, NavigatingToAppBoundDomain, NavigatedAwayFromAppBoundDomain, Optional<WebsitePoliciesData>&& = WTF::nullopt);
-    void goToBackForwardItem(API::Navigation&, WebBackForwardListItem&, Optional<WebsitePoliciesData>&&);
+    void goToBackForwardItem(API::Navigation&, WebBackForwardListItem&, RefPtr<API::WebsitePolicies>&&);
     void cancel();
 
     void unfreezeLayerTreeDueToSwipeAnimation();
@@ -143,7 +143,7 @@
     void didCreateContextForVisibilityPropagation(LayerHostingContextID);
 #endif
 
-    void initializeWebPage();
+    void initializeWebPage(RefPtr<API::WebsitePolicies>&&);
     bool validateInput(WebCore::FrameIdentifier, const Optional<uint64_t>& navigationID = WTF::nullopt);
 
     WebPageProxy& m_page;

Modified: trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -96,37 +96,39 @@
 }
 #endif
 
-void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy, WebPageCreationParameters& parameters)
+void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy)
 {
     ASSERT(!m_processes.hasNullReferences());
 
     if (m_processes.add(webProcessProxy).isNewEntry)
         webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier(), *this);
+}
 
-    ASSERT(parameters.userContentWorlds.isEmpty());
+UserContentControllerParameters WebUserContentControllerProxy::parameters() const
+{
+    UserContentControllerParameters parameters;
+
     for (const auto& world : m_contentWorlds)
         parameters.userContentWorlds.append(world.key->worldData());
 
-    ASSERT(parameters.userScripts.isEmpty());
     for (auto userScript : m_userScripts->elementsOfType<API::UserScript>())
         parameters.userScripts.append({ userScript->identifier(), userScript->contentWorld().identifier(), userScript->userScript() });
 
-    ASSERT(parameters.userStyleSheets.isEmpty());
     for (auto userStyleSheet : m_userStyleSheets->elementsOfType<API::UserStyleSheet>())
         parameters.userStyleSheets.append({ userStyleSheet->identifier(), userStyleSheet->contentWorld().identifier(), userStyleSheet->userStyleSheet() });
 
-    ASSERT(parameters.messageHandlers.isEmpty());
     for (auto& handler : m_scriptMessageHandlers.values())
         parameters.messageHandlers.append({ handler->identifier(), handler->world().identifier(), handler->name() });
 
 #if ENABLE(CONTENT_EXTENSIONS)
-    ASSERT(parameters.contentRuleLists.isEmpty());
     parameters.contentRuleLists = contentRuleListData();
 #endif
+    
+    return parameters;
 }
 
 #if ENABLE(CONTENT_EXTENSIONS)
-Vector<std::pair<String, WebCompiledContentRuleListData>> WebUserContentControllerProxy::contentRuleListData()
+Vector<std::pair<String, WebCompiledContentRuleListData>> WebUserContentControllerProxy::contentRuleListData() const
 {
     Vector<std::pair<String, WebCompiledContentRuleListData>> data;
     data.reserveInitialCapacity(m_contentRuleLists.size());

Modified: trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -62,6 +62,7 @@
 struct FrameInfoData;
 class WebCompiledContentRuleListData;
 struct WebPageCreationParameters;
+struct UserContentControllerParameters;
 enum class InjectUserScriptImmediately : bool;
 
 class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver {
@@ -75,7 +76,9 @@
 
     static WebUserContentControllerProxy* get(UserContentControllerIdentifier);
 
-    void addProcess(WebProcessProxy&, WebPageCreationParameters&);
+    UserContentControllerParameters parameters() const;
+
+    void addProcess(WebProcessProxy&);
     void removeProcess(WebProcessProxy&);
 
     API::Array& userScripts() { return m_userScripts.get(); }
@@ -105,7 +108,7 @@
     void removeContentRuleList(const String&);
     void removeAllContentRuleLists();
     const HashMap<String, RefPtr<API::ContentRuleList>>& contentExtensionRules() { return m_contentRuleLists; }
-    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleListData();
+    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleListData() const;
 #endif
 
     UserContentControllerIdentifier identifier() const { return m_identifier; }

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -3160,31 +3160,31 @@
     completionHandler(m_isNavigatingToAppBoundDomain == NavigatingToAppBoundDomain::Yes);
 }
 
-void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation* navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, API::WebsitePolicies* policies, Ref<PolicyDecisionSender>&& sender)
+void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation* navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, RefPtr<API::WebsitePolicies>&& policies, Ref<PolicyDecisionSender>&& sender)
 {
     Ref<WebsiteDataStore> websiteDataStore = m_websiteDataStore.copyRef();
-    Optional<WebsitePoliciesData> data;
     if (policies) {
-        data = ""
         if (policies->websiteDataStore() && policies->websiteDataStore() != websiteDataStore.ptr()) {
             websiteDataStore = *policies->websiteDataStore();
             processSwapRequestedByClient = ProcessSwapRequestedByClient::Yes;
         }
+        if (policies->userContentController() && policies->userContentController() != m_userContentController.ptr())
+            processSwapRequestedByClient = ProcessSwapRequestedByClient::Yes;
     }
 
     if (navigation && !navigation->userContentExtensionsEnabled()) {
-        if (!data)
-            data = "" { };
-        data->contentBlockersEnabled = false;
+        if (!policies)
+            policies = API::WebsitePolicies::create();
+        policies->setContentBlockersEnabled(false);
     }
 
 #if ENABLE(DEVICE_ORIENTATION)
-    if (navigation && (!data || data->deviceOrientationAndMotionAccessState == WebCore::DeviceOrientationOrMotionPermissionState::Prompt)) {
+    if (navigation && (!policies || policies->deviceOrientationAndMotionAccessState() == WebCore::DeviceOrientationOrMotionPermissionState::Prompt)) {
         auto deviceOrientationPermission = websiteDataStore->deviceOrientationAndMotionAccessController().cachedDeviceOrientationPermission(SecurityOriginData::fromURL(navigation->currentRequest().url()));
         if (deviceOrientationPermission != WebCore::DeviceOrientationOrMotionPermissionState::Prompt) {
-            if (!data)
-                data = "" { };
-            data->deviceOrientationAndMotionAccessState = deviceOrientationPermission;
+            if (!policies)
+                policies = API::WebsitePolicies::create();
+            policies->setDeviceOrientationAndMotionAccessState(deviceOrientationPermission);
         }
     }
 #endif
@@ -3198,7 +3198,7 @@
         policyAction = PolicyAction::Download;
 
     if (policyAction != PolicyAction::Use || !frame.isMainFrame() || !navigation) {
-        receivedPolicyDecision(policyAction, navigation, WTFMove(data), WTFMove(sender));
+        receivedPolicyDecision(policyAction, navigation, WTFMove(policies), WTFMove(sender));
         return;
     }
 
@@ -3212,10 +3212,10 @@
     }
 
     process().processPool().processForNavigation(*this, *navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, WTFMove(websiteDataStore), [this, protectedThis = makeRef(*this), policyAction, navigation = makeRef(*navigation), sourceProcess = sourceProcess.copyRef(),
-        data = "" sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable {
+        policies = WTFMove(policies), sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable {
         // If the navigation has been destroyed, then no need to proceed.
         if (isClosed() || !navigationState().hasNavigation(navigation->navigationID())) {
-            receivedPolicyDecision(policyAction, navigation.ptr(), WTFMove(data), WTFMove(sender));
+            receivedPolicyDecision(policyAction, navigation.ptr(), WTFMove(policies), WTFMove(sender));
             return;
         }
 
@@ -3237,14 +3237,14 @@
             if (suspendedPage && suspendedPage->pageIsClosedOrClosing())
                 suspendedPage = nullptr;
 
-            continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, WTFMove(data));
+            continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, std::exchange(policies, nullptr));
         }
 
-        receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? WTF::nullopt : WTFMove(data), WTFMove(sender), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
+        receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? nullptr : WTFMove(policies), WTFMove(sender), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
     });
 }
 
-void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, Optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
+void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, RefPtr<API::WebsitePolicies>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
 {
     if (!hasRunningProcess()) {
         sender->send(PolicyDecision { sender->identifier(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), PolicyAction::Ignore, 0, DownloadID(), WTF::nullopt });
@@ -3269,8 +3269,12 @@
         handleDownloadRequest(download);
         m_decidePolicyForResponseRequest = { };
     }
+    
+    Optional<WebsitePoliciesData> websitePoliciesData;
+    if (websitePolicies)
+        websitePoliciesData = websitePolicies->data();
 
-    sender->send(PolicyDecision { sender->identifier(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), action, navigation ? navigation->navigationID() : 0, downloadID, WTFMove(websitePolicies) });
+    sender->send(PolicyDecision { sender->identifier(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), action, navigation ? navigation->navigationID() : 0, downloadID, WTFMove(websitePoliciesData) });
 }
 
 void WebPageProxy::commitProvisionalPage(FrameIdentifier frameID, FrameInfoData&& frameInfo, ResourceRequest&& request, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo& certificateInfo, bool usedLegacyTLS, bool containsPluginDocument, Optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData& userData)
@@ -3312,7 +3316,7 @@
     m_inspectorController->didCommitProvisionalPage(oldWebPageID, m_webPageID);
 }
 
-void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, Optional<WebsitePoliciesData>&& websitePolicies)
+void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, RefPtr<API::WebsitePolicies>&& websitePolicies)
 {
     RELEASE_LOG_IF_ALLOWED(Loading, "continueNavigationInNewProcess: newProcessPID = %i, hasSuspendedPage = %i", newProcess->processIdentifier(), !!suspendedPage);
     LOG(Loading, "Continuing navigation %" PRIu64 " '%s' in a new web process", navigation.navigationID(), navigation.loggingString());
@@ -3325,7 +3329,7 @@
         m_provisionalPage = nullptr;
     }
 
-    m_provisionalPage = makeUnique<ProvisionalPageProxy>(*this, WTFMove(newProcess), WTFMove(suspendedPage), navigation.navigationID(), navigation.currentRequestIsRedirect(), navigation.currentRequest(), processSwapRequestedByClient);
+    m_provisionalPage = makeUnique<ProvisionalPageProxy>(*this, WTFMove(newProcess), WTFMove(suspendedPage), navigation.navigationID(), navigation.currentRequestIsRedirect(), navigation.currentRequest(), processSwapRequestedByClient, websitePolicies.get());
 
     auto continuation = [this, protectedThis = makeRef(*this), navigation = makeRef(navigation), websitePolicies = WTFMove(websitePolicies)]() mutable {
         if (auto* item = navigation->targetItem()) {
@@ -3344,12 +3348,16 @@
             m_provisionalPage->send(Messages::WebPage::SetCurrentHistoryItemForReattach(m_backForwardList->currentItem()->itemState()));
         }
 
+        Optional<WebsitePoliciesData> websitePoliciesData;
+        if (websitePolicies)
+            websitePoliciesData = websitePolicies->data();
+
         // FIXME: Work out timing of responding with the last policy delegate, etc
         ASSERT(!navigation->currentRequest().isEmpty());
         if (auto& substituteData = navigation->substituteData())
-            m_provisionalPage->loadData(navigation, { substituteData->content.data(), substituteData->content.size() }, substituteData->MIMEType, substituteData->encoding, substituteData->baseURL, substituteData->userData.get(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePolicies));
+            m_provisionalPage->loadData(navigation, { substituteData->content.data(), substituteData->content.size() }, substituteData->MIMEType, substituteData->encoding, substituteData->baseURL, substituteData->userData.get(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePoliciesData));
         else
-            m_provisionalPage->loadRequest(navigation, ResourceRequest { navigation->currentRequest() }, nullptr, isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePolicies));
+            m_provisionalPage->loadRequest(navigation, ResourceRequest { navigation->currentRequest() }, nullptr, isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePoliciesData));
     };
     if (m_inspectorController->shouldPauseLoading(*m_provisionalPage))
         m_inspectorController->setContinueLoadingCallback(*m_provisionalPage, WTFMove(continuation));
@@ -5096,7 +5104,7 @@
 
 #if ENABLE(CONTENT_FILTERING)
     if (frame.didHandleContentFilterUnblockNavigation(request))
-        return receivedPolicyDecision(PolicyAction::Ignore, m_navigationState->navigation(navigationID), WTF::nullopt, WTFMove(sender));
+        return receivedPolicyDecision(PolicyAction::Ignore, m_navigationState->navigation(navigationID), nullptr, WTFMove(sender));
 #endif
 
     ShouldExpectSafeBrowsingResult shouldExpectSafeBrowsingResult = ShouldExpectSafeBrowsingResult::Yes;
@@ -5122,7 +5130,7 @@
                 if (policies)
                     navigation->setEffectiveContentMode(effectiveContentModeAfterAdjustingPolicies(*policies, navigation->currentRequest()));
             }
-            receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, policies.get(), WTFMove(sender));
+            receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, WTFMove(policies), WTFMove(sender));
         };
 
         if (!m_pageClient)
@@ -5304,7 +5312,7 @@
             send(Messages::WebPage::DidReceivePolicyDecision(frameID, listenerID, policyDecision));
         });
 
-        receivedPolicyDecision(policyAction, nullptr, WTF::nullopt, WTFMove(sender));
+        receivedPolicyDecision(policyAction, nullptr, nullptr, WTFMove(sender));
     }, ShouldExpectSafeBrowsingResult::No, ShouldExpectAppBoundDomainResult::No));
 
     if (m_policyClient)
@@ -5352,7 +5360,7 @@
             process->send(Messages::WebPage::DidReceivePolicyDecision(frameID, listenerID, policyDecision), webPageID);
         });
         
-        receivedPolicyDecision(policyAction, navigation.get(), WTF::nullopt, WTFMove(sender));
+        receivedPolicyDecision(policyAction, navigation.get(), nullptr, WTFMove(sender));
     }, ShouldExpectSafeBrowsingResult::No, ShouldExpectAppBoundDomainResult::No));
     if (m_policyClient)
         m_policyClient->decidePolicyForResponse(*this, *frame, response, request, canShowMIMEType, WTFMove(listener), process->transformHandlesToObjects(userData.object()).get());
@@ -7648,7 +7656,7 @@
     m_process->processTerminated();
 }
 
-WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& process, DrawingAreaProxy& drawingArea)
+WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& process, DrawingAreaProxy& drawingArea, RefPtr<API::WebsitePolicies>&& websitePolicies)
 {
     WebPageCreationParameters parameters;
 
@@ -7777,7 +7785,11 @@
     parameters.crossOriginAccessControlCheckEnabled = m_configuration->crossOriginAccessControlCheckEnabled();
     parameters.hasResourceLoadClient = !!m_resourceLoadClient;
 
-    process.addWebUserContentControllerProxy(m_userContentController, parameters);
+    std::reference_wrapper<WebUserContentControllerProxy> userContentController(m_userContentController.get());
+    if (auto* userContentControllerFromWebsitePolicies = websitePolicies ? websitePolicies->userContentController() : nullptr)
+        userContentController = *userContentControllerFromWebsitePolicies;
+    process.addWebUserContentControllerProxy(userContentController);
+    parameters.userContentControllerParameters = userContentController.get().parameters();
 
     parameters.shouldCaptureAudioInUIProcess = preferences().captureAudioInUIProcessEnabled();
     parameters.shouldCaptureAudioInGPUProcess = preferences().captureAudioInGPUProcessEnabled();

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -1123,8 +1123,8 @@
 
     class PolicyDecisionSender;
     enum class WillContinueLoadInNewProcess : bool { No, Yes };
-    void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, Optional<WebsitePoliciesData>&&, Ref<PolicyDecisionSender>&&, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);
-    void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, ProcessSwapRequestedByClient, WebFrameProxy&, API::WebsitePolicies*, Ref<PolicyDecisionSender>&&);
+    void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, RefPtr<API::WebsitePolicies>&&, Ref<PolicyDecisionSender>&&, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);
+    void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, ProcessSwapRequestedByClient, WebFrameProxy&, RefPtr<API::WebsitePolicies>&&, Ref<PolicyDecisionSender>&&);
 
     void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&);
 
@@ -1230,7 +1230,7 @@
     void didChooseFilesForOpenPanel(const Vector<String>&);
     void didCancelForOpenPanel();
 
-    WebPageCreationParameters creationParameters(WebProcessProxy&, DrawingAreaProxy&);
+    WebPageCreationParameters creationParameters(WebProcessProxy&, DrawingAreaProxy&, RefPtr<API::WebsitePolicies>&& = nullptr);
 
     void handleDownloadRequest(DownloadProxy&);
 
@@ -2230,7 +2230,7 @@
 
     void reportPageLoadResult(const WebCore::ResourceError& = { });
 
-    void continueNavigationInNewProcess(API::Navigation&, std::unique_ptr<SuspendedPageProxy>&&, Ref<WebProcessProxy>&&, ProcessSwapRequestedByClient, Optional<WebsitePoliciesData>&&);
+    void continueNavigationInNewProcess(API::Navigation&, std::unique_ptr<SuspendedPageProxy>&&, Ref<WebProcessProxy>&&, ProcessSwapRequestedByClient, RefPtr<API::WebsitePolicies>&&);
 
     void setNeedsFontAttributes(bool);
     void updateFontAttributesAfterEditorStateChange();

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -542,10 +542,10 @@
     }
 }
 
-void WebProcessProxy::addWebUserContentControllerProxy(WebUserContentControllerProxy& proxy, WebPageCreationParameters& parameters)
+void WebProcessProxy::addWebUserContentControllerProxy(WebUserContentControllerProxy& proxy)
 {
     m_webUserContentControllerProxies.add(&proxy);
-    proxy.addProcess(*this, parameters);
+    proxy.addProcess(*this);
 }
 
 void WebProcessProxy::didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy& proxy)

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.h (259306 => 259307)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -178,7 +178,7 @@
     void addVisitedLinkStoreUser(VisitedLinkStore&, WebPageProxyIdentifier);
     void removeVisitedLinkStoreUser(VisitedLinkStore&, WebPageProxyIdentifier);
 
-    void addWebUserContentControllerProxy(WebUserContentControllerProxy&, WebPageCreationParameters&);
+    void addWebUserContentControllerProxy(WebUserContentControllerProxy&);
     void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&);
 
     RefPtr<API::UserInitiatedAction> userInitiatedActivity(uint64_t);

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (259306 => 259307)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-03-31 20:13:48 UTC (rev 259307)
@@ -4034,6 +4034,8 @@
 		5C8DD37D1FE4501100F2A556 /* APIWebsitePolicies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APIWebsitePolicies.cpp; sourceTree = "<group>"; };
 		5C8DD37F1FE4519200F2A556 /* WebsiteAutoplayPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteAutoplayPolicy.h; sourceTree = "<group>"; };
 		5C8DD3811FE455CA00F2A556 /* WebsiteAutoplayQuirk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteAutoplayQuirk.h; sourceTree = "<group>"; };
+		5C9C5C022430535800BB6740 /* UserContentControllerParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentControllerParameters.h; sourceTree = "<group>"; };
+		5C9C5C032430535800BB6740 /* UserContentControllerParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentControllerParameters.cpp; sourceTree = "<group>"; };
 		5C9E56801DF7F05500C9EE33 /* WKWebsitePolicies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKWebsitePolicies.cpp; sourceTree = "<group>"; };
 		5C9E56811DF7F05500C9EE33 /* WKWebsitePolicies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsitePolicies.h; sourceTree = "<group>"; };
 		5C9EF2E721F058F9003BDC56 /* NetworkStorageSessionProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkStorageSessionProvider.h; sourceTree = "<group>"; };
@@ -6044,6 +6046,8 @@
 				5C19A51E1FD0B14600EEA323 /* URLSchemeTaskParameters.cpp */,
 				5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */,
 				41FBE821206D87F6000F0741 /* UserContentControllerIdentifier.h */,
+				5C9C5C032430535800BB6740 /* UserContentControllerParameters.cpp */,
+				5C9C5C022430535800BB6740 /* UserContentControllerParameters.h */,
 				1AC1336518565B5700F3EC05 /* UserData.cpp */,
 				1AC1336618565B5700F3EC05 /* UserData.h */,
 				2684054A18B866FF0022C38B /* VisibleContentRectUpdateInfo.cpp */,

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (259306 => 259307)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -718,12 +718,12 @@
     for (const auto& iterator : parameters.urlSchemeHandlers)
         registerURLSchemeHandler(iterator.value, iterator.key);
 
-    m_userContentController->addContentWorlds(parameters.userContentWorlds);
-    m_userContentController->addUserScripts(WTFMove(parameters.userScripts), InjectUserScriptImmediately::No);
-    m_userContentController->addUserStyleSheets(parameters.userStyleSheets);
-    m_userContentController->addUserScriptMessageHandlers(parameters.messageHandlers);
+    m_userContentController->addContentWorlds(parameters.userContentControllerParameters.userContentWorlds);
+    m_userContentController->addUserScripts(WTFMove(parameters.userContentControllerParameters.userScripts), InjectUserScriptImmediately::No);
+    m_userContentController->addUserStyleSheets(parameters.userContentControllerParameters.userStyleSheets);
+    m_userContentController->addUserScriptMessageHandlers(parameters.userContentControllerParameters.messageHandlers);
 #if ENABLE(CONTENT_EXTENSIONS)
-    m_userContentController->addContentRuleLists(WTFMove(parameters.contentRuleLists));
+    m_userContentController->addContentRuleLists(WTFMove(parameters.userContentControllerParameters.contentRuleLists));
 #endif
 
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (259306 => 259307)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-03-31 20:13:48 UTC (rev 259307)
@@ -791,7 +791,7 @@
     }
 #endif
 
-    LOG_ERROR("Unhandled web process message '%s:%s' (destination: %" PRIu64 ")", decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data(), decoder.destinationID());
+    LOG_ERROR("Unhandled web process message '%s::%s' (destination: %" PRIu64 " pid: %d)", decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data(), decoder.destinationID(), static_cast<int>(getCurrentProcessID()));
 }
 
 WebFrame* WebProcess::webFrame(FrameIdentifier frameID) const

Modified: trunk/Tools/ChangeLog (259306 => 259307)


--- trunk/Tools/ChangeLog	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Tools/ChangeLog	2020-03-31 20:13:48 UTC (rev 259307)
@@ -1,3 +1,20 @@
+2020-03-31  Alex Christensen  <[email protected]>
+
+        Add SPI WKWebpagePreferences._userContentController
+        https://bugs.webkit.org/show_bug.cgi?id=209795
+
+        Reviewed by Tim Hatcher.
+
+        * TestWebKitAPI/SourcesCocoa.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
+        (-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): Deleted.
+        * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+        * TestWebKitAPI/cocoa/TestUIDelegate.h: Added.
+        * TestWebKitAPI/cocoa/TestUIDelegate.mm: Added.
+        (-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (-[TestUIDelegate waitForAlert]):
+
 2020-03-31  Aakash Jain  <[email protected]>
 
         Delete code for security EWS from old EWS (follow-up fix)

Modified: trunk/Tools/TestWebKitAPI/SourcesCocoa.txt (259306 => 259307)


--- trunk/Tools/TestWebKitAPI/SourcesCocoa.txt	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Tools/TestWebKitAPI/SourcesCocoa.txt	2020-03-31 20:13:48 UTC (rev 259307)
@@ -28,6 +28,7 @@
 cocoa/TestCocoa.mm
 cocoa/TestNavigationDelegate.mm
 cocoa/TestProtocol.mm
+cocoa/TestUIDelegate.mm
 cocoa/TestWKWebView.mm
 
 Tests/WebKitCocoa/TLSDeprecation.mm

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (259306 => 259307)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-03-31 20:13:48 UTC (rev 259307)
@@ -2084,6 +2084,8 @@
 		5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UIDelegate.mm; sourceTree = "<group>"; };
 		5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameHandleSerialization.mm; sourceTree = "<group>"; };
 		5CB7AFDB23C451E400E49CF3 /* ResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceLoadDelegate.mm; sourceTree = "<group>"; };
+		5CBAA7F324327F6B00564A8B /* TestUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestUIDelegate.h; path = cocoa/TestUIDelegate.h; sourceTree = "<group>"; };
+		5CBAA7F424327F6B00564A8B /* TestUIDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestUIDelegate.mm; path = cocoa/TestUIDelegate.mm; sourceTree = "<group>"; };
 		5CCB10DD2134579C00AC5AF0 /* ResponsivenessTimerDoesntFireEarly.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimerDoesntFireEarly.mm; sourceTree = "<group>"; };
 		5CCB10DE2134579D00AC5AF0 /* RestoreSessionStateWithoutNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreSessionStateWithoutNavigation.mm; sourceTree = "<group>"; };
 		5CCB10DF2134579D00AC5AF0 /* ShouldGoToBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShouldGoToBackForwardListItem.mm; sourceTree = "<group>"; };
@@ -2901,6 +2903,8 @@
 				516281242325C17B00BB7E42 /* TestPDFDocument.mm */,
 				A14FC58D1B8AE36500D107EB /* TestProtocol.h */,
 				A14FC58E1B8AE36500D107EB /* TestProtocol.mm */,
+				5CBAA7F324327F6B00564A8B /* TestUIDelegate.h */,
+				5CBAA7F424327F6B00564A8B /* TestUIDelegate.mm */,
 				2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */,
 				2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */,
 				7C83E0391D0A602700FEBCF3 /* UtilitiesCocoa.mm */,

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm (259306 => 259307)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm	2020-03-31 20:13:48 UTC (rev 259307)
@@ -29,6 +29,7 @@
 #import "PlatformUtilities.h"
 #import "TCPServer.h"
 #import "TestNavigationDelegate.h"
+#import "TestUIDelegate.h"
 #import "TestWKWebView.h"
 #import <WebKit/WKWebViewPrivate.h>
 #import <WebKit/WebKit.h>
@@ -81,24 +82,6 @@
 
 @end
 
-@interface TestUIDelegate : NSObject <WKUIDelegate>
-
-@property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void));
-
-@end
-
-@implementation TestUIDelegate
-
-- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
-{
-    if (_runJavaScriptAlertPanelWithMessage)
-        _runJavaScriptAlertPanelWithMessage(webView, message, frame, completionHandler);
-    else
-        completionHandler();
-}
-
-@end
-
 TEST(ResourceLoadDelegate, Basic)
 {
     auto webView = adoptNS([WKWebView new]);

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (259306 => 259307)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm	2020-03-31 20:08:10 UTC (rev 259306)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm	2020-03-31 20:13:48 UTC (rev 259307)
@@ -27,6 +27,7 @@
 
 #import "PlatformUtilities.h"
 #import "TestNavigationDelegate.h"
+#import "TestUIDelegate.h"
 #import "TestWKWebView.h"
 #import <WebKit/WKMutableDictionary.h>
 #import <WebKit/WKNavigationDelegatePrivate.h>
@@ -1723,3 +1724,59 @@
 
     EXPECT_NE(pid1, [cookieWebView _webProcessIdentifier]);
 }
+
+TEST(WebpagePreferences, WebsitePoliciesUserContentController)
+{
+    auto makeScript = [] (NSString *script) {
+        return [[[WKUserScript alloc] initWithSource:script injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES] autorelease];
+    };
+    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease];
+    [configuration.userContentController addUserScript:makeScript(@"alert('testAlert1')")];
+    TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease];
+    TestUIDelegate *uiDelegate = [[TestUIDelegate new] autorelease];
+    webView.UIDelegate = uiDelegate;
+    TestNavigationDelegate *navigationDelegate = [[TestNavigationDelegate new] autorelease];
+    __block bool iframeExceptionThrown = false;
+    __block RetainPtr<WKUserContentController> replacementUserContentController;
+    navigationDelegate.decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *action, WKWebpagePreferences *, void (^completionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+        if ([action.request.URL.path hasSuffix:@"/simple-iframe.html"])
+            return completionHandler(WKNavigationActionPolicyAllow, nil);
+        if ([action.request.URL.path hasSuffix:@"/simple.html"]) {
+            @try {
+                WKWebpagePreferences *preferences = [[WKWebpagePreferences new] autorelease];
+                preferences._userContentController = [[WKUserContentController new] autorelease];
+                return completionHandler(WKNavigationActionPolicyAllow, preferences);
+            } @catch (NSException *exception) {
+                iframeExceptionThrown = true;
+            }
+            return;
+        }
+        
+        EXPECT_TRUE([action.request.URL.path hasSuffix:@"/simple2.html"]);
+        WKWebpagePreferences *preferences = [[WKWebpagePreferences new] autorelease];
+        replacementUserContentController = adoptNS([WKUserContentController new]);
+        [replacementUserContentController addUserScript:makeScript(@"alert('testAlert2')")];
+        preferences._userContentController = replacementUserContentController.get();
+        completionHandler(WKNavigationActionPolicyAllow, preferences);
+    };
+    webView.navigationDelegate = navigationDelegate;
+
+    [webView loadTestPageNamed:@"simple-iframe"];
+    EXPECT_WK_STREQ([uiDelegate waitForAlert], "testAlert1");
+    TestWebKitAPI::Util::run(&iframeExceptionThrown);
+
+    [webView loadTestPageNamed:@"simple2"];
+    EXPECT_WK_STREQ([uiDelegate waitForAlert], "testAlert2");
+
+    bool caughtException = false;
+    @try {
+        WKWebpagePreferences *preferences = [[WKWebpagePreferences new] autorelease];
+        preferences._userContentController = [[WKUserContentController new] autorelease];
+        [webView _updateWebpagePreferences:preferences];
+    } @catch (NSException *exception) {
+        caughtException = true;
+    }
+    EXPECT_TRUE(caughtException);
+
+    // FIXME: Make _addUserScriptImmediately work successfully after using WKWebpagePreferences._userContentController
+}

Added: trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h (0 => 259307)


--- trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.h	2020-03-31 20:13:48 UTC (rev 259307)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import <WebKit/WKUIDelegatePrivate.h>
+
+@interface TestUIDelegate : NSObject <WKUIDelegate>
+
+@property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void));
+
+- (NSString *)waitForAlert;
+
+@end

Added: trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm (0 => 259307)


--- trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestUIDelegate.mm	2020-03-31 20:13:48 UTC (rev 259307)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "TestUIDelegate.h"
+
+#import "Utilities.h"
+#import <WebKit/WKWebViewPrivateForTesting.h>
+#import <wtf/RetainPtr.h>
+
+@implementation TestUIDelegate
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
+{
+    if (_runJavaScriptAlertPanelWithMessage)
+        _runJavaScriptAlertPanelWithMessage(webView, message, frame, completionHandler);
+    else
+        completionHandler();
+}
+
+- (NSString *)waitForAlert
+{
+    EXPECT_FALSE(self.runJavaScriptAlertPanelWithMessage);
+
+    __block bool finished = false;
+    __block RetainPtr<NSString> result;
+    self.runJavaScriptAlertPanelWithMessage = ^(WKWebView *, NSString *message, WKFrameInfo *, void (^completionHandler)(void)) {
+        result = message;
+        finished = true;
+        completionHandler();
+    };
+
+    TestWebKitAPI::Util::run(&finished);
+
+    self.runJavaScriptAlertPanelWithMessage = nil;
+    return result.autorelease();
+}
+
+@end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to