Changeset 259307 in webkit


Ignore:
Timestamp:
Mar 31, 2020 1:13:48 PM (4 years ago)
Author:
achristensen@apple.com
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]):

Location:
trunk
Files:
4 added
30 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259306 r259307  
     12020-03-31  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add SPI WKWebpagePreferences._userContentController
     4        https://bugs.webkit.org/show_bug.cgi?id=209795
     5
     6        Reviewed by Tim Hatcher.
     7
     8        This will allow us to switch which WKUserContentController we are using at decidePolicyForNavigationAction time
     9        like we do WKWebsiteDataStores.  This is only allowed with main frame navigations.
     10
     11        To do this I moved UserContentControllerParameters into their own struct.
     12        I remove unused WebsitePoliciesData.websiteDataStoreParameters.
     13        I pass an API::WebsitePolicies* further down the chain instead of switching to Optional<WebsitePoliciesData>,
     14        which allows us to access the WebUserContentControllerProxy* from the former in WebPageProxy::creationParameters.
     15        I removed an unused WebsitePolicies constructor.
     16        I added a missing copied member variable in WebsitePolicies::copy.
     17
     18        * NetworkProcess/NetworkSession.cpp:
     19        * Shared/UserContentControllerParameters.cpp: Added.
     20        (WebKit::UserContentControllerParameters::encode const):
     21        (WebKit::UserContentControllerParameters::decode):
     22        * Shared/UserContentControllerParameters.h: Added.
     23        * Shared/WebPageCreationParameters.cpp:
     24        (WebKit::WebPageCreationParameters::encode const):
     25        (WebKit::WebPageCreationParameters::decode):
     26        * Shared/WebPageCreationParameters.h:
     27        * Shared/WebsitePoliciesData.cpp:
     28        (WebKit::WebsitePoliciesData::encode const):
     29        (WebKit::WebsitePoliciesData::decode):
     30        * Shared/WebsitePoliciesData.h:
     31        * Sources.txt:
     32        * UIProcess/API/APIWebsitePolicies.cpp:
     33        (API::WebsitePolicies::copy const):
     34        (API::WebsitePolicies::setUserContentController):
     35        (API::WebsitePolicies::data):
     36        (API::WebsitePolicies::WebsitePolicies): Deleted.
     37        * UIProcess/API/APIWebsitePolicies.h:
     38        * UIProcess/API/C/WKPage.cpp:
     39        (WKPageUpdateWebsitePolicies):
     40        * UIProcess/API/Cocoa/WKWebView.mm:
     41        (-[WKWebView _updateWebpagePreferences:]):
     42        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
     43        (-[WKWebpagePreferences _userContentController]):
     44        (-[WKWebpagePreferences _setUserContentController:]):
     45        * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
     46        * UIProcess/Cocoa/NavigationState.mm:
     47        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
     48        * UIProcess/ProvisionalPageProxy.cpp:
     49        (WebKit::ProvisionalPageProxy::ProvisionalPageProxy):
     50        (WebKit::ProvisionalPageProxy::initializeWebPage):
     51        (WebKit::ProvisionalPageProxy::goToBackForwardItem):
     52        * UIProcess/ProvisionalPageProxy.h:
     53        * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
     54        (WebKit::WebUserContentControllerProxy::addProcess):
     55        (WebKit::WebUserContentControllerProxy::parameters const):
     56        (WebKit::WebUserContentControllerProxy::contentRuleListData const):
     57        (WebKit::WebUserContentControllerProxy::contentRuleListData): Deleted.
     58        * UIProcess/UserContent/WebUserContentControllerProxy.h:
     59        * UIProcess/WebPageProxy.cpp:
     60        (WebKit::WebPageProxy::receivedNavigationPolicyDecision):
     61        (WebKit::WebPageProxy::receivedPolicyDecision):
     62        (WebKit::WebPageProxy::continueNavigationInNewProcess):
     63        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
     64        (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
     65        (WebKit::WebPageProxy::decidePolicyForResponseShared):
     66        * UIProcess/WebPageProxy.h:
     67        * UIProcess/WebProcessProxy.cpp:
     68        (WebKit::WebProcessProxy::addWebUserContentControllerProxy):
     69        * UIProcess/WebProcessProxy.h:
     70        * WebKit.xcodeproj/project.pbxproj:
     71        * WebProcess/WebPage/WebPage.cpp:
     72        (WebKit::m_processDisplayName):
     73        * WebProcess/WebProcess.cpp:
     74        (WebKit::WebProcess::didReceiveMessage):
     75
    1762020-03-31  Alex Christensen  <achristensen@webkit.org>
    277
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r259275 r259307  
    3333#include "NetworkResourceLoadParameters.h"
    3434#include "NetworkResourceLoader.h"
     35#include "NetworkSessionCreationParameters.h"
    3536#include "PingLoad.h"
    3637#include "WebPageProxy.h"
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp

    r259209 r259307  
    130130    encoder << iceCandidateFilteringEnabled;
    131131    encoder << enumeratingAllNetworkInterfacesEnabled;
    132     encoder << userContentWorlds;
    133     encoder << userScripts;
    134     encoder << userStyleSheets;
    135     encoder << messageHandlers;
    136 #if ENABLE(CONTENT_EXTENSIONS)
    137     encoder << contentRuleLists;
    138 #endif
     132    encoder << userContentControllerParameters;
    139133    encoder << backgroundColor;
    140134    encoder << oldPageID;
     
    403397        return WTF::nullopt;
    404398
    405     Optional<Vector<std::pair<ContentWorldIdentifier, String>>> userContentWorlds;
    406     decoder >> userContentWorlds;
    407     if (!userContentWorlds)
    408         return WTF::nullopt;
    409     parameters.userContentWorlds = WTFMove(*userContentWorlds);
    410 
    411     Optional<Vector<WebUserScriptData>> userScripts;
    412     decoder >> userScripts;
    413     if (!userScripts)
    414         return WTF::nullopt;
    415     parameters.userScripts = WTFMove(*userScripts);
    416    
    417     Optional<Vector<WebUserStyleSheetData>> userStyleSheets;
    418     decoder >> userStyleSheets;
    419     if (!userStyleSheets)
    420         return WTF::nullopt;
    421     parameters.userStyleSheets = WTFMove(*userStyleSheets);
    422    
    423     Optional<Vector<WebScriptMessageHandlerData>> messageHandlers;
    424     decoder >> messageHandlers;
    425     if (!messageHandlers)
    426         return WTF::nullopt;
    427     parameters.messageHandlers = WTFMove(*messageHandlers);
    428    
    429 #if ENABLE(CONTENT_EXTENSIONS)
    430     Optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
    431     decoder >> contentRuleLists;
    432     if (!contentRuleLists)
    433         return WTF::nullopt;
    434     parameters.contentRuleLists = WTFMove(*contentRuleLists);
    435 #endif
     399    Optional<UserContentControllerParameters> userContentControllerParameters;
     400    decoder >> userContentControllerParameters;
     401    if (!userContentControllerParameters)
     402        return WTF::nullopt;
     403    parameters.userContentControllerParameters = WTFMove(*userContentControllerParameters);
    436404
    437405    Optional<Optional<WebCore::Color>> backgroundColor;
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.h

    r259209 r259307  
    2929#include "LayerTreeContext.h"
    3030#include "SessionState.h"
    31 #include "WebCompiledContentRuleListData.h"
     31#include "UserContentControllerParameters.h"
    3232#include "WebCoreArgumentCoders.h"
    3333#include "WebPageGroupData.h"
    3434#include "WebPageProxyIdentifier.h"
    3535#include "WebPreferencesStore.h"
    36 #include "WebUserContentControllerDataTypes.h"
    3736#include <WebCore/ActivityState.h>
    3837#include <WebCore/Color.h>
     
    197196    bool enumeratingAllNetworkInterfacesEnabled { false };
    198197
    199     // UserContentController members
    200     Vector<std::pair<ContentWorldIdentifier, String>> userContentWorlds;
    201     Vector<WebUserScriptData> userScripts;
    202     Vector<WebUserStyleSheetData> userStyleSheets;
    203     Vector<WebScriptMessageHandlerData> messageHandlers;
    204 #if ENABLE(CONTENT_EXTENSIONS)
    205     Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
    206 #endif
     198    UserContentControllerParameters userContentControllerParameters;
    207199
    208200    Optional<WebCore::Color> backgroundColor;
  • trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp

    r256715 r259307  
    4646    encoder << customHeaderFields;
    4747    encoder << popUpPolicy;
    48     encoder << websiteDataStoreParameters;
    4948    encoder << customUserAgent;
    5049    encoder << customUserAgentAsSiteSpecificQuirks;
     
    9291        return WTF::nullopt;
    9392
    94     Optional<Optional<WebsiteDataStoreParameters>> websiteDataStoreParameters;
    95     decoder >> websiteDataStoreParameters;
    96     if (!websiteDataStoreParameters)
    97         return WTF::nullopt;
    98 
    9993    Optional<String> customUserAgent;
    10094    decoder >> customUserAgent;
     
    151145        WTFMove(*customHeaderFields),
    152146        WTFMove(*popUpPolicy),
    153         WTFMove(*websiteDataStoreParameters),
    154147        WTFMove(*customUserAgent),
    155148        WTFMove(*customUserAgentAsSiteSpecificQuirks),
  • trunk/Source/WebKit/Shared/WebsitePoliciesData.h

    r256715 r259307  
    2828#include "WebsiteAutoplayPolicy.h"
    2929#include "WebsiteAutoplayQuirk.h"
    30 #include "WebsiteDataStoreParameters.h"
    3130#include "WebsiteLegacyOverflowScrollingTouchPolicy.h"
    3231#include "WebsiteMediaSourcePolicy.h"
     
    6160    Vector<WebCore::CustomHeaderFields> customHeaderFields;
    6261    WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default };
    63     Optional<WebsiteDataStoreParameters> websiteDataStoreParameters;
    6462    String customUserAgent;
    6563    String customUserAgentAsSiteSpecificQuirks;
  • trunk/Source/WebKit/Sources.txt

    r259200 r259307  
    182182Shared/UpdateInfo.cpp
    183183Shared/UserData.cpp
     184Shared/UserContentControllerParameters.cpp
    184185Shared/WebBackForwardListItem.cpp
    185186Shared/WebCompiledContentRuleList.cpp
  • trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp

    r256715 r259307  
    2727#include "APIWebsitePolicies.h"
    2828
     29#include "WebUserContentControllerProxy.h"
    2930#include "WebsiteDataStore.h"
    3031#include "WebsitePoliciesData.h"
     
    3334
    3435WebsitePolicies::WebsitePolicies() = default;
    35 
    36 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)
    37     : m_contentBlockersEnabled(contentBlockersEnabled)
    38     , m_allowedAutoplayQuirks(allowedAutoplayQuirks)
    39     , m_autoplayPolicy(autoplayPolicy)
    40     , m_legacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields))
    41     , m_customHeaderFields(WTFMove(customHeaderFields))
    42     , m_popUpPolicy(popUpPolicy)
    43     , m_websiteDataStore(WTFMove(websiteDataStore))
    44 { }
    4536
    4637Ref<WebsitePolicies> WebsitePolicies::copy() const
     
    6455    policies->setLegacyOverflowScrollingTouchPolicy(m_legacyOverflowScrollingTouchPolicy);
    6556    policies->setAllowContentChangeObserverQuirk(m_allowContentChangeObserverQuirk);
     57    policies->setWebsiteDataStore(m_websiteDataStore.get());
     58    policies->setUserContentController(m_userContentController.get());
    6659   
    6760    Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields;
     
    9083}
    9184
     85void WebsitePolicies::setUserContentController(RefPtr<WebKit::WebUserContentControllerProxy>&& controller)
     86{
     87    m_userContentController = WTFMove(controller);
     88}
     89
    9290WebKit::WebsitePoliciesData WebsitePolicies::data()
    9391{
     
    109107        WTFMove(customHeaderFields),
    110108        popUpPolicy(),
    111         m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->parameters() } : WTF::nullopt,
    112109        m_customUserAgent,
    113110        m_customUserAgentAsSiteSpecificQuirks,
  • trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h

    r256715 r259307  
    2828#include "APIObject.h"
    2929#include "WebContentMode.h"
     30#include "WebUserContentControllerProxy.h"
    3031#include "WebsiteAutoplayPolicy.h"
    3132#include "WebsiteAutoplayQuirk.h"
     
    5758    Ref<WebsitePolicies> copy() const;
    5859
     60    WebKit::WebsitePoliciesData data();
     61
    5962    bool contentBlockersEnabled() const { return m_contentBlockersEnabled; }
    6063    void setContentBlockersEnabled(bool enabled) { m_contentBlockersEnabled = enabled; }
     
    8285    WebKit::WebsiteDataStore* websiteDataStore() const { return m_websiteDataStore.get(); }
    8386    void setWebsiteDataStore(RefPtr<WebKit::WebsiteDataStore>&&);
    84 
    85     WebKit::WebsitePoliciesData data();
     87   
     88    WebKit::WebUserContentControllerProxy* userContentController() const { return m_userContentController.get(); }
     89    void setUserContentController(RefPtr<WebKit::WebUserContentControllerProxy>&&);
    8690
    8791    void setCustomUserAgent(const WTF::String& customUserAgent) { m_customUserAgent = customUserAgent; }
     
    122126
    123127private:
    124     WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebKit::WebsiteDataStore>&&);
    125 
    126128    bool m_contentBlockersEnabled { true };
    127129    OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks;
     
    134136    WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default };
    135137    RefPtr<WebKit::WebsiteDataStore> m_websiteDataStore;
     138    RefPtr<WebKit::WebUserContentControllerProxy> m_userContentController;
    136139    WTF::String m_customUserAgent;
    137140    WTF::String m_customUserAgentAsSiteSpecificQuirks;
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r259171 r259307  
    368368void WKPageUpdateWebsitePolicies(WKPageRef pageRef, WKWebsitePoliciesRef websitePoliciesRef)
    369369{
     370    RELEASE_ASSERT_WITH_MESSAGE(!toImpl(websitePoliciesRef)->websiteDataStore(), "Setting WebsitePolicies.websiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
     371    RELEASE_ASSERT_WITH_MESSAGE(!toImpl(websitePoliciesRef)->userContentController(), "Setting WebsitePolicies.userContentController is only supported during WKFramePolicyListenerUseWithPolicies().");
    370372    auto data = toImpl(websitePoliciesRef)->data();
    371     RELEASE_ASSERT_WITH_MESSAGE(!data.websiteDataStoreParameters, "Setting WebsitePolicies.WebsiteDataStore is only supported during WKFramePolicyListenerUseWithPolicies().");
    372373    toImpl(pageRef)->updateWebsitePolicies(WTFMove(data));
    373374}
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r259306 r259307  
    23162316- (void)_updateWebpagePreferences:(WKWebpagePreferences *)webpagePreferences
    23172317{
     2318    if (webpagePreferences._websiteDataStore)
     2319        [NSException raise:NSInvalidArgumentException format:@"Updating WKWebsiteDataStore is only supported during decidePolicyForNavigationAction."];
     2320    if (webpagePreferences._userContentController)
     2321        [NSException raise:NSInvalidArgumentException format:@"Updating WKUserContentController is only supported during decidePolicyForNavigationAction."];
    23182322    auto data = webpagePreferences->_websitePolicies->data();
    2319     if (data.websiteDataStoreParameters)
    2320         [NSException raise:NSInvalidArgumentException format:@"Updating WKWebsiteDataStore is only supported during decidePolicyForNavigationAction."];
    23212323    _page->updateWebsitePolicies(WTFMove(data));
    23222324}
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm

    r256715 r259307  
    2828
    2929#import "APICustomHeaderFields.h"
     30#import "WKUserContentControllerInternal.h"
    3031#import "WKWebpagePreferencesInternal.h"
    3132#import "WKWebsiteDataStoreInternal.h"
     
    277278}
    278279
     280- (WKUserContentController *)_userContentController
     281{
     282    return wrapper(_websitePolicies->userContentController());
     283}
     284
     285- (void)_setUserContentController:(WKUserContentController *)userContentController
     286{
     287    _websitePolicies->setUserContentController(userContentController->_userContentControllerProxy.get());
     288}
     289
    279290- (void)_setCustomUserAgent:(NSString *)customUserAgent
    280291{
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h

    r253090 r259307  
    2828#import <WebKit/WKFoundation.h>
    2929#import <WebKit/WKWebpagePreferences.h>
    30 #import <WebKit/WKWebsiteDataStore.h>
    3130
    3231typedef NS_ENUM(NSInteger, _WKWebsiteAutoplayPolicy) {
     
    5756
    5857@class _WKCustomHeaderFields;
     58@class WKUserContentController;
     59@class WKWebsiteDataStore;
    5960
    6061@interface WKWebpagePreferences (WKPrivate)
     
    6667@property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy;
    6768@property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore;
     69@property (nonatomic, strong, setter=_setUserContentController:) WKUserContentController *_userContentController WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    6870@property (nonatomic, copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
    6971@property (nonatomic, copy, setter=_setCustomUserAgentAsSiteSpecificQuirks:) NSString *_customUserAgentAsSiteSpecificQuirks;
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r259177 r259307  
    607607
    608608        if (apiWebsitePolicies) {
    609             if (auto* websiteDataStore = apiWebsitePolicies->websiteDataStore()) {
    610                 if (subframeNavigation)
    611                     [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._websiteDataStore must be nil for subframe navigations."];
    612             }
     609            if (apiWebsitePolicies->websiteDataStore() && subframeNavigation)
     610                [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._websiteDataStore must be nil for subframe navigations."];
     611            if (apiWebsitePolicies->userContentController() && subframeNavigation)
     612                [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._userContentController must be nil for subframe navigations."];
    613613            if (!apiWebsitePolicies->customUserAgent().isNull() && subframeNavigation)
    614614                [NSException raise:NSInvalidArgumentException format:@"WKWebpagePreferences._customUserAgent must be nil for subframe navigations."];
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp

    r257963 r259307  
    2828
    2929#include "APINavigation.h"
     30#include "APIWebsitePolicies.h"
    3031#include "DrawingAreaProxy.h"
    3132#include "FormDataReference.h"
     
    5556#define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(m_page.isAlwaysOnLoggingAllowed(), channel, "%p - ProvisionalPageProxy::" fmt, this, ##__VA_ARGS__)
    5657
    57 ProvisionalPageProxy::ProvisionalPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, std::unique_ptr<SuspendedPageProxy> suspendedPage, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest& request, ProcessSwapRequestedByClient processSwapRequestedByClient)
     58ProvisionalPageProxy::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)
    5859    : m_page(page)
    5960    , m_webPageID(suspendedPage ? suspendedPage->webPageID() : PageIdentifier::generate())
     
    8990    }
    9091
    91     initializeWebPage();
     92    initializeWebPage(websitePolicies);
    9293
    9394    m_page.inspectorController().didCreateProvisionalPage(*this);
     
    136137}
    137138
    138 void ProvisionalPageProxy::initializeWebPage()
     139void ProvisionalPageProxy::initializeWebPage(RefPtr<API::WebsitePolicies>&& websitePolicies)
    139140{
    140141    m_drawingArea = m_page.pageClient().createDrawingAreaProxy(m_process);
    141142
    142     auto parameters = m_page.creationParameters(m_process, *m_drawingArea);
     143    auto parameters = m_page.creationParameters(m_process, *m_drawingArea, WTFMove(websitePolicies));
    143144    parameters.isProcessSwap = true;
    144145    m_process->send(Messages::WebProcess::CreateWebPage(m_webPageID, parameters), 0);
     
    169170}
    170171
    171 void ProvisionalPageProxy::goToBackForwardItem(API::Navigation& navigation, WebBackForwardListItem& item, Optional<WebsitePoliciesData>&& websitePolicies)
     172void ProvisionalPageProxy::goToBackForwardItem(API::Navigation& navigation, WebBackForwardListItem& item, RefPtr<API::WebsitePolicies>&& websitePolicies)
    172173{
    173174    RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "goToBackForwardItem: pageProxyID=%" PRIu64 " webPageID=%" PRIu64, m_page.identifier().toUInt64(), m_webPageID.toUInt64());
     
    180181        return &item != targetItem;
    181182    });
     183   
     184    Optional<WebsitePoliciesData> websitePoliciesData;
     185    if (websitePolicies)
     186        websitePoliciesData = websitePolicies->data();
     187   
    182188    send(Messages::WebPage::UpdateBackForwardListForReattach(WTFMove(itemStates)));
    183     send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePolicies)));
     189    send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePoliciesData)));
    184190    m_process->startResponsivenessTimer();
    185191}
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h

    r257963 r259307  
    7070    WTF_MAKE_FAST_ALLOCATED;
    7171public:
    72     ProvisionalPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest&, ProcessSwapRequestedByClient);
     72    ProvisionalPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest&, ProcessSwapRequestedByClient, API::WebsitePolicies*);
    7373    ~ProvisionalPageProxy();
    7474
     
    9595    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);
    9696    void loadRequest(API::Navigation&, WebCore::ResourceRequest&&, API::Object* userData, NavigatingToAppBoundDomain, NavigatedAwayFromAppBoundDomain, Optional<WebsitePoliciesData>&& = WTF::nullopt);
    97     void goToBackForwardItem(API::Navigation&, WebBackForwardListItem&, Optional<WebsitePoliciesData>&&);
     97    void goToBackForwardItem(API::Navigation&, WebBackForwardListItem&, RefPtr<API::WebsitePolicies>&&);
    9898    void cancel();
    9999
     
    144144#endif
    145145
    146     void initializeWebPage();
     146    void initializeWebPage(RefPtr<API::WebsitePolicies>&&);
    147147    bool validateInput(WebCore::FrameIdentifier, const Optional<uint64_t>& navigationID = WTF::nullopt);
    148148
  • trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp

    r257552 r259307  
    9797#endif
    9898
    99 void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy, WebPageCreationParameters& parameters)
     99void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy)
    100100{
    101101    ASSERT(!m_processes.hasNullReferences());
     
    103103    if (m_processes.add(webProcessProxy).isNewEntry)
    104104        webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier(), *this);
    105 
    106     ASSERT(parameters.userContentWorlds.isEmpty());
     105}
     106
     107UserContentControllerParameters WebUserContentControllerProxy::parameters() const
     108{
     109    UserContentControllerParameters parameters;
     110
    107111    for (const auto& world : m_contentWorlds)
    108112        parameters.userContentWorlds.append(world.key->worldData());
    109113
    110     ASSERT(parameters.userScripts.isEmpty());
    111114    for (auto userScript : m_userScripts->elementsOfType<API::UserScript>())
    112115        parameters.userScripts.append({ userScript->identifier(), userScript->contentWorld().identifier(), userScript->userScript() });
    113116
    114     ASSERT(parameters.userStyleSheets.isEmpty());
    115117    for (auto userStyleSheet : m_userStyleSheets->elementsOfType<API::UserStyleSheet>())
    116118        parameters.userStyleSheets.append({ userStyleSheet->identifier(), userStyleSheet->contentWorld().identifier(), userStyleSheet->userStyleSheet() });
    117119
    118     ASSERT(parameters.messageHandlers.isEmpty());
    119120    for (auto& handler : m_scriptMessageHandlers.values())
    120121        parameters.messageHandlers.append({ handler->identifier(), handler->world().identifier(), handler->name() });
    121122
    122123#if ENABLE(CONTENT_EXTENSIONS)
    123     ASSERT(parameters.contentRuleLists.isEmpty());
    124124    parameters.contentRuleLists = contentRuleListData();
    125125#endif
    126 }
    127 
    128 #if ENABLE(CONTENT_EXTENSIONS)
    129 Vector<std::pair<String, WebCompiledContentRuleListData>> WebUserContentControllerProxy::contentRuleListData()
     126   
     127    return parameters;
     128}
     129
     130#if ENABLE(CONTENT_EXTENSIONS)
     131Vector<std::pair<String, WebCompiledContentRuleListData>> WebUserContentControllerProxy::contentRuleListData() const
    130132{
    131133    Vector<std::pair<String, WebCompiledContentRuleListData>> data;
  • trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h

    r257552 r259307  
    6363class WebCompiledContentRuleListData;
    6464struct WebPageCreationParameters;
     65struct UserContentControllerParameters;
    6566enum class InjectUserScriptImmediately : bool;
    6667
     
    7677    static WebUserContentControllerProxy* get(UserContentControllerIdentifier);
    7778
    78     void addProcess(WebProcessProxy&, WebPageCreationParameters&);
     79    UserContentControllerParameters parameters() const;
     80
     81    void addProcess(WebProcessProxy&);
    7982    void removeProcess(WebProcessProxy&);
    8083
     
    106109    void removeAllContentRuleLists();
    107110    const HashMap<String, RefPtr<API::ContentRuleList>>& contentExtensionRules() { return m_contentRuleLists; }
    108     Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleListData();
     111    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleListData() const;
    109112#endif
    110113
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r259275 r259307  
    31613161}
    31623162
    3163 void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation* navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, API::WebsitePolicies* policies, Ref<PolicyDecisionSender>&& sender)
     3163void WebPageProxy::receivedNavigationPolicyDecision(PolicyAction policyAction, API::Navigation* navigation, ProcessSwapRequestedByClient processSwapRequestedByClient, WebFrameProxy& frame, RefPtr<API::WebsitePolicies>&& policies, Ref<PolicyDecisionSender>&& sender)
    31643164{
    31653165    Ref<WebsiteDataStore> websiteDataStore = m_websiteDataStore.copyRef();
    3166     Optional<WebsitePoliciesData> data;
    31673166    if (policies) {
    3168         data = policies->data();
    31693167        if (policies->websiteDataStore() && policies->websiteDataStore() != websiteDataStore.ptr()) {
    31703168            websiteDataStore = *policies->websiteDataStore();
    31713169            processSwapRequestedByClient = ProcessSwapRequestedByClient::Yes;
    31723170        }
     3171        if (policies->userContentController() && policies->userContentController() != m_userContentController.ptr())
     3172            processSwapRequestedByClient = ProcessSwapRequestedByClient::Yes;
    31733173    }
    31743174
    31753175    if (navigation && !navigation->userContentExtensionsEnabled()) {
    3176         if (!data)
    3177             data = WebsitePoliciesData { };
    3178         data->contentBlockersEnabled = false;
     3176        if (!policies)
     3177            policies = API::WebsitePolicies::create();
     3178        policies->setContentBlockersEnabled(false);
    31793179    }
    31803180
    31813181#if ENABLE(DEVICE_ORIENTATION)
    3182     if (navigation && (!data || data->deviceOrientationAndMotionAccessState == WebCore::DeviceOrientationOrMotionPermissionState::Prompt)) {
     3182    if (navigation && (!policies || policies->deviceOrientationAndMotionAccessState() == WebCore::DeviceOrientationOrMotionPermissionState::Prompt)) {
    31833183        auto deviceOrientationPermission = websiteDataStore->deviceOrientationAndMotionAccessController().cachedDeviceOrientationPermission(SecurityOriginData::fromURL(navigation->currentRequest().url()));
    31843184        if (deviceOrientationPermission != WebCore::DeviceOrientationOrMotionPermissionState::Prompt) {
    3185             if (!data)
    3186                 data = WebsitePoliciesData { };
    3187             data->deviceOrientationAndMotionAccessState = deviceOrientationPermission;
     3185            if (!policies)
     3186                policies = API::WebsitePolicies::create();
     3187            policies->setDeviceOrientationAndMotionAccessState(deviceOrientationPermission);
    31883188        }
    31893189    }
     
    31993199
    32003200    if (policyAction != PolicyAction::Use || !frame.isMainFrame() || !navigation) {
    3201         receivedPolicyDecision(policyAction, navigation, WTFMove(data), WTFMove(sender));
     3201        receivedPolicyDecision(policyAction, navigation, WTFMove(policies), WTFMove(sender));
    32023202        return;
    32033203    }
     
    32133213
    32143214    process().processPool().processForNavigation(*this, *navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, WTFMove(websiteDataStore), [this, protectedThis = makeRef(*this), policyAction, navigation = makeRef(*navigation), sourceProcess = sourceProcess.copyRef(),
    3215         data = WTFMove(data), sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable {
     3215        policies = WTFMove(policies), sender = WTFMove(sender), processSwapRequestedByClient] (Ref<WebProcessProxy>&& processForNavigation, SuspendedPageProxy* destinationSuspendedPage, const String& reason) mutable {
    32163216        // If the navigation has been destroyed, then no need to proceed.
    32173217        if (isClosed() || !navigationState().hasNavigation(navigation->navigationID())) {
    3218             receivedPolicyDecision(policyAction, navigation.ptr(), WTFMove(data), WTFMove(sender));
     3218            receivedPolicyDecision(policyAction, navigation.ptr(), WTFMove(policies), WTFMove(sender));
    32193219            return;
    32203220        }
     
    32383238                suspendedPage = nullptr;
    32393239
    3240             continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, WTFMove(data));
     3240            continueNavigationInNewProcess(navigation, WTFMove(suspendedPage), WTFMove(processForNavigation), processSwapRequestedByClient, std::exchange(policies, nullptr));
    32413241        }
    32423242
    3243         receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? WTF::nullopt : WTFMove(data), WTFMove(sender), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
     3243        receivedPolicyDecision(policyAction, navigation.ptr(), shouldProcessSwap ? nullptr : WTFMove(policies), WTFMove(sender), shouldProcessSwap ? WillContinueLoadInNewProcess::Yes : WillContinueLoadInNewProcess::No);
    32443244    });
    32453245}
    32463246
    3247 void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, Optional<WebsitePoliciesData>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
     3247void WebPageProxy::receivedPolicyDecision(PolicyAction action, API::Navigation* navigation, RefPtr<API::WebsitePolicies>&& websitePolicies, Ref<PolicyDecisionSender>&& sender, WillContinueLoadInNewProcess willContinueLoadInNewProcess)
    32483248{
    32493249    if (!hasRunningProcess()) {
     
    32703270        m_decidePolicyForResponseRequest = { };
    32713271    }
    3272 
    3273     sender->send(PolicyDecision { sender->identifier(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), action, navigation ? navigation->navigationID() : 0, downloadID, WTFMove(websitePolicies) });
     3272   
     3273    Optional<WebsitePoliciesData> websitePoliciesData;
     3274    if (websitePolicies)
     3275        websitePoliciesData = websitePolicies->data();
     3276
     3277    sender->send(PolicyDecision { sender->identifier(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), action, navigation ? navigation->navigationID() : 0, downloadID, WTFMove(websitePoliciesData) });
    32743278}
    32753279
     
    33133317}
    33143318
    3315 void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, Optional<WebsitePoliciesData>&& websitePolicies)
     3319void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, RefPtr<API::WebsitePolicies>&& websitePolicies)
    33163320{
    33173321    RELEASE_LOG_IF_ALLOWED(Loading, "continueNavigationInNewProcess: newProcessPID = %i, hasSuspendedPage = %i", newProcess->processIdentifier(), !!suspendedPage);
     
    33263330    }
    33273331
    3328     m_provisionalPage = makeUnique<ProvisionalPageProxy>(*this, WTFMove(newProcess), WTFMove(suspendedPage), navigation.navigationID(), navigation.currentRequestIsRedirect(), navigation.currentRequest(), processSwapRequestedByClient);
     3332    m_provisionalPage = makeUnique<ProvisionalPageProxy>(*this, WTFMove(newProcess), WTFMove(suspendedPage), navigation.navigationID(), navigation.currentRequestIsRedirect(), navigation.currentRequest(), processSwapRequestedByClient, websitePolicies.get());
    33293333
    33303334    auto continuation = [this, protectedThis = makeRef(*this), navigation = makeRef(navigation), websitePolicies = WTFMove(websitePolicies)]() mutable {
     
    33453349        }
    33463350
     3351        Optional<WebsitePoliciesData> websitePoliciesData;
     3352        if (websitePolicies)
     3353            websitePoliciesData = websitePolicies->data();
     3354
    33473355        // FIXME: Work out timing of responding with the last policy delegate, etc
    33483356        ASSERT(!navigation->currentRequest().isEmpty());
    33493357        if (auto& substituteData = navigation->substituteData())
    3350             m_provisionalPage->loadData(navigation, { substituteData->content.data(), substituteData->content.size() }, substituteData->MIMEType, substituteData->encoding, substituteData->baseURL, substituteData->userData.get(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePolicies));
     3358            m_provisionalPage->loadData(navigation, { substituteData->content.data(), substituteData->content.size() }, substituteData->MIMEType, substituteData->encoding, substituteData->baseURL, substituteData->userData.get(), isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePoliciesData));
    33513359        else
    3352             m_provisionalPage->loadRequest(navigation, ResourceRequest { navigation->currentRequest() }, nullptr, isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePolicies));
     3360            m_provisionalPage->loadRequest(navigation, ResourceRequest { navigation->currentRequest() }, nullptr, isNavigatingToAppBoundDomain(), hasNavigatedAwayFromAppBoundDomain(), WTFMove(websitePoliciesData));
    33533361    };
    33543362    if (m_inspectorController->shouldPauseLoading(*m_provisionalPage))
     
    50975105#if ENABLE(CONTENT_FILTERING)
    50985106    if (frame.didHandleContentFilterUnblockNavigation(request))
    5099         return receivedPolicyDecision(PolicyAction::Ignore, m_navigationState->navigation(navigationID), WTF::nullopt, WTFMove(sender));
     5107        return receivedPolicyDecision(PolicyAction::Ignore, m_navigationState->navigation(navigationID), nullptr, WTFMove(sender));
    51005108#endif
    51015109
     
    51235131                    navigation->setEffectiveContentMode(effectiveContentModeAfterAdjustingPolicies(*policies, navigation->currentRequest()));
    51245132            }
    5125             receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, policies.get(), WTFMove(sender));
     5133            receivedNavigationPolicyDecision(policyAction, navigation.get(), processSwapRequestedByClient, frame, WTFMove(policies), WTFMove(sender));
    51265134        };
    51275135
     
    53055313        });
    53065314
    5307         receivedPolicyDecision(policyAction, nullptr, WTF::nullopt, WTFMove(sender));
     5315        receivedPolicyDecision(policyAction, nullptr, nullptr, WTFMove(sender));
    53085316    }, ShouldExpectSafeBrowsingResult::No, ShouldExpectAppBoundDomainResult::No));
    53095317
     
    53535361        });
    53545362       
    5355         receivedPolicyDecision(policyAction, navigation.get(), WTF::nullopt, WTFMove(sender));
     5363        receivedPolicyDecision(policyAction, navigation.get(), nullptr, WTFMove(sender));
    53565364    }, ShouldExpectSafeBrowsingResult::No, ShouldExpectAppBoundDomainResult::No));
    53575365    if (m_policyClient)
     
    76497657}
    76507658
    7651 WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& process, DrawingAreaProxy& drawingArea)
     7659WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& process, DrawingAreaProxy& drawingArea, RefPtr<API::WebsitePolicies>&& websitePolicies)
    76527660{
    76537661    WebPageCreationParameters parameters;
     
    77787786    parameters.hasResourceLoadClient = !!m_resourceLoadClient;
    77797787
    7780     process.addWebUserContentControllerProxy(m_userContentController, parameters);
     7788    std::reference_wrapper<WebUserContentControllerProxy> userContentController(m_userContentController.get());
     7789    if (auto* userContentControllerFromWebsitePolicies = websitePolicies ? websitePolicies->userContentController() : nullptr)
     7790        userContentController = *userContentControllerFromWebsitePolicies;
     7791    process.addWebUserContentControllerProxy(userContentController);
     7792    parameters.userContentControllerParameters = userContentController.get().parameters();
    77817793
    77827794    parameters.shouldCaptureAudioInUIProcess = preferences().captureAudioInUIProcessEnabled();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r259242 r259307  
    11241124    class PolicyDecisionSender;
    11251125    enum class WillContinueLoadInNewProcess : bool { No, Yes };
    1126     void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, Optional<WebsitePoliciesData>&&, Ref<PolicyDecisionSender>&&, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);
    1127     void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, ProcessSwapRequestedByClient, WebFrameProxy&, API::WebsitePolicies*, Ref<PolicyDecisionSender>&&);
     1126    void receivedPolicyDecision(WebCore::PolicyAction, API::Navigation*, RefPtr<API::WebsitePolicies>&&, Ref<PolicyDecisionSender>&&, WillContinueLoadInNewProcess = WillContinueLoadInNewProcess::No);
     1127    void receivedNavigationPolicyDecision(WebCore::PolicyAction, API::Navigation*, ProcessSwapRequestedByClient, WebFrameProxy&, RefPtr<API::WebsitePolicies>&&, Ref<PolicyDecisionSender>&&);
    11281128
    11291129    void backForwardRemovedItem(const WebCore::BackForwardItemIdentifier&);
     
    12311231    void didCancelForOpenPanel();
    12321232
    1233     WebPageCreationParameters creationParameters(WebProcessProxy&, DrawingAreaProxy&);
     1233    WebPageCreationParameters creationParameters(WebProcessProxy&, DrawingAreaProxy&, RefPtr<API::WebsitePolicies>&& = nullptr);
    12341234
    12351235    void handleDownloadRequest(DownloadProxy&);
     
    22312231    void reportPageLoadResult(const WebCore::ResourceError& = { });
    22322232
    2233     void continueNavigationInNewProcess(API::Navigation&, std::unique_ptr<SuspendedPageProxy>&&, Ref<WebProcessProxy>&&, ProcessSwapRequestedByClient, Optional<WebsitePoliciesData>&&);
     2233    void continueNavigationInNewProcess(API::Navigation&, std::unique_ptr<SuspendedPageProxy>&&, Ref<WebProcessProxy>&&, ProcessSwapRequestedByClient, RefPtr<API::WebsitePolicies>&&);
    22342234
    22352235    void setNeedsFontAttributes(bool);
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r259200 r259307  
    543543}
    544544
    545 void WebProcessProxy::addWebUserContentControllerProxy(WebUserContentControllerProxy& proxy, WebPageCreationParameters& parameters)
     545void WebProcessProxy::addWebUserContentControllerProxy(WebUserContentControllerProxy& proxy)
    546546{
    547547    m_webUserContentControllerProxies.add(&proxy);
    548     proxy.addProcess(*this, parameters);
     548    proxy.addProcess(*this);
    549549}
    550550
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r259200 r259307  
    179179    void removeVisitedLinkStoreUser(VisitedLinkStore&, WebPageProxyIdentifier);
    180180
    181     void addWebUserContentControllerProxy(WebUserContentControllerProxy&, WebPageCreationParameters&);
     181    void addWebUserContentControllerProxy(WebUserContentControllerProxy&);
    182182    void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&);
    183183
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r259200 r259307  
    40354035                5C8DD37F1FE4519200F2A556 /* WebsiteAutoplayPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteAutoplayPolicy.h; sourceTree = "<group>"; };
    40364036                5C8DD3811FE455CA00F2A556 /* WebsiteAutoplayQuirk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebsiteAutoplayQuirk.h; sourceTree = "<group>"; };
     4037                5C9C5C022430535800BB6740 /* UserContentControllerParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentControllerParameters.h; sourceTree = "<group>"; };
     4038                5C9C5C032430535800BB6740 /* UserContentControllerParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentControllerParameters.cpp; sourceTree = "<group>"; };
    40374039                5C9E56801DF7F05500C9EE33 /* WKWebsitePolicies.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKWebsitePolicies.cpp; sourceTree = "<group>"; };
    40384040                5C9E56811DF7F05500C9EE33 /* WKWebsitePolicies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsitePolicies.h; sourceTree = "<group>"; };
     
    60456047                                5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */,
    60466048                                41FBE821206D87F6000F0741 /* UserContentControllerIdentifier.h */,
     6049                                5C9C5C032430535800BB6740 /* UserContentControllerParameters.cpp */,
     6050                                5C9C5C022430535800BB6740 /* UserContentControllerParameters.h */,
    60476051                                1AC1336518565B5700F3EC05 /* UserData.cpp */,
    60486052                                1AC1336618565B5700F3EC05 /* UserData.h */,
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r259209 r259307  
    719719        registerURLSchemeHandler(iterator.value, iterator.key);
    720720
    721     m_userContentController->addContentWorlds(parameters.userContentWorlds);
    722     m_userContentController->addUserScripts(WTFMove(parameters.userScripts), InjectUserScriptImmediately::No);
    723     m_userContentController->addUserStyleSheets(parameters.userStyleSheets);
    724     m_userContentController->addUserScriptMessageHandlers(parameters.messageHandlers);
     721    m_userContentController->addContentWorlds(parameters.userContentControllerParameters.userContentWorlds);
     722    m_userContentController->addUserScripts(WTFMove(parameters.userContentControllerParameters.userScripts), InjectUserScriptImmediately::No);
     723    m_userContentController->addUserStyleSheets(parameters.userContentControllerParameters.userStyleSheets);
     724    m_userContentController->addUserScriptMessageHandlers(parameters.userContentControllerParameters.messageHandlers);
    725725#if ENABLE(CONTENT_EXTENSIONS)
    726     m_userContentController->addContentRuleLists(WTFMove(parameters.contentRuleLists));
     726    m_userContentController->addContentRuleLists(WTFMove(parameters.userContentControllerParameters.contentRuleLists));
    727727#endif
    728728
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r259236 r259307  
    792792#endif
    793793
    794     LOG_ERROR("Unhandled web process message '%s:%s' (destination: %" PRIu64 ")", decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data(), decoder.destinationID());
     794    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()));
    795795}
    796796
  • trunk/Tools/ChangeLog

    r259295 r259307  
     12020-03-31  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add SPI WKWebpagePreferences._userContentController
     4        https://bugs.webkit.org/show_bug.cgi?id=209795
     5
     6        Reviewed by Tim Hatcher.
     7
     8        * TestWebKitAPI/SourcesCocoa.txt:
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm:
     11        (-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): Deleted.
     12        * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
     13        * TestWebKitAPI/cocoa/TestUIDelegate.h: Added.
     14        * TestWebKitAPI/cocoa/TestUIDelegate.mm: Added.
     15        (-[TestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
     16        (-[TestUIDelegate waitForAlert]):
     17
    1182020-03-31  Aakash Jain  <aakash_jain@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/SourcesCocoa.txt

    r252023 r259307  
    2929cocoa/TestNavigationDelegate.mm
    3030cocoa/TestProtocol.mm
     31cocoa/TestUIDelegate.mm
    3132cocoa/TestWKWebView.mm
    3233
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r259200 r259307  
    20852085                5CB5B3BD1FFC517E00C27BB0 /* FrameHandleSerialization.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FrameHandleSerialization.mm; sourceTree = "<group>"; };
    20862086                5CB7AFDB23C451E400E49CF3 /* ResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceLoadDelegate.mm; sourceTree = "<group>"; };
     2087                5CBAA7F324327F6B00564A8B /* TestUIDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestUIDelegate.h; path = cocoa/TestUIDelegate.h; sourceTree = "<group>"; };
     2088                5CBAA7F424327F6B00564A8B /* TestUIDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestUIDelegate.mm; path = cocoa/TestUIDelegate.mm; sourceTree = "<group>"; };
    20872089                5CCB10DD2134579C00AC5AF0 /* ResponsivenessTimerDoesntFireEarly.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimerDoesntFireEarly.mm; sourceTree = "<group>"; };
    20882090                5CCB10DE2134579D00AC5AF0 /* RestoreSessionStateWithoutNavigation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RestoreSessionStateWithoutNavigation.mm; sourceTree = "<group>"; };
     
    29022904                                A14FC58D1B8AE36500D107EB /* TestProtocol.h */,
    29032905                                A14FC58E1B8AE36500D107EB /* TestProtocol.mm */,
     2906                                5CBAA7F324327F6B00564A8B /* TestUIDelegate.h */,
     2907                                5CBAA7F424327F6B00564A8B /* TestUIDelegate.mm */,
    29042908                                2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */,
    29052909                                2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadDelegate.mm

    r258017 r259307  
    3030#import "TCPServer.h"
    3131#import "TestNavigationDelegate.h"
     32#import "TestUIDelegate.h"
    3233#import "TestWKWebView.h"
    3334#import <WebKit/WKWebViewPrivate.h>
     
    7879    if (_didCompleteWithError)
    7980        _didCompleteWithError(webView, resourceLoad, error, response);
    80 }
    81 
    82 @end
    83 
    84 @interface TestUIDelegate : NSObject <WKUIDelegate>
    85 
    86 @property (nonatomic, copy) void (^runJavaScriptAlertPanelWithMessage)(WKWebView *, NSString *, WKFrameInfo *, void (^)(void));
    87 
    88 @end
    89 
    90 @implementation TestUIDelegate
    91 
    92 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
    93 {
    94     if (_runJavaScriptAlertPanelWithMessage)
    95         _runJavaScriptAlertPanelWithMessage(webView, message, frame, completionHandler);
    96     else
    97         completionHandler();
    9881}
    9982
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm

    r258457 r259307  
    2828#import "PlatformUtilities.h"
    2929#import "TestNavigationDelegate.h"
     30#import "TestUIDelegate.h"
    3031#import "TestWKWebView.h"
    3132#import <WebKit/WKMutableDictionary.h>
     
    17241725    EXPECT_NE(pid1, [cookieWebView _webProcessIdentifier]);
    17251726}
     1727
     1728TEST(WebpagePreferences, WebsitePoliciesUserContentController)
     1729{
     1730    auto makeScript = [] (NSString *script) {
     1731        return [[[WKUserScript alloc] initWithSource:script injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES] autorelease];
     1732    };
     1733    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration new] autorelease];
     1734    [configuration.userContentController addUserScript:makeScript(@"alert('testAlert1')")];
     1735    TestWKWebView *webView = [[[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration] autorelease];
     1736    TestUIDelegate *uiDelegate = [[TestUIDelegate new] autorelease];
     1737    webView.UIDelegate = uiDelegate;
     1738    TestNavigationDelegate *navigationDelegate = [[TestNavigationDelegate new] autorelease];
     1739    __block bool iframeExceptionThrown = false;
     1740    __block RetainPtr<WKUserContentController> replacementUserContentController;
     1741    navigationDelegate.decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *action, WKWebpagePreferences *, void (^completionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
     1742        if ([action.request.URL.path hasSuffix:@"/simple-iframe.html"])
     1743            return completionHandler(WKNavigationActionPolicyAllow, nil);
     1744        if ([action.request.URL.path hasSuffix:@"/simple.html"]) {
     1745            @try {
     1746                WKWebpagePreferences *preferences = [[WKWebpagePreferences new] autorelease];
     1747                preferences._userContentController = [[WKUserContentController new] autorelease];
     1748                return completionHandler(WKNavigationActionPolicyAllow, preferences);
     1749            } @catch (NSException *exception) {
     1750                iframeExceptionThrown = true;
     1751            }
     1752            return;
     1753        }
     1754       
     1755        EXPECT_TRUE([action.request.URL.path hasSuffix:@"/simple2.html"]);
     1756        WKWebpagePreferences *preferences = [[WKWebpagePreferences new] autorelease];
     1757        replacementUserContentController = adoptNS([WKUserContentController new]);
     1758        [replacementUserContentController addUserScript:makeScript(@"alert('testAlert2')")];
     1759        preferences._userContentController = replacementUserContentController.get();
     1760        completionHandler(WKNavigationActionPolicyAllow, preferences);
     1761    };
     1762    webView.navigationDelegate = navigationDelegate;
     1763
     1764    [webView loadTestPageNamed:@"simple-iframe"];
     1765    EXPECT_WK_STREQ([uiDelegate waitForAlert], "testAlert1");
     1766    TestWebKitAPI::Util::run(&iframeExceptionThrown);
     1767
     1768    [webView loadTestPageNamed:@"simple2"];
     1769    EXPECT_WK_STREQ([uiDelegate waitForAlert], "testAlert2");
     1770
     1771    bool caughtException = false;
     1772    @try {
     1773        WKWebpagePreferences *preferences = [[WKWebpagePreferences new] autorelease];
     1774        preferences._userContentController = [[WKUserContentController new] autorelease];
     1775        [webView _updateWebpagePreferences:preferences];
     1776    } @catch (NSException *exception) {
     1777        caughtException = true;
     1778    }
     1779    EXPECT_TRUE(caughtException);
     1780
     1781    // FIXME: Make _addUserScriptImmediately work successfully after using WKWebpagePreferences._userContentController
     1782}
Note: See TracChangeset for help on using the changeset viewer.