Changeset 230210 in webkit


Ignore:
Timestamp:
Apr 3, 2018 10:58:48 AM (6 years ago)
Author:
youenn@apple.com
Message:

Make NetworkProcess get ContentBlocker information from UIProcess
https://bugs.webkit.org/show_bug.cgi?id=184205

Reviewed by Alex Christensen.

Make NetworkProcess get content blockers from UIProcess directly.
Before that patch, WebProcess sent content blockers to NetworkProcess for each PingLoad.
Instead, WebProcess sends the content blocker identifier for each PingLoad and NetworkProcess fetches the content blocker once.

This is both more efficient than passing them for each PingLoad and safer in the sense
that a compromised WebProcess will not be able to bypass any of these.
In the future, NetworkProcess should get the content blocker identifier directly from the WebPageID attached to the request.

Covered by existing beacon+content blocker tests.

Did some refactoring to add a typed content blocker identifier.
Once NetworkProcess fetches a given content blocker, the content blocker will send any modification to NetworkProcess.
Introduced NetworkContentRuleListManager to handle the content blockers in NetworkProcess.

  • CMakeLists.txt:
  • DerivedSources.make:
  • NetworkProcess/NetworkLoadChecker.cpp:

(WebKit::NetworkLoadChecker::checkRequest):
(WebKit::NetworkLoadChecker::continueCheckingRequest):
(WebKit::NetworkLoadChecker::processContentExtensionRulesForLoad):

  • NetworkProcess/NetworkLoadChecker.h:

(WebKit::NetworkLoadChecker::setContentExtensionController):

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::didReceiveMessage):

  • NetworkProcess/NetworkProcess.h:

(WebKit::NetworkProcess::networkUserContentController):

  • NetworkProcess/NetworkResourceLoadParameters.cpp:

(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):

  • NetworkProcess/NetworkResourceLoadParameters.h:
  • NetworkProcess/NetworkContentRuleListManager.cpp: Added.

(WebKit::NetworkContentRuleListManager::contentExtensionsBackend):
(WebKit::NetworkContentRuleListManager::addContentRuleLists):
(WebKit::NetworkContentRuleListManager::removeContentRuleList):
(WebKit::NetworkContentRuleListManager::removeAllContentRuleLists):
(WebKit::NetworkContentRuleListManager::remove):

  • NetworkProcess/NetworkContentRuleListManager.h: Added.
  • NetworkProcess/NetworkContentRuleListManager.messages.in: Added.
  • NetworkProcess/PingLoad.cpp:
  • Scripts/webkit/messages.py:
  • Shared/UserContentControllerIdentifier.h: Added.
  • Shared/WebPageCreationParameters.cpp:

(WebKit::WebPageCreationParameters::decode):

  • Shared/WebPageCreationParameters.h:
  • Shared/WebPageGroupData.cpp:

(WebKit::WebPageGroupData::decode):

  • Shared/WebPageGroupData.h:
  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::~NetworkProcessProxy):
(WebKit::NetworkProcessProxy::contentExtensionRules):
(WebKit::NetworkProcessProxy::didDestroyWebUserContentControllerProxy):

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/Network/NetworkProcessProxy.messages.in:
  • UIProcess/UserContent/WebUserContentControllerProxy.cpp:

(WebKit::WebUserContentControllerProxy::get):
(WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy):
(WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy):
(WebKit::WebUserContentControllerProxy::addProcess):
(WebKit::WebUserContentControllerProxy::removeProcess):
(WebKit::WebUserContentControllerProxy::addUserContentWorldUse):
(WebKit::WebUserContentControllerProxy::removeUserContentWorldUses):
(WebKit::WebUserContentControllerProxy::addUserScript):
(WebKit::WebUserContentControllerProxy::removeUserScript):
(WebKit::WebUserContentControllerProxy::removeAllUserScripts):
(WebKit::WebUserContentControllerProxy::addUserStyleSheet):
(WebKit::WebUserContentControllerProxy::removeUserStyleSheet):
(WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets):
(WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler):
(WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName):
(WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers):
(WebKit::WebUserContentControllerProxy::addContentRuleList):
(WebKit::WebUserContentControllerProxy::removeContentRuleList):
(WebKit::WebUserContentControllerProxy::removeAllContentRuleLists):

  • UIProcess/UserContent/WebUserContentControllerProxy.h:

(WebKit::WebUserContentControllerProxy::create):
(WebKit::WebUserContentControllerProxy::addNetworkProcess):
(WebKit::WebUserContentControllerProxy::removeNetworkProcess):
(WebKit::WebUserContentControllerProxy::contentExtensionRules):
(WebKit::WebUserContentControllerProxy::identifier const):

  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Network/WebLoaderStrategy.cpp:

(WebKit::WebLoaderStrategy::startPingLoad):

  • WebProcess/UserContent/WebUserContentController.cpp:

(WebKit::WebUserContentController::getOrCreate):
(WebKit::WebUserContentController::WebUserContentController):
(WebKit::WebUserContentController::~WebUserContentController):

  • WebProcess/UserContent/WebUserContentController.h:
  • WebProcess/WebPage/WebPage.h:

(WebKit::WebPage::userContentControllerIdentifier const):

Location:
trunk/Source/WebKit
Files:
2 added
26 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/CMakeLists.txt

    r230152 r230210  
    108108    NetworkProcess/NetworkCORSPreflightChecker.cpp
    109109    NetworkProcess/NetworkConnectionToWebProcess.cpp
     110    NetworkProcess/NetworkContentRuleListManager.cpp
    110111    NetworkProcess/NetworkDataTask.cpp
    111112    NetworkProcess/NetworkDataTaskBlob.cpp
     
    620621
    621622    NetworkProcess/NetworkConnectionToWebProcess.messages.in
     623    NetworkProcess/NetworkContentRuleListManager.messages.in
    622624    NetworkProcess/NetworkProcess.messages.in
    623625    NetworkProcess/NetworkResourceLoader.messages.in
  • trunk/Source/WebKit/ChangeLog

    r230204 r230210  
     12018-04-03  Youenn Fablet  <youenn@apple.com>
     2
     3        Make NetworkProcess get ContentBlocker information from UIProcess
     4        https://bugs.webkit.org/show_bug.cgi?id=184205
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make NetworkProcess get content blockers from UIProcess directly.
     9        Before that patch, WebProcess sent content blockers to NetworkProcess for each PingLoad.
     10        Instead, WebProcess sends the content blocker identifier for each PingLoad and NetworkProcess fetches the content blocker once.
     11
     12        This is both more efficient than passing them for each PingLoad and safer in the sense
     13        that a compromised WebProcess will not be able to bypass any of these.
     14        In the future, NetworkProcess should get the content blocker identifier directly from the WebPageID attached to the request.
     15
     16        Covered by existing beacon+content blocker tests.
     17
     18        Did some refactoring to add a typed content blocker identifier.
     19        Once NetworkProcess fetches a given content blocker, the content blocker will send any modification to NetworkProcess.
     20        Introduced NetworkContentRuleListManager to handle the content blockers in NetworkProcess.
     21
     22        * CMakeLists.txt:
     23        * DerivedSources.make:
     24        * NetworkProcess/NetworkLoadChecker.cpp:
     25        (WebKit::NetworkLoadChecker::checkRequest):
     26        (WebKit::NetworkLoadChecker::continueCheckingRequest):
     27        (WebKit::NetworkLoadChecker::processContentExtensionRulesForLoad):
     28        * NetworkProcess/NetworkLoadChecker.h:
     29        (WebKit::NetworkLoadChecker::setContentExtensionController):
     30        * NetworkProcess/NetworkProcess.cpp:
     31        (WebKit::NetworkProcess::didReceiveMessage):
     32        * NetworkProcess/NetworkProcess.h:
     33        (WebKit::NetworkProcess::networkUserContentController):
     34        * NetworkProcess/NetworkResourceLoadParameters.cpp:
     35        (WebKit::NetworkResourceLoadParameters::encode const):
     36        (WebKit::NetworkResourceLoadParameters::decode):
     37        * NetworkProcess/NetworkResourceLoadParameters.h:
     38        * NetworkProcess/NetworkContentRuleListManager.cpp: Added.
     39        (WebKit::NetworkContentRuleListManager::contentExtensionsBackend):
     40        (WebKit::NetworkContentRuleListManager::addContentRuleLists):
     41        (WebKit::NetworkContentRuleListManager::removeContentRuleList):
     42        (WebKit::NetworkContentRuleListManager::removeAllContentRuleLists):
     43        (WebKit::NetworkContentRuleListManager::remove):
     44        * NetworkProcess/NetworkContentRuleListManager.h: Added.
     45        * NetworkProcess/NetworkContentRuleListManager.messages.in: Added.
     46        * NetworkProcess/PingLoad.cpp:
     47        * Scripts/webkit/messages.py:
     48        * Shared/UserContentControllerIdentifier.h: Added.
     49        * Shared/WebPageCreationParameters.cpp:
     50        (WebKit::WebPageCreationParameters::decode):
     51        * Shared/WebPageCreationParameters.h:
     52        * Shared/WebPageGroupData.cpp:
     53        (WebKit::WebPageGroupData::decode):
     54        * Shared/WebPageGroupData.h:
     55        * UIProcess/Network/NetworkProcessProxy.cpp:
     56        (WebKit::NetworkProcessProxy::~NetworkProcessProxy):
     57        (WebKit::NetworkProcessProxy::contentExtensionRules):
     58        (WebKit::NetworkProcessProxy::didDestroyWebUserContentControllerProxy):
     59        * UIProcess/Network/NetworkProcessProxy.h:
     60        * UIProcess/Network/NetworkProcessProxy.messages.in:
     61        * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
     62        (WebKit::WebUserContentControllerProxy::get):
     63        (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy):
     64        (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy):
     65        (WebKit::WebUserContentControllerProxy::addProcess):
     66        (WebKit::WebUserContentControllerProxy::removeProcess):
     67        (WebKit::WebUserContentControllerProxy::addUserContentWorldUse):
     68        (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses):
     69        (WebKit::WebUserContentControllerProxy::addUserScript):
     70        (WebKit::WebUserContentControllerProxy::removeUserScript):
     71        (WebKit::WebUserContentControllerProxy::removeAllUserScripts):
     72        (WebKit::WebUserContentControllerProxy::addUserStyleSheet):
     73        (WebKit::WebUserContentControllerProxy::removeUserStyleSheet):
     74        (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets):
     75        (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler):
     76        (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName):
     77        (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers):
     78        (WebKit::WebUserContentControllerProxy::addContentRuleList):
     79        (WebKit::WebUserContentControllerProxy::removeContentRuleList):
     80        (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists):
     81        * UIProcess/UserContent/WebUserContentControllerProxy.h:
     82        (WebKit::WebUserContentControllerProxy::create):
     83        (WebKit::WebUserContentControllerProxy::addNetworkProcess):
     84        (WebKit::WebUserContentControllerProxy::removeNetworkProcess):
     85        (WebKit::WebUserContentControllerProxy::contentExtensionRules):
     86        (WebKit::WebUserContentControllerProxy::identifier const):
     87        * WebKit.xcodeproj/project.pbxproj:
     88        * WebProcess/Network/WebLoaderStrategy.cpp:
     89        (WebKit::WebLoaderStrategy::startPingLoad):
     90        * WebProcess/UserContent/WebUserContentController.cpp:
     91        (WebKit::WebUserContentController::getOrCreate):
     92        (WebKit::WebUserContentController::WebUserContentController):
     93        (WebKit::WebUserContentController::~WebUserContentController):
     94        * WebProcess/UserContent/WebUserContentController.h:
     95        * WebProcess/WebPage/WebPage.h:
     96        (WebKit::WebPage::userContentControllerIdentifier const):
     97
    1982018-04-02  Beth Dakin  <bdakin@apple.com>
    299
  • trunk/Source/WebKit/DerivedSources.make

    r229426 r230210  
    116116    NetworkResourceLoader \
    117117    NetworkSocketStream \
     118    NetworkContentRuleListManager \
    118119    PluginControllerProxy \
    119120    PluginProcess \
  • trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h

    r230208 r230210  
    11/*
    2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "NetworkLoadParameters.h"
    29 #include "SandboxExtension.h"
     28#if ENABLE(CONTENT_EXTENSIONS)
     29
     30#include "UserContentControllerIdentifier.h"
    3031#include "WebCompiledContentRuleListData.h"
    31 #include <WebCore/ContentSecurityPolicyResponseHeaders.h>
    32 #include <WebCore/FetchOptions.h>
    33 #include <WebCore/ResourceLoaderOptions.h>
    34 #include <WebCore/ResourceRequest.h>
    35 #include <WebCore/SecurityOrigin.h>
    36 #include <pal/SessionID.h>
    37 #include <wtf/Seconds.h>
     32#include <WebCore/ContentExtensionsBackend.h>
     33#include <WebCore/UserContentProvider.h>
    3834
    3935namespace IPC {
     36class Connection;
    4037class Decoder;
    41 class Encoder;
    4238}
    4339
    4440namespace WebKit {
    4541
    46 typedef uint64_t ResourceLoadIdentifier;
     42class NetworkContentRuleListManager {
     43public:
     44    NetworkContentRuleListManager();
     45    ~NetworkContentRuleListManager();
    4746
    48 class NetworkResourceLoadParameters : public NetworkLoadParameters {
    49 public:
    50     void encode(IPC::Encoder&) const;
    51     static bool decode(IPC::Decoder&, NetworkResourceLoadParameters&);
     47    void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
    5248
    53     ResourceLoadIdentifier identifier { 0 };
    54     Vector<RefPtr<SandboxExtension>> requestBodySandboxExtensions; // Created automatically for the sender.
    55     RefPtr<SandboxExtension> resourceSandboxExtension; // Created automatically for the sender.
    56     Seconds maximumBufferingTime;
    57     Vector<String> derivedCachedDataTypesToRetrieve;
    58     RefPtr<WebCore::SecurityOrigin> sourceOrigin;
    59     WebCore::FetchOptions::Mode mode;
    60     std::optional<WebCore::ContentSecurityPolicyResponseHeaders> cspResponseHeaders;
     49    using BackendCallback = CompletionHandler<void(WebCore::ContentExtensions::ContentExtensionsBackend&)>;
     50    void contentExtensionsBackend(UserContentControllerIdentifier, BackendCallback&&);
    6151
    62 #if ENABLE(CONTENT_EXTENSIONS)
    63     WebCore::URL mainDocumentURL;
    64     Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
    65 #endif
     52private:
     53    void addContentRuleLists(UserContentControllerIdentifier, const Vector<std::pair<String, WebCompiledContentRuleListData>>&);
     54    void removeContentRuleList(UserContentControllerIdentifier, const String& name);
     55    void removeAllContentRuleLists(UserContentControllerIdentifier);
     56    void remove(UserContentControllerIdentifier);
     57
     58    HashMap<UserContentControllerIdentifier, std::unique_ptr<WebCore::ContentExtensions::ContentExtensionsBackend>> m_contentExtensionBackends;
     59    HashMap<UserContentControllerIdentifier, Vector<BackendCallback>> m_pendingCallbacks;
    6660};
    6761
    6862} // namespace WebKit
     63
     64#endif // ENABLE(CONTENT_EXTENSIONS)
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp

    r230118 r230210  
    2929#include "Logging.h"
    3030#include "NetworkCORSPreflightChecker.h"
     31#include "NetworkProcess.h"
    3132#include "WebCompiledContentRuleList.h"
     33#include "WebUserContentController.h"
    3234#include <WebCore/ContentSecurityPolicy.h>
    3335#include <WebCore/CrossOriginAccessControl.h>
     
    9698{
    9799#if ENABLE(CONTENT_EXTENSIONS)
    98     if (processContentExtensionRulesForLoad(request).blockedLoad) {
    99         handler(returnError(ASCIILiteral("Blocked by content extension")));
    100         return;
    101     }
     100    processContentExtensionRulesForLoad(WTFMove(request), [this, handler = WTFMove(handler)](auto&& request, auto status) mutable {
     101        if (status.blockedLoad) {
     102            handler(this->returnError(ASCIILiteral("Blocked by content extension")));
     103            return;
     104        }
     105        this->continueCheckingRequest(WTFMove(request), WTFMove(handler));
     106    });
     107#else
     108    continueCheckingRequest(WTFMove(request), WTFMove(handler));
    102109#endif
    103 
     110}
     111
     112void NetworkLoadChecker::continueCheckingRequest(ResourceRequest&& request, ValidationHandler&& handler)
     113{
    104114    if (auto* contentSecurityPolicy = this->contentSecurityPolicy()) {
    105115        if (isRedirected()) {
     
    230240
    231241#if ENABLE(CONTENT_EXTENSIONS)
    232 ContentExtensions::ContentExtensionsBackend& NetworkLoadChecker::contentExtensionsBackend()
    233 {
    234     if (!m_contentExtensionsBackend) {
    235         m_contentExtensionsBackend = std::make_unique<ContentExtensions::ContentExtensionsBackend>();
    236         for (auto& pair : m_contentRuleLists)
    237             m_contentExtensionsBackend->addContentExtension(pair.first, WebCompiledContentRuleList::create(WTFMove(pair.second)));
    238     }
    239     return *m_contentExtensionsBackend;
    240 }
    241 
    242 ContentExtensions::BlockedStatus NetworkLoadChecker::processContentExtensionRulesForLoad(ResourceRequest& request)
    243 {
    244     auto status = contentExtensionsBackend().processContentExtensionRulesForPingLoad(request.url(), m_mainDocumentURL);
    245     applyBlockedStatusToRequest(status, nullptr, request);
    246     return status;
     242void NetworkLoadChecker::processContentExtensionRulesForLoad(ResourceRequest&& request, CompletionHandler<void(WebCore::ResourceRequest&&, const ContentExtensions::BlockedStatus&)>&& callback)
     243{
     244    if (!m_userContentControllerIdentifier) {
     245        ContentExtensions::BlockedStatus status;
     246        callback(WTFMove(request), status);
     247        return;
     248    }
     249    NetworkProcess::singleton().networkContentRuleListManager().contentExtensionsBackend(*m_userContentControllerIdentifier, [protectedThis = makeRef(*this), this, request = WTFMove(request), callback = WTFMove(callback)](auto& backend) mutable {
     250        auto status = backend.processContentExtensionRulesForPingLoad(request.url(), m_mainDocumentURL);
     251        applyBlockedStatusToRequest(status, nullptr, request);
     252        callback(WTFMove(request), status);
     253    });
    247254}
    248255#endif // ENABLE(CONTENT_EXTENSIONS)
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h

    r230014 r230210  
    2626#pragma once
    2727
     28#include "NetworkContentRuleListManager.h"
    2829#include "NetworkResourceLoadParameters.h"
    29 #include <WebCore/ContentExtensionsBackend.h>
    3030#include <WebCore/ResourceError.h>
    3131#include <WebCore/ResourceResponse.h>
     
    4141class NetworkCORSPreflightChecker;
    4242
    43 class NetworkLoadChecker {
     43class NetworkLoadChecker : public RefCounted<NetworkLoadChecker> {
    4444public:
    45     NetworkLoadChecker(WebCore::FetchOptions::Mode, bool shouldFollowRedirects, WebCore::StoredCredentialsPolicy, PAL::SessionID, WebCore::HTTPHeaderMap&&, WebCore::URL&&, RefPtr<WebCore::SecurityOrigin>&&);
     45    static Ref<NetworkLoadChecker> create(WebCore::FetchOptions::Mode mode, bool shouldFollowRedirects, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, PAL::SessionID sessionID, WebCore::HTTPHeaderMap&& originalHeaders, WebCore::URL&& url, RefPtr<WebCore::SecurityOrigin>&& sourceOrigin)
     46    {
     47        return adoptRef(*new NetworkLoadChecker { mode, shouldFollowRedirects, storedCredentialsPolicy, sessionID, WTFMove(originalHeaders), WTFMove(url), WTFMove(sourceOrigin) });
     48    }
    4649    ~NetworkLoadChecker();
    4750
     
    5356    void setCSPResponseHeaders(WebCore::ContentSecurityPolicyResponseHeaders&& headers) { m_cspResponseHeaders = WTFMove(headers); }
    5457#if ENABLE(CONTENT_EXTENSIONS)
    55     void setContentExtensionRuleLists(WebCore::URL&& mainDocumentURL, Vector<std::pair<String, WebCompiledContentRuleListData>>&& contentRuleLists)
     58    void setContentExtensionController(WebCore::URL&& mainDocumentURL, std::optional<UserContentControllerIdentifier> identifier)
    5659    {
    5760        m_mainDocumentURL = WTFMove(mainDocumentURL);
    58         m_contentRuleLists = WTFMove(contentRuleLists);
     61        m_userContentControllerIdentifier = identifier;
    5962    }
    6063#endif
     
    6467
    6568private:
     69    NetworkLoadChecker(WebCore::FetchOptions::Mode, bool shouldFollowRedirects, WebCore::StoredCredentialsPolicy, PAL::SessionID, WebCore::HTTPHeaderMap&&, WebCore::URL&&, RefPtr<WebCore::SecurityOrigin>&&);
     70
    6671    WebCore::ContentSecurityPolicy* contentSecurityPolicy() const;
    6772    bool isChecking() const { return !!m_corsPreflightChecker; }
     
    6974
    7075    void checkRequest(WebCore::ResourceRequest&&, ValidationHandler&&);
     76
     77    void continueCheckingRequest(WebCore::ResourceRequest&&, ValidationHandler&&);
    7178
    7279    bool doesNotNeedCORSCheck(const WebCore::URL&) const;
     
    7885
    7986#if ENABLE(CONTENT_EXTENSIONS)
    80     WebCore::ContentExtensions::ContentExtensionsBackend& contentExtensionsBackend();
    81     WebCore::ContentExtensions::BlockedStatus processContentExtensionRulesForLoad(WebCore::ResourceRequest&);
     87    void processContentExtensionRulesForLoad(WebCore::ResourceRequest&&, CompletionHandler<void(WebCore::ResourceRequest&&, const WebCore::ContentExtensions::BlockedStatus&)>&&);
    8288#endif
    8389
     
    9399#if ENABLE(CONTENT_EXTENSIONS)
    94100    WebCore::URL m_mainDocumentURL;
    95     Vector<std::pair<String, WebCompiledContentRuleListData>> m_contentRuleLists;
     101    std::optional<UserContentControllerIdentifier> m_userContentControllerIdentifier;
    96102#endif
    97103
     
    100106    bool m_isSimpleRequest { true };
    101107    mutable std::unique_ptr<WebCore::ContentSecurityPolicy> m_contentSecurityPolicy;
    102 #if ENABLE(CONTENT_EXTENSIONS)
    103     std::unique_ptr<WebCore::ContentExtensions::ContentExtensionsBackend> m_contentExtensionsBackend;
    104 #endif
    105108    size_t m_redirectCount { 0 };
    106109    WebCore::URL m_previousURL;
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r230079 r230210  
    4040#include "NetworkBlobRegistry.h"
    4141#include "NetworkConnectionToWebProcess.h"
     42#include "NetworkContentRuleListManagerMessages.h"
    4243#include "NetworkProcessCreationParameters.h"
    4344#include "NetworkProcessPlatformStrategies.h"
     
    172173    }
    173174
     175#if ENABLE(CONTENT_EXTENSIONS)
     176    if (decoder.messageReceiverName() == Messages::NetworkContentRuleListManager::messageReceiverName()) {
     177        m_NetworkContentRuleListManager.didReceiveMessage(connection, decoder);
     178        return;
     179    }
     180#endif
     181
    174182    didReceiveNetworkProcessMessage(connection, decoder);
    175183}
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r230079 r230210  
    3030#include "DownloadManager.h"
    3131#include "MessageReceiverMap.h"
     32#include "NetworkContentRuleListManager.h"
    3233#include <WebCore/DiagnosticLoggingClient.h>
    3334#include <memory>
     
    157158    void setSessionIsControlledByAutomation(PAL::SessionID, bool);
    158159    bool sessionIsControlledByAutomation(PAL::SessionID) const;
     160
     161#if ENABLE(CONTENT_EXTENSIONS)
     162    NetworkContentRuleListManager& networkContentRuleListManager() { return m_NetworkContentRuleListManager; }
     163#endif
    159164
    160165private:
     
    292297    WebSQLiteDatabaseTracker m_webSQLiteDatabaseTracker;
    293298#endif
     299
     300#if ENABLE(CONTENT_EXTENSIONS)
     301    NetworkContentRuleListManager m_NetworkContentRuleListManager;
     302#endif
    294303};
    295304
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp

    r229979 r230210  
    9494#if ENABLE(CONTENT_EXTENSIONS)
    9595    encoder << mainDocumentURL;
    96     encoder << contentRuleLists;
     96    encoder << userContentControllerIdentifier;
    9797#endif
    9898}
     
    185185        return false;
    186186
    187     std::optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
    188     decoder >> contentRuleLists;
    189     if (!contentRuleLists)
     187    std::optional<std::optional<UserContentControllerIdentifier>> userContentControllerIdentifier;
     188    decoder >> userContentControllerIdentifier;
     189    if (!userContentControllerIdentifier)
    190190        return false;
    191     result.contentRuleLists = WTFMove(*contentRuleLists);
     191    result.userContentControllerIdentifier = *userContentControllerIdentifier;
    192192#endif
    193193
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h

    r227455 r230210  
    2828#include "NetworkLoadParameters.h"
    2929#include "SandboxExtension.h"
    30 #include "WebCompiledContentRuleListData.h"
     30#include "UserContentControllerIdentifier.h"
    3131#include <WebCore/ContentSecurityPolicyResponseHeaders.h>
    3232#include <WebCore/FetchOptions.h>
     
    6262#if ENABLE(CONTENT_EXTENSIONS)
    6363    WebCore::URL mainDocumentURL;
    64     Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
     64    std::optional<UserContentControllerIdentifier> userContentControllerIdentifier;
    6565#endif
    6666};
  • trunk/Source/WebKit/NetworkProcess/PingLoad.cpp

    r230014 r230210  
    4343    , m_completionHandler(WTFMove(completionHandler))
    4444    , m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)
    45     , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(m_parameters.mode, m_parameters.shouldFollowRedirects, m_parameters.storedCredentialsPolicy, m_parameters.sessionID, WTFMove(originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef()))
     45    , m_networkLoadChecker(NetworkLoadChecker::create(m_parameters.mode, m_parameters.shouldFollowRedirects, m_parameters.storedCredentialsPolicy, m_parameters.sessionID, WTFMove(originalRequestHeaders), URL { m_parameters.request.url() }, m_parameters.sourceOrigin.copyRef()))
    4646{
    4747
     
    4949        m_networkLoadChecker->setCSPResponseHeaders(WTFMove(m_parameters.cspResponseHeaders.value()));
    5050#if ENABLE(CONTENT_EXTENSIONS)
    51     m_networkLoadChecker->setContentExtensionRuleLists(WTFMove(m_parameters.mainDocumentURL), WTFMove(m_parameters.contentRuleLists));
     51    m_networkLoadChecker->setContentExtensionController(WTFMove(m_parameters.mainDocumentURL), m_parameters.userContentControllerIdentifier);
    5252#endif
    5353
  • trunk/Source/WebKit/NetworkProcess/PingLoad.h

    r230014 r230210  
    7171    RefPtr<NetworkDataTask> m_task;
    7272    WebCore::Timer m_timeoutTimer;
    73     UniqueRef<NetworkLoadChecker> m_networkLoadChecker;
     73    Ref<NetworkLoadChecker> m_networkLoadChecker;
    7474    std::optional<WebCore::ResourceRequest> m_lastRedirectionRequest;
    7575};
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r230108 r230210  
    186186
    187187    no_forward_declaration_types = frozenset([
     188        'String',
    188189        'WebCore::DocumentIdentifier',
    189190        'WebCore::ServiceWorkerIdentifier',
     
    193194        'WebCore::ServiceWorkerRegistrationIdentifier',
    194195        'WebCore::SWServerConnectionIdentifier',
    195         'String',
     196        'WebKit::UserContentControllerIdentifier',
    196197    ])
    197198
  • trunk/Source/WebKit/Shared/UserContentControllerIdentifier.h

    r230208 r230210  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include <wtf/text/WTFString.h>
    29 
    30 namespace IPC {
    31 class Decoder;
    32 class Encoder;
    33 }
     28#include <wtf/ObjectIdentifier.h>
    3429
    3530namespace WebKit {
    3631
    37 struct WebPageGroupData {
    38     void encode(IPC::Encoder&) const;
    39     static std::optional<WebPageGroupData> decode(IPC::Decoder&);
     32enum UserContentControllerIdentifierType { };
     33using UserContentControllerIdentifier = ObjectIdentifier<UserContentControllerIdentifierType>;
    4034
    41     String identifier;
    42     uint64_t pageGroupID;
    43     bool visibleToInjectedBundle;
    44     bool visibleToHistoryClient;
    45 
    46     uint64_t userContentControllerIdentifier;
    47 };
    48 
    49 } // namespace WebKit
     35}
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp

    r230059 r230210  
    180180    if (!decoder.decode(parameters.highestUsedBackForwardItemID))
    181181        return std::nullopt;
    182     if (!decoder.decode(parameters.userContentControllerID))
    183         return std::nullopt;
     182
     183    std::optional<UserContentControllerIdentifier> userContentControllerIdentifier;
     184    decoder >> userContentControllerIdentifier;
     185    if (!userContentControllerIdentifier)
     186        return std::nullopt;
     187    parameters.userContentControllerID = *userContentControllerIdentifier;
     188
    184189    if (!decoder.decode(parameters.visitedLinkTableID))
    185190        return std::nullopt;
  • trunk/Source/WebKit/Shared/WebPageCreationParameters.h

    r230059 r230210  
    9999    uint64_t highestUsedBackForwardItemID;
    100100
    101     uint64_t userContentControllerID;
     101    UserContentControllerIdentifier userContentControllerID;
    102102    uint64_t visitedLinkTableID;
    103103    uint64_t websiteDataStoreID;
  • trunk/Source/WebKit/Shared/WebPageGroupData.cpp

    r221319 r230210  
    5454    if (!decoder.decode(visibleToHistoryClient))
    5555        return std::nullopt;
    56     uint64_t userContentControllerIdentifier;
    57     if (!decoder.decode(userContentControllerIdentifier))
     56    std::optional<UserContentControllerIdentifier> userContentControllerIdentifier;
     57    decoder >> userContentControllerIdentifier;
     58    if (!userContentControllerIdentifier)
    5859        return std::nullopt;
    59     return { { id, pageGroupID, visibleToInjectedBundle, visibleToHistoryClient, userContentControllerIdentifier } };
     60    return { { id, pageGroupID, visibleToInjectedBundle, visibleToHistoryClient, *userContentControllerIdentifier } };
    6061}
    6162
  • trunk/Source/WebKit/Shared/WebPageGroupData.h

    r221333 r230210  
    2626#pragma once
    2727
     28#include "UserContentControllerIdentifier.h"
    2829#include <wtf/text/WTFString.h>
    2930
     
    4445    bool visibleToHistoryClient;
    4546
    46     uint64_t userContentControllerIdentifier;
     47    UserContentControllerIdentifier userContentControllerIdentifier;
    4748};
    4849
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r230153 r230210  
    2727#include "NetworkProcessProxy.h"
    2828
     29#include "APIContentRuleList.h"
    2930#include "AuthenticationChallengeProxy.h"
    3031#include "DownloadProxyMessages.h"
     
    3334#endif
    3435#include "Logging.h"
     36#include "NetworkContentRuleListManagerMessages.h"
    3537#include "NetworkProcessCreationParameters.h"
    3638#include "NetworkProcessMessages.h"
    3739#include "SandboxExtension.h"
    3840#include "StorageProcessMessages.h"
     41#include "WebCompiledContentRuleList.h"
    3942#include "WebPageProxy.h"
    4043#include "WebProcessMessages.h"
    4144#include "WebProcessPool.h"
     45#include "WebUserContentControllerProxy.h"
    4246#include "WebsiteData.h"
    4347#include <wtf/CompletionHandler.h>
     
    8690    ASSERT(m_pendingDeleteWebsiteDataCallbacks.isEmpty());
    8791    ASSERT(m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty());
     92#if ENABLE(CONTENT_EXTENSIONS)
     93    for (auto* proxy : m_webUserContentControllerProxies)
     94        proxy->removeNetworkProcess(*this);
     95#endif
    8896}
    8997
     
    541549}
    542550
     551
     552#if ENABLE(CONTENT_EXTENSIONS)
     553void NetworkProcessProxy::contentExtensionRules(UserContentControllerIdentifier identifier)
     554{
     555    if (auto* webUserContentControllerProxy = WebUserContentControllerProxy::get(identifier)) {
     556        m_webUserContentControllerProxies.add(webUserContentControllerProxy);
     557        webUserContentControllerProxy->addNetworkProcess(*this);
     558
     559        auto rules = WTF::map(webUserContentControllerProxy->contentExtensionRules(), [](auto&& keyValue) -> std::pair<String, WebCompiledContentRuleListData> {
     560            return std::make_pair(keyValue.value->name(), keyValue.value->compiledRuleList().data());
     561        });
     562        send(Messages::NetworkContentRuleListManager::AddContentRuleLists { identifier, rules }, 0);
     563        return;
     564    }
     565    send(Messages::NetworkContentRuleListManager::AddContentRuleLists { identifier, { } }, 0);
     566}
     567
     568void NetworkProcessProxy::didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy& proxy)
     569{
     570    send(Messages::NetworkContentRuleListManager::Remove { proxy.identifier() }, 0);
     571    m_webUserContentControllerProxies.remove(&proxy);
     572}
     573#endif
     574
    543575} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r229619 r230210  
    3434#include "ProcessThrottler.h"
    3535#include "ProcessThrottlerClient.h"
     36#include "UserContentControllerIdentifier.h"
    3637#include "WebProcessProxyMessages.h"
    3738#include <memory>
     
    6061enum class WebsiteDataType;
    6162struct NetworkProcessCreationParameters;
     63class WebUserContentControllerProxy;
    6264struct WebsiteData;
    6365
     
    9496    ProcessThrottler& throttler() { return m_throttler; }
    9597    WebProcessPool& processPool() { return m_processPool; }
     98
     99#if ENABLE(CONTENT_EXTENSIONS)
     100    void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&);
     101#endif
    96102
    97103private:
     
    140146#endif
    141147
     148#if ENABLE(CONTENT_EXTENSIONS)
     149    void contentExtensionRules(UserContentControllerIdentifier);
     150#endif
     151
    142152    // ProcessLauncher::Client
    143153    void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
     
    162172    HashMap<uint64_t, WTF::CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap;
    163173    HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap;
     174
     175#if ENABLE(CONTENT_EXTENSIONS)
     176    HashSet<WebUserContentControllerProxy*> m_webUserContentControllerProxies;
     177#endif
    164178};
    165179
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r228109 r230210  
    4848    StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
    4949    AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
     50
     51#if ENABLE(CONTENT_EXTENSIONS)
     52    ContentExtensionRules(WebKit::UserContentControllerIdentifier identifier)
     53#endif
    5054}
  • trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp

    r221399 r230210  
    3232#include "APIUserStyleSheet.h"
    3333#include "DataReference.h"
     34#include "NetworkContentRuleListManagerMessages.h"
     35#include "NetworkProcessProxy.h"
    3436#include "WebPageCreationParameters.h"
    3537#include "WebProcessProxy.h"
     
    4749namespace WebKit {
    4850
     51static HashMap<UserContentControllerIdentifier, WebUserContentControllerProxy*>& webUserContentControllerProxies()
     52{
     53    static NeverDestroyed<HashMap<UserContentControllerIdentifier, WebUserContentControllerProxy*>> proxies;
     54    return proxies;
     55}
     56
     57
     58WebUserContentControllerProxy* WebUserContentControllerProxy::get(UserContentControllerIdentifier identifier)
     59{
     60    return webUserContentControllerProxies().get(identifier);
     61}
     62   
    4963WebUserContentControllerProxy::WebUserContentControllerProxy()
    50     : m_userScripts(API::Array::create())
     64    : m_identifier(generateObjectIdentifier<UserContentControllerIdentifierType>())
     65    , m_userScripts(API::Array::create())
    5166    , m_userStyleSheets(API::Array::create())
    5267{
     68    webUserContentControllerProxies().add(m_identifier, this);
    5369}
    5470
    5571WebUserContentControllerProxy::~WebUserContentControllerProxy()
    5672{
    57     for (WebProcessProxy* process : m_processes) {
    58         process->removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier());
     73    webUserContentControllerProxies().remove(m_identifier);
     74    for (auto* process : m_processes) {
     75        process->removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier().toUInt64());
    5976        process->didDestroyWebUserContentControllerProxy(*this);
    6077    }
     78#if ENABLE(CONTENT_EXTENSIONS)
     79    for (auto* process : m_networkProcesses)
     80        process->didDestroyWebUserContentControllerProxy(*this);
     81#endif
    6182}
    6283
     
    6687        return;
    6788
    68     webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier(), *this);
     89    webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier().toUInt64(), *this);
    6990
    7091    ASSERT(parameters.userContentWorlds.isEmpty());
     
    96117
    97118    m_processes.remove(&webProcessProxy);
    98     webProcessProxy.removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier());
     119    webProcessProxy.removeMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), identifier().toUInt64());
    99120}
    100121
     
    107128    if (addResult.isNewEntry) {
    108129        for (WebProcessProxy* process : m_processes)
    109             process->send(Messages::WebUserContentController::AddUserContentWorlds({ std::make_pair(world.identifier(), world.name()) }), identifier());
     130            process->send(Messages::WebUserContentController::AddUserContentWorlds({ std::make_pair(world.identifier(), world.name()) }), identifier().toUInt64());
    110131    }
    111132}
     
    131152    if (shouldSendRemoveUserContentWorldsMessage(world, numberOfUsesToRemove)) {
    132153        for (WebProcessProxy* process : m_processes)
    133             process->send(Messages::WebUserContentController::RemoveUserContentWorlds({ world.identifier() }), identifier());
     154            process->send(Messages::WebUserContentController::RemoveUserContentWorlds({ world.identifier() }), identifier().toUInt64());
    134155    }
    135156}
     
    144165
    145166    for (WebProcessProxy* process : m_processes)
    146         process->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), identifier());
     167        process->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), identifier().toUInt64());
    147168}
    148169
     
    156177
    157178    for (WebProcessProxy* process : m_processes)
    158         process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), identifier());
     179        process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), identifier().toUInt64());
    159180}
    160181
     
    164185
    165186    for (WebProcessProxy* process : m_processes)
    166         process->send(Messages::WebUserContentController::RemoveUserScript(world->identifier(), userScript.identifier()), identifier());
     187        process->send(Messages::WebUserContentController::RemoveUserScript(world->identifier(), userScript.identifier()), identifier().toUInt64());
    167188
    168189    m_userScripts->elements().removeAll(&userScript);
     
    174195{
    175196    for (WebProcessProxy* process : m_processes)
    176         process->send(Messages::WebUserContentController::RemoveAllUserScripts({ world.identifier() }), identifier());
     197        process->send(Messages::WebUserContentController::RemoveAllUserScripts({ world.identifier() }), identifier().toUInt64());
    177198
    178199    unsigned userScriptsRemoved = m_userScripts->removeAllOfTypeMatching<API::UserScript>([&](const auto& userScript) {
     
    195216
    196217    for (WebProcessProxy* process : m_processes)
    197         process->send(Messages::WebUserContentController::RemoveAllUserScripts(worldIdentifiers), identifier());
     218        process->send(Messages::WebUserContentController::RemoveAllUserScripts(worldIdentifiers), identifier().toUInt64());
    198219
    199220    m_userScripts->elements().clear();
     
    211232
    212233    for (WebProcessProxy* process : m_processes)
    213         process->send(Messages::WebUserContentController::AddUserStyleSheets({ { userStyleSheet.identifier(), world->identifier(), userStyleSheet.userStyleSheet() } }), identifier());
     234        process->send(Messages::WebUserContentController::AddUserStyleSheets({ { userStyleSheet.identifier(), world->identifier(), userStyleSheet.userStyleSheet() } }), identifier().toUInt64());
    214235}
    215236
     
    219240
    220241    for (WebProcessProxy* process : m_processes)
    221         process->send(Messages::WebUserContentController::RemoveUserStyleSheet(world->identifier(), userStyleSheet.identifier()), identifier());
     242        process->send(Messages::WebUserContentController::RemoveUserStyleSheet(world->identifier(), userStyleSheet.identifier()), identifier().toUInt64());
    222243
    223244    m_userStyleSheets->elements().removeAll(&userStyleSheet);
     
    229250{
    230251    for (WebProcessProxy* process : m_processes)
    231         process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets({ world.identifier() }), identifier());
     252        process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets({ world.identifier() }), identifier().toUInt64());
    232253
    233254    unsigned userStyleSheetsRemoved = m_userStyleSheets->removeAllOfTypeMatching<API::UserStyleSheet>([&](const auto& userStyleSheet) {
     
    250271
    251272    for (WebProcessProxy* process : m_processes)
    252         process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(worldIdentifiers), identifier());
     273        process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(worldIdentifiers), identifier().toUInt64());
    253274
    254275    m_userStyleSheets->elements().clear();
     
    271292
    272293    for (WebProcessProxy* process : m_processes)
    273         process->send(Messages::WebUserContentController::AddUserScriptMessageHandlers({ { handler.identifier(), world->identifier(), handler.name() } }), identifier());
     294        process->send(Messages::WebUserContentController::AddUserScriptMessageHandlers({ { handler.identifier(), world->identifier(), handler.name() } }), identifier().toUInt64());
    274295   
    275296    return true;
     
    281302        if (it->value->name() == name && &it->value->userContentWorld() == &world) {
    282303            for (WebProcessProxy* process : m_processes)
    283                 process->send(Messages::WebUserContentController::RemoveUserScriptMessageHandler(world.identifier(), it->value->identifier()), identifier());
     304                process->send(Messages::WebUserContentController::RemoveUserScriptMessageHandler(world.identifier(), it->value->identifier()), identifier().toUInt64());
    284305
    285306            m_scriptMessageHandlers.remove(it);
     
    294315{
    295316    for (WebProcessProxy* process : m_processes)
    296         process->send(Messages::WebUserContentController::RemoveAllUserScriptMessageHandlers({ world.identifier() }), identifier());
     317        process->send(Messages::WebUserContentController::RemoveAllUserScriptMessageHandlers({ world.identifier() }), identifier().toUInt64());
    297318
    298319    unsigned numberRemoved = 0;
     
    331352    auto pair = std::make_pair(contentRuleList.name(), contentRuleList.compiledRuleList().data());
    332353
    333     for (WebProcessProxy* process : m_processes)
    334         process->send(Messages::WebUserContentController::AddContentRuleLists({ pair }), identifier());
     354    for (auto* process : m_processes)
     355        process->send(Messages::WebUserContentController::AddContentRuleLists({ pair }), identifier().toUInt64());
     356
     357    for (auto* process : m_networkProcesses)
     358        process->send(Messages::NetworkContentRuleListManager::AddContentRuleLists { identifier(), { pair } }, 0);
    335359}
    336360
     
    339363    m_contentRuleLists.remove(name);
    340364
    341     for (WebProcessProxy* process : m_processes)
    342         process->send(Messages::WebUserContentController::RemoveContentRuleList(name), identifier());
     365    for (auto* process : m_processes)
     366        process->send(Messages::WebUserContentController::RemoveContentRuleList(name), identifier().toUInt64());
     367
     368    for (auto* process : m_networkProcesses)
     369        process->send(Messages::NetworkContentRuleListManager::RemoveContentRuleList { identifier(), name }, 0);
    343370}
    344371
     
    347374    m_contentRuleLists.clear();
    348375
    349     for (WebProcessProxy* process : m_processes)
    350         process->send(Messages::WebUserContentController::RemoveAllContentRuleLists(), identifier());
     376    for (auto* process : m_processes)
     377        process->send(Messages::WebUserContentController::RemoveAllContentRuleLists(), identifier().toUInt64());
     378
     379    for (auto* process : m_networkProcesses)
     380        process->send(Messages::NetworkContentRuleListManager::RemoveAllContentRuleLists { identifier() }, 0);
    351381}
    352382#endif
  • trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h

    r221399 r230210  
    2828#include "APIObject.h"
    2929#include "MessageReceiver.h"
     30#include "UserContentControllerIdentifier.h"
    3031#include <wtf/Forward.h>
    3132#include <wtf/HashCountedSet.h>
    3233#include <wtf/HashMap.h>
    3334#include <wtf/HashSet.h>
    34 #include <wtf/Identified.h>
    3535#include <wtf/Ref.h>
    3636#include <wtf/RefCounted.h>
     
    5555namespace WebKit {
    5656
     57class NetworkProcessProxy;
    5758class WebProcessProxy;
    5859class WebScriptMessageHandler;
     
    6061struct WebPageCreationParameters;
    6162
    62 class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver, public Identified<WebUserContentControllerProxy> {
     63class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver {
    6364public:
    6465    static Ref<WebUserContentControllerProxy> create()
    6566    {
    6667        return adoptRef(*new WebUserContentControllerProxy);
    67     } 
    68     explicit WebUserContentControllerProxy();
     68    }
     69    WebUserContentControllerProxy();
    6970    ~WebUserContentControllerProxy();
     71
     72    static WebUserContentControllerProxy* get(UserContentControllerIdentifier);
    7073
    7174    void addProcess(WebProcessProxy&, WebPageCreationParameters&);
     
    9295
    9396#if ENABLE(CONTENT_EXTENSIONS)
     97    void addNetworkProcess(NetworkProcessProxy& proxy) { m_networkProcesses.remove(&proxy); }
     98    void removeNetworkProcess(NetworkProcessProxy& proxy) { m_networkProcesses.add(&proxy); }
     99
    94100    void addContentRuleList(API::ContentRuleList&);
    95101    void removeContentRuleList(const String&);
    96102    void removeAllContentRuleLists();
     103    const HashMap<String, RefPtr<API::ContentRuleList>>& contentExtensionRules() { return m_contentRuleLists; }
    97104#endif
     105
     106    UserContentControllerIdentifier identifier() const { return m_identifier; }
    98107
    99108private:
     
    108117    bool shouldSendRemoveUserContentWorldsMessage(API::UserContentWorld&, unsigned numberOfUsesToRemove);
    109118
    110     HashSet<WebProcessProxy*> m_processes;   
     119    UserContentControllerIdentifier m_identifier;
     120    HashSet<WebProcessProxy*> m_processes;
    111121    Ref<API::Array> m_userScripts;
    112122    Ref<API::Array> m_userStyleSheets;
     
    115125
    116126#if ENABLE(CONTENT_EXTENSIONS)
     127    HashSet<NetworkProcessProxy*> m_networkProcesses;
    117128    HashMap<String, RefPtr<API::ContentRuleList>> m_contentRuleLists;
    118129#endif
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r230193 r230210  
    959959                41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
    960960                41FAF5F91E3C1025001AE678 /* LibWebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */; };
     961                41FBE826206DF7FA000F0741 /* NetworkContentRuleListManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FBE824206DA79C000F0741 /* NetworkContentRuleListManager.cpp */; };
    961962                4450AEC01DC3FAE5009943F2 /* SharedMemoryCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */; };
    962963                460F488F1F996F7100CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */; };
     
    11971198                52D5A1B11C57496200DE34A3 /* VideoFullscreenManagerProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A1AC1C57494E00DE34A3 /* VideoFullscreenManagerProxy.mm */; };
    11981199                52D5A1B71C574A0200DE34A3 /* VideoFullscreenManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A1B41C5749F200DE34A3 /* VideoFullscreenManager.mm */; };
     1200                52F060E11654318500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52F060DD1654317500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp */; };
    11991201                5302583B1DCBBD2200DA89C2 /* NetworkCaptureResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5302582E1DCBBD1D00DA89C2 /* NetworkCaptureResource.cpp */; };
    12001202                5302583C1DCBBD2200DA89C2 /* NetworkCaptureResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 5302582F1DCBBD1D00DA89C2 /* NetworkCaptureResource.h */; };
     
    33433345                41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCResolver.h; path = Network/webrtc/LibWebRTCResolver.h; sourceTree = "<group>"; };
    33443346                41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCResolver.cpp; path = Network/webrtc/LibWebRTCResolver.cpp; sourceTree = "<group>"; };
     3347                41FBE821206D87F6000F0741 /* UserContentControllerIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserContentControllerIdentifier.h; sourceTree = "<group>"; };
     3348                41FBE822206DA79C000F0741 /* NetworkContentRuleListManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkContentRuleListManager.h; path = NetworkProcess/NetworkContentRuleListManager.h; sourceTree = "<group>"; };
     3349                41FBE823206DA79C000F0741 /* NetworkContentRuleListManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkContentRuleListManager.messages.in; path = NetworkProcess/NetworkContentRuleListManager.messages.in; sourceTree = "<group>"; };
     3350                41FBE824206DA79C000F0741 /* NetworkContentRuleListManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkContentRuleListManager.cpp; path = NetworkProcess/NetworkContentRuleListManager.cpp; sourceTree = "<group>"; };
    33453351                4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemoryCocoa.cpp; sourceTree = "<group>"; };
    33463352                460F488D1F996F6C00CF4B87 /* WebSWContextManagerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWContextManagerConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
     
    36253631                52D5A1B31C5749F200DE34A3 /* VideoFullscreenManager.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VideoFullscreenManager.messages.in; sourceTree = "<group>"; };
    36263632                52D5A1B41C5749F200DE34A3 /* VideoFullscreenManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoFullscreenManager.mm; sourceTree = "<group>"; };
     3633                52F060DD1654317500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkContentRuleListManagerMessageReceiver.cpp; sourceTree = "<group>"; };
    36273634                5302582E1DCBBD1D00DA89C2 /* NetworkCaptureResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkCaptureResource.cpp; path = NetworkProcess/capture/NetworkCaptureResource.cpp; sourceTree = "<group>"; };
    36283635                5302582F1DCBBD1D00DA89C2 /* NetworkCaptureResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkCaptureResource.h; path = NetworkProcess/capture/NetworkCaptureResource.h; sourceTree = "<group>"; };
     
    52725279                                5C19A51E1FD0B14600EEA323 /* URLSchemeTaskParameters.cpp */,
    52735280                                5C19A51F1FD0B14700EEA323 /* URLSchemeTaskParameters.h */,
     5281                                41FBE821206D87F6000F0741 /* UserContentControllerIdentifier.h */,
    52745282                                1AC1336518565B5700F3EC05 /* UserData.cpp */,
    52755283                                1AC1336618565B5700F3EC05 /* UserData.h */,
     
    63606368                                513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */,
    63616369                                513A164B1630A9BF005D7D22 /* NetworkConnectionToWebProcess.messages.in */,
     6370                                41FBE824206DA79C000F0741 /* NetworkContentRuleListManager.cpp */,
     6371                                41FBE822206DA79C000F0741 /* NetworkContentRuleListManager.h */,
     6372                                41FBE823206DA79C000F0741 /* NetworkContentRuleListManager.messages.in */,
    63626373                                46DF06391F3905E5001980BB /* NetworkCORSPreflightChecker.cpp */,
    63636374                                46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */,
     
    82458256                                51DD9F2616367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp */,
    82468257                                51DD9F2716367DA2001578E9 /* NetworkConnectionToWebProcessMessages.h */,
     8258                                52F060DD1654317500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp */,
    82478259                                517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */,
    82488260                                517CF0E2163A486C00C2950E /* NetworkProcessConnectionMessages.h */,
     
    1066010672                                513A164C1630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp in Sources */,
    1066110673                                51DD9F2816367DA2001578E9 /* NetworkConnectionToWebProcessMessageReceiver.cpp in Sources */,
     10674                                41FBE826206DF7FA000F0741 /* NetworkContentRuleListManager.cpp in Sources */,
     10675                                52F060E11654318500F3281B /* NetworkContentRuleListManagerMessageReceiver.cpp in Sources */,
    1066210676                                46DF063B1F3905F8001980BB /* NetworkCORSPreflightChecker.cpp in Sources */,
    1066310677                                532159541DBAE71D0054AA3C /* NetworkDataTask.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

    r230007 r230210  
    457457    }
    458458
     459    WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(frame.loader().client());
     460    WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
     461
    459462    NetworkResourceLoadParameters loadParameters;
    460463    loadParameters.identifier = generateLoadIdentifier();
     
    473476#if ENABLE(CONTENT_EXTENSIONS)
    474477    loadParameters.mainDocumentURL = document->topDocument().url();
    475 
    476     if (auto* documentLoader = frame.loader().documentLoader()) {
    477         if (auto* page = frame.page()) {
    478             page->userContentProvider().forEachContentExtension([&loadParameters](const String& identifier, ContentExtensions::ContentExtension& contentExtension) {
    479                 loadParameters.contentRuleLists.append(std::make_pair(identifier, static_cast<const WebCompiledContentRuleList&>(contentExtension.compiledExtension()).data()));
    480             }, *documentLoader);
    481         }
     478    // FIXME: Instead of passing userContentControllerIdentifier, we should just pass webPageId to NetworkProcess.
     479    if (auto* page = frame.page()) {
     480        WebPage* webPage = webFrame ? webFrame->page() : nullptr;
     481        if (webPage)
     482            loadParameters.userContentControllerIdentifier = webPage->userContentControllerIdentifier();
    482483    }
    483484#endif
  • trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp

    r219573 r230210  
    5151namespace WebKit {
    5252
    53 static HashMap<uint64_t, WebUserContentController*>& userContentControllers()
    54 {
    55     static NeverDestroyed<HashMap<uint64_t, WebUserContentController*>> userContentControllers;
     53static HashMap<UserContentControllerIdentifier, WebUserContentController*>& userContentControllers()
     54{
     55    static NeverDestroyed<HashMap<UserContentControllerIdentifier, WebUserContentController*>> userContentControllers;
    5656
    5757    return userContentControllers;
     
    6767}
    6868
    69 Ref<WebUserContentController> WebUserContentController::getOrCreate(uint64_t identifier)
     69Ref<WebUserContentController> WebUserContentController::getOrCreate(UserContentControllerIdentifier identifier)
    7070{
    7171    auto& userContentControllerPtr = userContentControllers().add(identifier, nullptr).iterator->value;
     
    7979}
    8080
    81 WebUserContentController::WebUserContentController(uint64_t identifier)
     81WebUserContentController::WebUserContentController(UserContentControllerIdentifier identifier)
    8282    : m_identifier(identifier)
    8383{
    84     WebProcess::singleton().addMessageReceiver(Messages::WebUserContentController::messageReceiverName(), m_identifier, *this);
     84    WebProcess::singleton().addMessageReceiver(Messages::WebUserContentController::messageReceiverName(), m_identifier.toUInt64(), *this);
    8585}
    8686
     
    8989    ASSERT(userContentControllers().contains(m_identifier));
    9090
    91     WebProcess::singleton().removeMessageReceiver(Messages::WebUserContentController::messageReceiverName(), m_identifier);
     91    WebProcess::singleton().removeMessageReceiver(Messages::WebUserContentController::messageReceiverName(), m_identifier.toUInt64());
    9292
    9393    userContentControllers().remove(m_identifier);
     
    243243            return;
    244244
    245         WebProcess::singleton().parentProcessConnection()->send(Messages::WebUserContentControllerProxy::DidPostMessage(webPage->pageID(), webFrame->info(), m_identifier, IPC::DataReference(value->data())), m_controller->identifier());
     245        WebProcess::singleton().parentProcessConnection()->send(Messages::WebUserContentControllerProxy::DidPostMessage(webPage->pageID(), webFrame->info(), m_identifier, IPC::DataReference(value->data())), m_controller->identifier().toUInt64());
    246246    }
    247247
  • trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.h

    r218299 r230210  
    2727
    2828#include "MessageReceiver.h"
     29#include "UserContentControllerIdentifier.h"
    2930#include "WebScriptMessageHandler.h"
    3031#include "WebUserContentControllerDataTypes.h"
     
    5051class WebUserContentController final : public WebCore::UserContentProvider, private IPC::MessageReceiver {
    5152public:
    52     static Ref<WebUserContentController> getOrCreate(uint64_t identifier);
     53    static Ref<WebUserContentController> getOrCreate(UserContentControllerIdentifier);
    5354    virtual ~WebUserContentController();
    5455
    55     uint64_t identifier() { return m_identifier; }
     56    UserContentControllerIdentifier identifier() { return m_identifier; }
    5657
    5758    void addUserScript(InjectedBundleScriptWorld&, WebCore::UserScript&&);
     
    7273
    7374private:
    74     explicit WebUserContentController(uint64_t identifier);
     75    explicit WebUserContentController(UserContentControllerIdentifier);
    7576
    7677    // WebCore::UserContentProvider
     
    112113#endif
    113114
    114     uint64_t m_identifier;
     115    UserContentControllerIdentifier m_identifier;
    115116
    116117    typedef HashMap<RefPtr<InjectedBundleScriptWorld>, Vector<std::pair<uint64_t, WebCore::UserScript>>> WorldToUserScriptMap;
     
    127128    WebCore::ContentExtensions::ContentExtensionsBackend m_contentExtensionBackend;
    128129#endif
    129 
    130130};
    131131
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r230059 r230210  
    4747#include "UserData.h"
    4848#include "WebURLSchemeHandler.h"
     49#include "WebUserContentController.h"
    4950#include <WebCore/ActivityState.h>
    5051#include <WebCore/DictionaryPopupInfo.h>
     
    10701071#endif
    10711072
     1073    UserContentControllerIdentifier userContentControllerIdentifier() const { return m_userContentController->identifier(); }
     1074
    10721075private:
    10731076    WebPage(uint64_t pageID, WebPageCreationParameters&&);
Note: See TracChangeset for help on using the changeset viewer.