<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[286084] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/286084">286084</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2021-11-19 15:52:41 -0800 (Fri, 19 Nov 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement extension-path variant of redirect action in WKContentRuleList
https://bugs.webkit.org/show_bug.cgi?id=233351

Reviewed by Tim Hatcher.

Source/WebCore:

Because the extension path changes each time you relaunch Safari but the compiled bytecode does not,
we need a way to pass in the extension base URL when adding the looked-up or compiled WKContentRuleList
to the WKUserContentController.

* contentextensions/ContentExtension.cpp:
(WebCore::ContentExtensions::ContentExtension::create):
(WebCore::ContentExtensions::ContentExtension::ContentExtension):
* contentextensions/ContentExtension.h:
(WebCore::ContentExtensions::ContentExtension::extensionBaseURL const):
* contentextensions/ContentExtensionActions.cpp:
(WebCore::ContentExtensions::RedirectAction::applyToRequest):
* contentextensions/ContentExtensionActions.h:
* contentextensions/ContentExtensionsBackend.cpp:
(WebCore::ContentExtensions::ContentExtensionsBackend::addContentExtension):
(WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
(WebCore::ContentExtensions::applyResultsToRequest):
* contentextensions/ContentExtensionsBackend.h:
* contentextensions/ContentRuleListResults.h:

Source/WebKit:

* NetworkProcess/NetworkContentRuleListManager.cpp:
(WebKit::NetworkContentRuleListManager::addContentRuleLists):
* NetworkProcess/NetworkContentRuleListManager.h:
* NetworkProcess/NetworkContentRuleListManager.messages.in:
* Shared/ServiceWorkerInitializationData.cpp:
(WebKit::ServiceWorkerInitializationData::decode):
* Shared/ServiceWorkerInitializationData.h:
* Shared/UserContentControllerParameters.cpp:
(WebKit::UserContentControllerParameters::decode):
* Shared/UserContentControllerParameters.h:
* Shared/WebCompiledContentRuleListData.cpp:
(WebKit::WebCompiledContentRuleListData::encode const):
(WebKit::WebCompiledContentRuleListData::decode):
* Shared/WebCompiledContentRuleListData.h:
(WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
* UIProcess/API/APIContentRuleList.cpp:
(API::ContentRuleList::ContentRuleList):
(API::ContentRuleList::name const):
* UIProcess/API/APIContentRuleList.h:
* UIProcess/API/APIContentRuleListStore.cpp:
(API::createExtension):
* UIProcess/API/Cocoa/WKUserContentController.mm:
(-[WKUserContentController _addContentRuleList:extensionBaseURL:]):
* UIProcess/API/Cocoa/WKUserContentControllerPrivate.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::contentExtensionRules):
* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::contentRuleListData const):
(WebKit::WebUserContentControllerProxy::addContentRuleList):
* UIProcess/UserContent/WebUserContentControllerProxy.h:
(WebKit::WebUserContentControllerProxy::addContentRuleList):
(WebKit::WebUserContentControllerProxy::contentExtensionRules):
* UIProcess/WebProcessProxy.cpp:
(WebKit::contentRuleListsFromIdentifier):
* WebProcess/UserContent/WebUserContentController.cpp:
(WebKit::WebUserContentController::addContentRuleLists):
* WebProcess/UserContent/WebUserContentController.h:
* WebProcess/UserContent/WebUserContentController.messages.in:

Tools:

* TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
(TestWebKitAPI::makeBackend):
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
(TEST_F):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensioncpp">trunk/Source/WebCore/contentextensions/ContentExtension.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionh">trunk/Source/WebCore/contentextensions/ContentExtension.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionActionscpp">trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionActionsh">trunk/Source/WebCore/contentextensions/ContentExtensionActions.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentExtensionsBackendh">trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h</a></li>
<li><a href="#trunkSourceWebCorecontentextensionsContentRuleListResultsh">trunk/Source/WebCore/contentextensions/ContentRuleListResults.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkContentRuleListManagercpp">trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.cpp</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkContentRuleListManagerh">trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkContentRuleListManagermessagesin">trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.messages.in</a></li>
<li><a href="#trunkSourceWebKitSharedServiceWorkerInitializationDatacpp">trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedServiceWorkerInitializationDatah">trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.h</a></li>
<li><a href="#trunkSourceWebKitSharedUserContentControllerParameterscpp">trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedUserContentControllerParametersh">trunk/Source/WebKit/Shared/UserContentControllerParameters.h</a></li>
<li><a href="#trunkSourceWebKitSharedWebCompiledContentRuleListDatacpp">trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebCompiledContentRuleListDatah">trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIContentRuleListcpp">trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIContentRuleListh">trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIContentRuleListStorecpp">trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUserContentControllermm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKUserContentControllerPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessNetworkNetworkProcessProxycpp">trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessUserContentWebUserContentControllerProxycpp">trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessUserContentWebUserContentControllerProxyh">trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebProcessProxycpp">trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessUserContentWebUserContentControllercpp">trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessUserContentWebUserContentControllerh">trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessUserContentWebUserContentControllermessagesin">trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.messages.in</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoreContentExtensionscpp">trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaWKContentExtensionStoremm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/ChangeLog      2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2021-11-19  Alex Christensen  <achristensen@webkit.org>
+
+        Implement extension-path variant of redirect action in WKContentRuleList
+        https://bugs.webkit.org/show_bug.cgi?id=233351
+
+        Reviewed by Tim Hatcher.
+
+        Because the extension path changes each time you relaunch Safari but the compiled bytecode does not,
+        we need a way to pass in the extension base URL when adding the looked-up or compiled WKContentRuleList
+        to the WKUserContentController.
+
+        * contentextensions/ContentExtension.cpp:
+        (WebCore::ContentExtensions::ContentExtension::create):
+        (WebCore::ContentExtensions::ContentExtension::ContentExtension):
+        * contentextensions/ContentExtension.h:
+        (WebCore::ContentExtensions::ContentExtension::extensionBaseURL const):
+        * contentextensions/ContentExtensionActions.cpp:
+        (WebCore::ContentExtensions::RedirectAction::applyToRequest):
+        * contentextensions/ContentExtensionActions.h:
+        * contentextensions/ContentExtensionsBackend.cpp:
+        (WebCore::ContentExtensions::ContentExtensionsBackend::addContentExtension):
+        (WebCore::ContentExtensions::ContentExtensionsBackend::processContentRuleListsForLoad):
+        (WebCore::ContentExtensions::applyResultsToRequest):
+        * contentextensions/ContentExtensionsBackend.h:
+        * contentextensions/ContentRuleListResults.h:
+
</ins><span class="cx"> 2021-11-19  Myles C. Maxfield  <mmaxfield@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [WebGPU] Add converters from serializable descriptors to interface descriptors
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtension.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.cpp      2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.cpp 2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -36,14 +36,15 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> namespace ContentExtensions {
</span><span class="cx"> 
</span><del>-Ref<ContentExtension> ContentExtension::create(const String& identifier, Ref<CompiledContentExtension>&& compiledExtension, ShouldCompileCSS shouldCompileCSS)
</del><ins>+Ref<ContentExtension> ContentExtension::create(const String& identifier, Ref<CompiledContentExtension>&& compiledExtension, URL&& extensionBaseURL, ShouldCompileCSS shouldCompileCSS)
</ins><span class="cx"> {
</span><del>-    return adoptRef(*new ContentExtension(identifier, WTFMove(compiledExtension), shouldCompileCSS));
</del><ins>+    return adoptRef(*new ContentExtension(identifier, WTFMove(compiledExtension), WTFMove(extensionBaseURL), shouldCompileCSS));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ContentExtension::ContentExtension(const String& identifier, Ref<CompiledContentExtension>&& compiledExtension, ShouldCompileCSS shouldCompileCSS)
</del><ins>+ContentExtension::ContentExtension(const String& identifier, Ref<CompiledContentExtension>&& compiledExtension, URL&& extensionBaseURL, ShouldCompileCSS shouldCompileCSS)
</ins><span class="cx">     : m_identifier(identifier)
</span><span class="cx">     , m_compiledExtension(WTFMove(compiledExtension))
</span><ins>+    , m_extensionBaseURL(WTFMove(extensionBaseURL))
</ins><span class="cx"> {
</span><span class="cx">     DFABytecodeInterpreter withoutConditions(m_compiledExtension->filtersWithoutConditionsBytecode(), m_compiledExtension->filtersWithoutConditionsBytecodeLength());
</span><span class="cx">     DFABytecodeInterpreter withConditions(m_compiledExtension->filtersWithConditionsBytecode(), m_compiledExtension->filtersWithConditionsBytecodeLength());
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtension.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtension.h        2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentExtension.h   2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -42,9 +42,10 @@
</span><span class="cx"> class ContentExtension : public RefCounted<ContentExtension> {
</span><span class="cx"> public:
</span><span class="cx">     enum class ShouldCompileCSS { No, Yes };
</span><del>-    static Ref<ContentExtension> create(const String& identifier, Ref<CompiledContentExtension>&&, ShouldCompileCSS = ShouldCompileCSS::Yes);
</del><ins>+    static Ref<ContentExtension> create(const String& identifier, Ref<CompiledContentExtension>&&, URL&&, ShouldCompileCSS);
</ins><span class="cx"> 
</span><span class="cx">     const String& identifier() const { return m_identifier; }
</span><ins>+    const URL& extensionBaseURL() const { return m_extensionBaseURL; }
</ins><span class="cx">     const CompiledContentExtension& compiledExtension() const { return m_compiledExtension.get(); }
</span><span class="cx">     StyleSheetContents* globalDisplayNoneStyleSheet();
</span><span class="cx">     const DFABytecodeInterpreter::Actions& topURLActions(const URL& topURL);
</span><span class="lines">@@ -52,11 +53,12 @@
</span><span class="cx">     const Vector<uint32_t>& universalActionsWithConditions(const URL& topURL);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    ContentExtension(const String& identifier, Ref<CompiledContentExtension>&&, ShouldCompileCSS);
</del><ins>+    ContentExtension(const String& identifier, Ref<CompiledContentExtension>&&, URL&&, ShouldCompileCSS);
</ins><span class="cx">     uint32_t findFirstIgnorePreviousRules() const;
</span><span class="cx">     
</span><span class="cx">     String m_identifier;
</span><span class="cx">     Ref<CompiledContentExtension> m_compiledExtension;
</span><ins>+    URL m_extensionBaseURL;
</ins><span class="cx"> 
</span><span class="cx">     RefPtr<StyleSheetContents> m_globalDisplayNoneStyleSheet;
</span><span class="cx">     void compileGlobalDisplayNoneStyleSheet();
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionActionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp       2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionActions.cpp  2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -368,10 +368,12 @@
</span><span class="cx">     return deserializeLength(span, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RedirectAction::applyToRequest(ResourceRequest& request)
</del><ins>+void RedirectAction::applyToRequest(ResourceRequest& request, const URL& extensionBaseURL)
</ins><span class="cx"> {
</span><del>-    std::visit(WTF::makeVisitor([](const ExtensionPathAction&) {
-        // FIXME: Implement. We need to know the base URL of the extension here from new SPI.
</del><ins>+    std::visit(WTF::makeVisitor([&](const ExtensionPathAction& action) {
+        auto url = extensionBaseURL;
+        url.setPath(action.extensionPath);
+        request.setURL(WTFMove(url));
</ins><span class="cx">     }, [&] (const RegexSubstitutionAction&) {
</span><span class="cx">         // FIXME: Implement, ideally in a way that doesn't require making a new VM and global object for each redirect operation.
</span><span class="cx">     }, [&] (const URLTransformAction& action) {
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionActionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionActions.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionActions.h 2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionActions.h    2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -244,7 +244,7 @@
</span><span class="cx">     void serialize(Vector<uint8_t>&) const;
</span><span class="cx">     static RedirectAction deserialize(Span<const uint8_t>);
</span><span class="cx">     static size_t serializedLength(Span<const uint8_t>);
</span><del>-    void applyToRequest(ResourceRequest&);
</del><ins>+    void applyToRequest(ResourceRequest&, const URL&);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> using ActionData = std::variant<
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp      2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.cpp 2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -78,13 +78,13 @@
</span><span class="cx">     return results.summary.madeHTTPS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ContentExtensionsBackend::addContentExtension(const String& identifier, Ref<CompiledContentExtension> compiledContentExtension, ContentExtension::ShouldCompileCSS shouldCompileCSS)
</del><ins>+void ContentExtensionsBackend::addContentExtension(const String& identifier, Ref<CompiledContentExtension> compiledContentExtension, URL&& extensionBaseURL, ContentExtension::ShouldCompileCSS shouldCompileCSS)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!identifier.isEmpty());
</span><span class="cx">     if (identifier.isEmpty())
</span><span class="cx">         return;
</span><span class="cx">     
</span><del>-    auto contentExtension = ContentExtension::create(identifier, WTFMove(compiledContentExtension), shouldCompileCSS);
</del><ins>+    auto contentExtension = ContentExtension::create(identifier, WTFMove(compiledContentExtension), WTFMove(extensionBaseURL), shouldCompileCSS);
</ins><span class="cx">     m_contentExtensions.set(identifier, WTFMove(contentExtension));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -231,9 +231,9 @@
</span><span class="cx">             }, [&] (const ModifyHeadersAction& action) {
</span><span class="cx">                 if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(url))
</span><span class="cx">                     results.summary.modifyHeadersActions.append(action);
</span><del>-            }, [&] (const RedirectAction& action) {
</del><ins>+            }, [&] (const RedirectAction& redirectAction) {
</ins><span class="cx">                 if (initiatingDocumentLoader.allowsActiveContentRuleListActionsForURL(url))
</span><del>-                    results.summary.redirectActions.append(action);
</del><ins>+                    results.summary.redirectActions.append({ redirectAction, m_contentExtensions.get(actionsFromContentRuleList.contentRuleListIdentifier)->extensionBaseURL() });
</ins><span class="cx">             }), action.data());
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -330,8 +330,8 @@
</span><span class="cx">     for (auto& action : results.summary.modifyHeadersActions)
</span><span class="cx">         action.applyToRequest(request);
</span><span class="cx"> 
</span><del>-    for (auto& action : results.summary.redirectActions)
-        action.applyToRequest(request);
</del><ins>+    for (auto& pair : results.summary.redirectActions)
+        pair.first.applyToRequest(request, pair.second);
</ins><span class="cx"> 
</span><span class="cx">     if (page && results.shouldNotifyApplication()) {
</span><span class="cx">         results.results.removeAllMatching([](const auto& pair) {
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentExtensionsBackendh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h        2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionsBackend.h   2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Set a list of rules for a given name. If there were existing rules for the name, they are overridden.
</span><span class="cx">     // The identifier cannot be empty.
</span><del>-    WEBCORE_EXPORT void addContentExtension(const String& identifier, Ref<CompiledContentExtension>, ContentExtension::ShouldCompileCSS = ContentExtension::ShouldCompileCSS::Yes);
</del><ins>+    WEBCORE_EXPORT void addContentExtension(const String& identifier, Ref<CompiledContentExtension>, URL&& extensionBaseURL, ContentExtension::ShouldCompileCSS = ContentExtension::ShouldCompileCSS::Yes);
</ins><span class="cx">     WEBCORE_EXPORT void removeContentExtension(const String& identifier);
</span><span class="cx">     WEBCORE_EXPORT void removeAllContentExtensions();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecontentextensionsContentRuleListResultsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/contentextensions/ContentRuleListResults.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/contentextensions/ContentRuleListResults.h  2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebCore/contentextensions/ContentRuleListResults.h     2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">         bool blockedCookies { false };
</span><span class="cx">         bool hasNotifications { false };
</span><span class="cx">         Vector<ContentExtensions::ModifyHeadersAction> modifyHeadersActions;
</span><del>-        Vector<ContentExtensions::RedirectAction> redirectActions;
</del><ins>+        Vector<std::pair<ContentExtensions::RedirectAction, URL>> redirectActions;
</ins><span class="cx"> 
</span><span class="cx">         template<class Encoder> void encode(Encoder&) const;
</span><span class="cx">         template<class Decoder> static std::optional<Summary> decode(Decoder&);
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/ChangeLog       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2021-11-19  Alex Christensen  <achristensen@webkit.org>
+
+        Implement extension-path variant of redirect action in WKContentRuleList
+        https://bugs.webkit.org/show_bug.cgi?id=233351
+
+        Reviewed by Tim Hatcher.
+
+        * NetworkProcess/NetworkContentRuleListManager.cpp:
+        (WebKit::NetworkContentRuleListManager::addContentRuleLists):
+        * NetworkProcess/NetworkContentRuleListManager.h:
+        * NetworkProcess/NetworkContentRuleListManager.messages.in:
+        * Shared/ServiceWorkerInitializationData.cpp:
+        (WebKit::ServiceWorkerInitializationData::decode):
+        * Shared/ServiceWorkerInitializationData.h:
+        * Shared/UserContentControllerParameters.cpp:
+        (WebKit::UserContentControllerParameters::decode):
+        * Shared/UserContentControllerParameters.h:
+        * Shared/WebCompiledContentRuleListData.cpp:
+        (WebKit::WebCompiledContentRuleListData::encode const):
+        (WebKit::WebCompiledContentRuleListData::decode):
+        * Shared/WebCompiledContentRuleListData.h:
+        (WebKit::WebCompiledContentRuleListData::WebCompiledContentRuleListData):
+        * UIProcess/API/APIContentRuleList.cpp:
+        (API::ContentRuleList::ContentRuleList):
+        (API::ContentRuleList::name const):
+        * UIProcess/API/APIContentRuleList.h:
+        * UIProcess/API/APIContentRuleListStore.cpp:
+        (API::createExtension):
+        * UIProcess/API/Cocoa/WKUserContentController.mm:
+        (-[WKUserContentController _addContentRuleList:extensionBaseURL:]):
+        * UIProcess/API/Cocoa/WKUserContentControllerPrivate.h:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::contentExtensionRules):
+        * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
+        (WebKit::WebUserContentControllerProxy::contentRuleListData const):
+        (WebKit::WebUserContentControllerProxy::addContentRuleList):
+        * UIProcess/UserContent/WebUserContentControllerProxy.h:
+        (WebKit::WebUserContentControllerProxy::addContentRuleList):
+        (WebKit::WebUserContentControllerProxy::contentExtensionRules):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::contentRuleListsFromIdentifier):
+        * WebProcess/UserContent/WebUserContentController.cpp:
+        (WebKit::WebUserContentController::addContentRuleLists):
+        * WebProcess/UserContent/WebUserContentController.h:
+        * WebProcess/UserContent/WebUserContentController.messages.in:
+
</ins><span class="cx"> 2021-11-19  Antoine Quint  <graouts@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         [Model] Use RefPtr across ARKitInlinePreviewModelPlayer when creating strong pointers
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkContentRuleListManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.cpp     2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.cpp        2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -66,15 +66,17 @@
</span><span class="cx">     m_networkProcess.parentProcessConnection()->send(Messages::NetworkProcessProxy::ContentExtensionRules { identifier }, 0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void NetworkContentRuleListManager::addContentRuleLists(UserContentControllerIdentifier identifier, Vector<std::pair<String, WebCompiledContentRuleListData>>&& contentRuleLists)
</del><ins>+void NetworkContentRuleListManager::addContentRuleLists(UserContentControllerIdentifier identifier, Vector<std::pair<WebCompiledContentRuleListData, URL>>&& contentRuleLists)
</ins><span class="cx"> {
</span><span class="cx">     auto& backend = *m_contentExtensionBackends.ensure(identifier, [] {
</span><span class="cx">         return makeUnique<WebCore::ContentExtensions::ContentExtensionsBackend>();
</span><span class="cx">     }).iterator->value;
</span><span class="cx"> 
</span><del>-    for (auto&& contentRuleList : contentRuleLists) {
-        auto compiledContentRuleList = WebCompiledContentRuleList::create(WTFMove(contentRuleList.second));
-        backend.addContentExtension(contentRuleList.first, WTFMove(compiledContentRuleList), ContentExtensions::ContentExtension::ShouldCompileCSS::No);
</del><ins>+    for (auto&& pair : contentRuleLists) {
+        auto&& contentRuleList = WTFMove(pair.first);
+        String identifier = contentRuleList.identifier;
+        auto compiledContentRuleList = WebCompiledContentRuleList::create(WTFMove(contentRuleList));
+        backend.addContentExtension(identifier, WTFMove(compiledContentRuleList), WTFMove(pair.second), ContentExtensions::ContentExtension::ShouldCompileCSS::No);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     auto pendingCallbacks = m_pendingCallbacks.take(identifier);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkContentRuleListManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h       2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h  2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     void contentExtensionsBackend(UserContentControllerIdentifier, BackendCallback&&);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void addContentRuleLists(UserContentControllerIdentifier, Vector<std::pair<String, WebCompiledContentRuleListData>>&&);
</del><ins>+    void addContentRuleLists(UserContentControllerIdentifier, Vector<std::pair<WebCompiledContentRuleListData, URL>>&&);
</ins><span class="cx">     void removeContentRuleList(UserContentControllerIdentifier, const String& name);
</span><span class="cx">     void removeAllContentRuleLists(UserContentControllerIdentifier);
</span><span class="cx">     void remove(UserContentControllerIdentifier);
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkContentRuleListManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.messages.in (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.messages.in     2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/NetworkProcess/NetworkContentRuleListManager.messages.in        2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> 
</span><span class="cx"> messages -> NetworkContentRuleListManager NotRefCounted {
</span><span class="cx">     Remove(WebKit::UserContentControllerIdentifier identifier)
</span><del>-    AddContentRuleLists(WebKit::UserContentControllerIdentifier identifier, Vector<std::pair<String, WebKit::WebCompiledContentRuleListData>> contentFilters)
</del><ins>+    AddContentRuleLists(WebKit::UserContentControllerIdentifier identifier, Vector<std::pair<WebKit::WebCompiledContentRuleListData, URL>> contentFilters)
</ins><span class="cx">     RemoveContentRuleList(WebKit::UserContentControllerIdentifier identifier, String name)
</span><span class="cx">     RemoveAllContentRuleLists(WebKit::UserContentControllerIdentifier identifier)
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitSharedServiceWorkerInitializationDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.cpp   2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.cpp      2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "Decoder.h"
</span><span class="cx"> #include "Encoder.h"
</span><span class="cx"> #include "WebCompiledContentRuleListData.h"
</span><ins>+#include <wtf/URL.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -49,7 +50,7 @@
</span><span class="cx">         return std::nullopt;
</span><span class="cx">     
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    std::optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
</del><ins>+    std::optional<Vector<std::pair<WebCompiledContentRuleListData, URL>>> contentRuleLists;
</ins><span class="cx">     decoder >> contentRuleLists;
</span><span class="cx">     if (!contentRuleLists)
</span><span class="cx">         return std::nullopt;
</span></span></pre></div>
<a id="trunkSourceWebKitSharedServiceWorkerInitializationDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.h     2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/Shared/ServiceWorkerInitializationData.h        2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> 
</span><span class="cx">     UserContentControllerIdentifier userContentControllerIdentifier;
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
</del><ins>+    Vector<std::pair<WebCompiledContentRuleListData, URL>> contentRuleLists;
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitSharedUserContentControllerParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp   2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/Shared/UserContentControllerParameters.cpp      2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">         return std::nullopt;
</span><span class="cx">     
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    std::optional<Vector<std::pair<String, WebCompiledContentRuleListData>>> contentRuleLists;
</del><ins>+    std::optional<Vector<std::pair<WebCompiledContentRuleListData, URL>>> contentRuleLists;
</ins><span class="cx">     decoder >> contentRuleLists;
</span><span class="cx">     if (!contentRuleLists)
</span><span class="cx">         return std::nullopt;
</span></span></pre></div>
<a id="trunkSourceWebKitSharedUserContentControllerParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/UserContentControllerParameters.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/UserContentControllerParameters.h     2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/Shared/UserContentControllerParameters.h        2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx">     Vector<WebUserStyleSheetData> userStyleSheets;
</span><span class="cx">     Vector<WebScriptMessageHandlerData> messageHandlers;
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleLists;
</del><ins>+    Vector<std::pair<WebCompiledContentRuleListData, URL>> contentRuleLists;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void encode(IPC::Encoder&) const;
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebCompiledContentRuleListDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.cpp       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx"> 
</span><span class="cx"> void WebCompiledContentRuleListData::encode(IPC::Encoder& encoder) const
</span><span class="cx"> {
</span><ins>+    encoder << identifier;
+
</ins><span class="cx">     SharedMemory::Handle handle;
</span><span class="cx">     data->createHandle(handle, SharedMemory::Protection::ReadOnly);
</span><span class="cx">     
</span><span class="lines">@@ -60,10 +62,17 @@
</span><span class="cx"> 
</span><span class="cx"> std::optional<WebCompiledContentRuleListData> WebCompiledContentRuleListData::decode(IPC::Decoder& decoder)
</span><span class="cx"> {
</span><ins>+    std::optional<String> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+
</ins><span class="cx">     SharedMemory::IPCHandle ipcHandle;
</span><span class="cx">     if (!decoder.decode(ipcHandle))
</span><span class="cx">         return std::nullopt;
</span><del>-    RefPtr<SharedMemory> data = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
</del><ins>+    auto data = SharedMemory::map(ipcHandle.handle, SharedMemory::Protection::ReadOnly);
+    if (!data)
+        return std::nullopt;
</ins><span class="cx"> 
</span><span class="cx">     std::optional<unsigned> conditionsApplyOnlyToDomainOffset;
</span><span class="cx">     decoder >> conditionsApplyOnlyToDomainOffset;
</span><span class="lines">@@ -111,7 +120,8 @@
</span><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><span class="cx">     return {{
</span><del>-        WTFMove(data),
</del><ins>+        WTFMove(*identifier),
+        data.releaseNonNull(),
</ins><span class="cx">         WTFMove(*conditionsApplyOnlyToDomainOffset),
</span><span class="cx">         WTFMove(*actionsOffset),
</span><span class="cx">         WTFMove(*actionsSize),
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebCompiledContentRuleListDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h      2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/Shared/WebCompiledContentRuleListData.h 2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -41,8 +41,9 @@
</span><span class="cx"> 
</span><span class="cx"> class WebCompiledContentRuleListData {
</span><span class="cx"> public:
</span><del>-    WebCompiledContentRuleListData(RefPtr<SharedMemory>&& data, unsigned conditionsApplyOnlyToDomainOffset, unsigned actionsOffset, unsigned actionsSize, unsigned filtersWithoutConditionsBytecodeOffset, unsigned filtersWithoutConditionsBytecodeSize, unsigned filtersWithConditionsBytecodeOffset, unsigned filtersWithConditionsBytecodeSize, unsigned topURLFiltersBytecodeOffset, unsigned topURLFiltersBytecodeSize)
-        : data(WTFMove(data))
</del><ins>+    WebCompiledContentRuleListData(String&& identifier, Ref<SharedMemory>&& data, unsigned conditionsApplyOnlyToDomainOffset, unsigned actionsOffset, unsigned actionsSize, unsigned filtersWithoutConditionsBytecodeOffset, unsigned filtersWithoutConditionsBytecodeSize, unsigned filtersWithConditionsBytecodeOffset, unsigned filtersWithConditionsBytecodeSize, unsigned topURLFiltersBytecodeOffset, unsigned topURLFiltersBytecodeSize)
+        : identifier(WTFMove(identifier))
+        , data(WTFMove(data))
</ins><span class="cx">         , conditionsApplyOnlyToDomainOffset(conditionsApplyOnlyToDomainOffset)
</span><span class="cx">         , actionsOffset(actionsOffset)
</span><span class="cx">         , actionsSize(actionsSize)
</span><span class="lines">@@ -58,7 +59,8 @@
</span><span class="cx">     void encode(IPC::Encoder&) const;
</span><span class="cx">     static std::optional<WebCompiledContentRuleListData> decode(IPC::Decoder&);
</span><span class="cx"> 
</span><del>-    RefPtr<SharedMemory> data;
</del><ins>+    String identifier;
+    Ref<SharedMemory> data;
</ins><span class="cx">     unsigned conditionsApplyOnlyToDomainOffset { 0 };
</span><span class="cx">     unsigned actionsOffset { 0 };
</span><span class="cx">     unsigned actionsSize { 0 };
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIContentRuleListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp 2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleList.cpp    2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -34,9 +34,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace API {
</span><span class="cx"> 
</span><del>-ContentRuleList::ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
-    : m_name(name)
-    , m_compiledRuleList(WTFMove(contentRuleList))
</del><ins>+ContentRuleList::ContentRuleList(Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
+    : m_compiledRuleList(WTFMove(contentRuleList))
</ins><span class="cx">     , m_mappedFile(WTFMove(mappedFile))
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -45,6 +44,11 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const WTF::String& ContentRuleList::name() const
+{
+    return m_compiledRuleList->data().identifier;
+}
+
</ins><span class="cx"> bool ContentRuleList::supportsRegularExpression(const WTF::String& regex)
</span><span class="cx"> {
</span><span class="cx">     using namespace WebCore::ContentExtensions;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIContentRuleListh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h   2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleList.h      2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -38,21 +38,20 @@
</span><span class="cx"> class ContentRuleList final : public ObjectImpl<Object::Type::ContentRuleList> {
</span><span class="cx"> public:
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    static Ref<ContentRuleList> create(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
</del><ins>+    static Ref<ContentRuleList> create(Ref<WebKit::WebCompiledContentRuleList>&& contentRuleList, WebKit::NetworkCache::Data&& mappedFile)
</ins><span class="cx">     {
</span><del>-        return adoptRef(*new ContentRuleList(name, WTFMove(contentRuleList), WTFMove(mappedFile)));
</del><ins>+        return adoptRef(*new ContentRuleList(WTFMove(contentRuleList), WTFMove(mappedFile)));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ContentRuleList(const WTF::String& name, Ref<WebKit::WebCompiledContentRuleList>&&, WebKit::NetworkCache::Data&&);
</del><ins>+    ContentRuleList(Ref<WebKit::WebCompiledContentRuleList>&&, WebKit::NetworkCache::Data&&);
</ins><span class="cx">     virtual ~ContentRuleList();
</span><span class="cx"> 
</span><del>-    const WTF::String& name() const { return m_name; }
</del><ins>+    const WTF::String& name() const;
</ins><span class="cx">     const WebKit::WebCompiledContentRuleList& compiledRuleList() const { return m_compiledRuleList.get(); }
</span><span class="cx">     
</span><span class="cx">     static bool supportsRegularExpression(const WTF::String&);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    WTF::String m_name;
</del><span class="cx">     Ref<WebKit::WebCompiledContentRuleList> m_compiledRuleList;
</span><span class="cx">     WebKit::NetworkCache::Data m_mappedFile;
</span><span class="cx"> #endif // ENABLE(CONTENT_EXTENSIONS)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIContentRuleListStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -408,11 +408,12 @@
</span><span class="cx"> 
</span><span class="cx">     // Content extensions are always compiled to files, and at this point the file
</span><span class="cx">     // has been already mapped, therefore tryCreateSharedMemory() cannot fail.
</span><del>-    ASSERT(sharedMemory);
</del><ins>+    RELEASE_ASSERT(sharedMemory);
</ins><span class="cx"> 
</span><span class="cx">     const size_t headerAndSourceSize = ContentRuleListFileHeaderSize + data.metaData.sourceSize;
</span><span class="cx">     auto compiledContentRuleListData = WebKit::WebCompiledContentRuleListData(
</span><del>-        WTFMove(sharedMemory),
</del><ins>+        WTF::String(identifier),
+        sharedMemory.releaseNonNull(),
</ins><span class="cx">         ConditionsApplyOnlyToDomainOffset,
</span><span class="cx">         headerAndSourceSize,
</span><span class="cx">         data.metaData.actionsSize,
</span><span class="lines">@@ -430,7 +431,7 @@
</span><span class="cx">         data.metaData.conditionedFiltersBytecodeSize
</span><span class="cx">     );
</span><span class="cx">     auto compiledContentRuleList = WebKit::WebCompiledContentRuleList::create(WTFMove(compiledContentRuleListData));
</span><del>-    return API::ContentRuleList::create(identifier, WTFMove(compiledContentRuleList), WTFMove(data.data));
</del><ins>+    return API::ContentRuleList::create(WTFMove(compiledContentRuleList), WTFMove(data.data));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static WTF::String getContentRuleListSourceFromMappedFile(const MappedData& mappedData)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUserContentControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.mm (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.mm       2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentController.mm  2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -285,6 +285,13 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_addContentRuleList:(WKContentRuleList *)contentRuleList extensionBaseURL:(NSURL *)extensionBaseURL
+{
+#if ENABLE(CONTENT_EXTENSIONS)
+    _userContentControllerProxy->addContentRuleList(*contentRuleList->_contentRuleList, extensionBaseURL);
+#endif
+}
+
</ins><span class="cx"> - (void)_removeUserContentFilter:(NSString *)userContentFilterName
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKUserContentControllerPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h 2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKUserContentControllerPrivate.h    2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> - (void)_addUserContentFilter:(_WKUserContentFilter *)userContentFilter WK_API_AVAILABLE(macos(10.11), ios(9.0));
</span><span class="cx"> - (void)_removeUserContentFilter:(NSString *)userContentFilterName WK_API_AVAILABLE(macos(10.11), ios(9.0));
</span><span class="cx"> - (void)_removeAllUserContentFilters WK_API_AVAILABLE(macos(10.11), ios(9.0));
</span><ins>+- (void)_addContentRuleList:(WKContentRuleList *)contentRuleList extensionBaseURL:(NSURL *)extensionBaseURL WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
</ins><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly, copy) NSArray<_WKUserStyleSheet *> *_userStyleSheets WK_API_AVAILABLE(macos(10.12), ios(10.0));
</span><span class="cx"> - (void)_addUserStyleSheet:(_WKUserStyleSheet *)userStyleSheet WK_API_AVAILABLE(macos(10.12), ios(10.0));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessNetworkNetworkProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -1388,8 +1388,8 @@
</span><span class="cx">         m_webUserContentControllerProxies.add(webUserContentControllerProxy);
</span><span class="cx">         webUserContentControllerProxy->addNetworkProcess(*this);
</span><span class="cx"> 
</span><del>-        auto rules = WTF::map(webUserContentControllerProxy->contentExtensionRules(), [](auto&& keyValue) -> std::pair<String, WebCompiledContentRuleListData> {
-            return std::make_pair(keyValue.value->name(), keyValue.value->compiledRuleList().data());
</del><ins>+        auto rules = WTF::map(webUserContentControllerProxy->contentExtensionRules(), [](auto&& keyValue) -> std::pair<WebCompiledContentRuleListData, URL> {
+            return { keyValue.value.first->compiledRuleList().data(), keyValue.value.second };
</ins><span class="cx">         });
</span><span class="cx">         send(Messages::NetworkContentRuleListManager::AddContentRuleLists { identifier, rules }, 0);
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessUserContentWebUserContentControllerProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp      2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp 2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -140,13 +140,11 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-Vector<std::pair<String, WebCompiledContentRuleListData>> WebUserContentControllerProxy::contentRuleListData() const
</del><ins>+Vector<std::pair<WebCompiledContentRuleListData, URL>> WebUserContentControllerProxy::contentRuleListData() const
</ins><span class="cx"> {
</span><del>-    Vector<std::pair<String, WebCompiledContentRuleListData>> data;
-    data.reserveInitialCapacity(m_contentRuleLists.size());
-    for (const auto& contentRuleList : m_contentRuleLists.values())
-        data.uncheckedAppend(std::make_pair(contentRuleList->name(), contentRuleList->compiledRuleList().data()));
-    return data;
</del><ins>+    return WTF::map(m_contentRuleLists, [](const auto& keyValue) -> std::pair<WebCompiledContentRuleListData, URL> {
+        return { keyValue.value.first->compiledRuleList().data(), keyValue.value.second };
+    });
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -362,17 +360,17 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-void WebUserContentControllerProxy::addContentRuleList(API::ContentRuleList& contentRuleList)
</del><ins>+void WebUserContentControllerProxy::addContentRuleList(API::ContentRuleList& contentRuleList, const WTF::URL& extensionBaseURL)
</ins><span class="cx"> {
</span><del>-    m_contentRuleLists.set(contentRuleList.name(), &contentRuleList);
</del><ins>+    m_contentRuleLists.set(contentRuleList.name(), std::make_pair(Ref { contentRuleList }, extensionBaseURL));
</ins><span class="cx"> 
</span><del>-    auto pair = std::make_pair(contentRuleList.name(), contentRuleList.compiledRuleList().data());
</del><ins>+    auto& data = contentRuleList.compiledRuleList().data();
</ins><span class="cx"> 
</span><span class="cx">     for (auto& process : m_processes)
</span><del>-        process.send(Messages::WebUserContentController::AddContentRuleLists({ pair }), identifier());
</del><ins>+        process.send(Messages::WebUserContentController::AddContentRuleLists({ { data, extensionBaseURL } }), identifier());
</ins><span class="cx"> 
</span><span class="cx">     for (auto& process : m_networkProcesses)
</span><del>-        process.send(Messages::NetworkContentRuleListManager::AddContentRuleLists { identifier(), { pair } }, 0);
</del><ins>+        process.send(Messages::NetworkContentRuleListManager::AddContentRuleLists { identifier(), { { data, extensionBaseURL } } }, 0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebUserContentControllerProxy::removeContentRuleList(const String& name)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessUserContentWebUserContentControllerProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h        2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h   2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/Ref.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><ins>+#include <wtf/URL.h>
+#include <wtf/URLHash.h>
</ins><span class="cx"> #include <wtf/WeakHashSet.h>
</span><span class="cx"> #include <wtf/text/StringHash.h>
</span><span class="cx"> 
</span><span class="lines">@@ -102,11 +104,11 @@
</span><span class="cx">     void addNetworkProcess(NetworkProcessProxy&);
</span><span class="cx">     void removeNetworkProcess(NetworkProcessProxy&);
</span><span class="cx"> 
</span><del>-    void addContentRuleList(API::ContentRuleList&);
</del><ins>+    void addContentRuleList(API::ContentRuleList&, const WTF::URL& extensionBaseURL = { });
</ins><span class="cx">     void removeContentRuleList(const String&);
</span><span class="cx">     void removeAllContentRuleLists();
</span><del>-    const HashMap<String, RefPtr<API::ContentRuleList>>& contentExtensionRules() { return m_contentRuleLists; }
-    Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleListData() const;
</del><ins>+    const HashMap<String, std::pair<Ref<API::ContentRuleList>, URL>>& contentExtensionRules() { return m_contentRuleLists; }
+    Vector<std::pair<WebCompiledContentRuleListData, URL>> contentRuleListData() const;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     UserContentControllerIdentifier identifier() const { return m_identifier; }
</span><span class="lines">@@ -130,7 +132,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><span class="cx">     WeakHashSet<NetworkProcessProxy> m_networkProcesses;
</span><del>-    HashMap<String, RefPtr<API::ContentRuleList>> m_contentRuleLists;
</del><ins>+    HashMap<String, std::pair<Ref<API::ContentRuleList>, URL>> m_contentRuleLists;
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp        2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp   2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -1983,7 +1983,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-static Vector<std::pair<String, WebCompiledContentRuleListData>> contentRuleListsFromIdentifier(const std::optional<UserContentControllerIdentifier>& userContentControllerIdentifier)
</del><ins>+static Vector<std::pair<WebCompiledContentRuleListData, URL>> contentRuleListsFromIdentifier(const std::optional<UserContentControllerIdentifier>& userContentControllerIdentifier)
</ins><span class="cx"> {
</span><span class="cx">     if (!userContentControllerIdentifier) {
</span><span class="cx">         ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessUserContentWebUserContentControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp  2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.cpp     2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -385,12 +385,14 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-void WebUserContentController::addContentRuleLists(Vector<std::pair<String, WebCompiledContentRuleListData>>&& contentRuleLists)
</del><ins>+void WebUserContentController::addContentRuleLists(Vector<std::pair<WebCompiledContentRuleListData, URL>>&& contentRuleLists)
</ins><span class="cx"> {
</span><del>-    for (auto&& contentRuleList : contentRuleLists) {
-        auto compiledContentRuleList = WebCompiledContentRuleList::create(WTFMove(contentRuleList.second));
</del><ins>+    for (auto&& pair : contentRuleLists) {
+        auto&& contentRuleList = WTFMove(pair.first);
+        String identifier = contentRuleList.identifier;
+        auto compiledContentRuleList = WebCompiledContentRuleList::create(WTFMove(contentRuleList));
</ins><span class="cx"> 
</span><del>-        m_contentExtensionBackend.addContentExtension(contentRuleList.first, WTFMove(compiledContentRuleList));
</del><ins>+        m_contentExtensionBackend.addContentExtension(identifier, WTFMove(compiledContentRuleList), WTFMove(pair.second));
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessUserContentWebUserContentControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.h (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.h    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.h       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">     void addUserStyleSheets(const Vector<WebUserStyleSheetData>&);
</span><span class="cx">     void addUserScriptMessageHandlers(const Vector<WebScriptMessageHandlerData>&);
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    void addContentRuleLists(Vector<std::pair<String, WebCompiledContentRuleListData>>&&);
</del><ins>+    void addContentRuleLists(Vector<std::pair<WebCompiledContentRuleListData, URL>>&&);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessUserContentWebUserContentControllermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.messages.in (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.messages.in  2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Source/WebKit/WebProcess/UserContent/WebUserContentController.messages.in     2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx">     RemoveAllUserScriptMessageHandlers();
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span><del>-    AddContentRuleLists(Vector<std::pair<String, WebKit::WebCompiledContentRuleListData>> contentFilters);
</del><ins>+    AddContentRuleLists(Vector<std::pair<WebKit::WebCompiledContentRuleListData, URL>> contentFilters);
</ins><span class="cx">     RemoveContentRuleList(String name);
</span><span class="cx">     RemoveAllContentRuleLists();
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Tools/ChangeLog       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2021-11-19  Alex Christensen  <achristensen@webkit.org>
+
+        Implement extension-path variant of redirect action in WKContentRuleList
+        https://bugs.webkit.org/show_bug.cgi?id=233351
+
+        Reviewed by Tim Hatcher.
+
+        * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
+        (TestWebKitAPI::makeBackend):
+        (TestWebKitAPI::TEST_F):
+        * TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm:
+        (TEST_F):
+
</ins><span class="cx"> 2021-11-19  J Pascoe  <j_pascoe@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [WebAuthn] Add headers for [_WKWebAuthenticationPanel makeCredentialWithClientDataHash] and [_WKWebAuthenticationPanel getAssertionWithClientDataHash]
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoreContentExtensionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp    2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp       2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -201,7 +201,7 @@
</span><span class="cx">     AtomString::init();
</span><span class="cx">     auto extension = InMemoryCompiledContentExtension::create(json);
</span><span class="cx">     ContentExtensions::ContentExtensionsBackend backend;
</span><del>-    backend.addContentExtension("testFilter", WTFMove(extension));
</del><ins>+    backend.addContentExtension("testFilter", WTFMove(extension), { });
</ins><span class="cx">     return backend;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -848,8 +848,8 @@
</span><span class="cx">     auto extension1 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"block_load\"}}]");
</span><span class="cx">     auto extension2 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"block_cookies\"}}]");
</span><span class="cx">     ContentExtensions::ContentExtensionsBackend backend;
</span><del>-    backend.addContentExtension("testFilter1", WTFMove(extension1));
-    backend.addContentExtension("testFilter2", WTFMove(extension2));
</del><ins>+    backend.addContentExtension("testFilter1", WTFMove(extension1), { });
+    backend.addContentExtension("testFilter2", WTFMove(extension2), { });
</ins><span class="cx">     
</span><span class="cx">     testRequest(backend, mainDocumentRequest("http://webkit.org"), { }, 2);
</span><span class="cx">     testRequest(backend, mainDocumentRequest("http://webkit.org/block_load.html"), { variantIndex<ContentExtensions::BlockLoadAction> }, 2);
</span><span class="lines">@@ -862,8 +862,8 @@
</span><span class="cx">     auto ignoreExtension2 = InMemoryCompiledContentExtension::create("[{\"action\":{\"type\":\"block-cookies\"},\"trigger\":{\"url-filter\":\"block_cookies\"}},"
</span><span class="cx">         "{\"action\":{\"type\":\"ignore-previous-rules\"},\"trigger\":{\"url-filter\":\"ignore2\"}}]");
</span><span class="cx">     ContentExtensions::ContentExtensionsBackend backendWithIgnore;
</span><del>-    backendWithIgnore.addContentExtension("testFilter1", WTFMove(ignoreExtension1));
-    backendWithIgnore.addContentExtension("testFilter2", WTFMove(ignoreExtension2));
</del><ins>+    backendWithIgnore.addContentExtension("testFilter1", WTFMove(ignoreExtension1), { });
+    backendWithIgnore.addContentExtension("testFilter2", WTFMove(ignoreExtension2), { });
</ins><span class="cx"> 
</span><span class="cx">     testRequest(backendWithIgnore, mainDocumentRequest("http://webkit.org"), { }, 2);
</span><span class="cx">     testRequest(backendWithIgnore, mainDocumentRequest("http://webkit.org/block_load/ignore1.html"), { }, 1);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaWKContentExtensionStoremm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm (286083 => 286084)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm   2021-11-19 23:19:44 UTC (rev 286083)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentExtensionStore.mm      2021-11-19 23:52:41 UTC (rev 286084)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import "TestURLSchemeHandler.h"
</span><span class="cx"> #import <WebKit/WKContentRuleList.h>
</span><span class="cx"> #import <WebKit/WKContentRuleListStorePrivate.h>
</span><ins>+#import <WebKit/WKUserContentControllerPrivate.h>
</ins><span class="cx"> #import <WebKit/WKWebpagePreferencesPrivate.h>
</span><span class="cx"> #import <WebKit/_WKUserContentExtensionStore.h>
</span><span class="cx"> #import <WebKit/_WKUserContentFilter.h>
</span><span class="lines">@@ -751,3 +752,40 @@
</span><span class="cx">     EXPECT_FALSE(getRedirectResult(DelegateAction::AllowNone));
</span><span class="cx">     EXPECT_TRUE(getRedirectResult(DelegateAction::AllowTestHost));
</span><span class="cx"> }
</span><ins>+
+TEST_F(WKContentRuleListStoreTest, ExtensionPath)
+{
+    auto list = compileContentRuleList(R"JSON(
+        [ {
+            "action": { "type": "redirect", "redirect": {
+                "extension-path": "/redirected-to-extension?no-query#no-fragment"
+            } },
+            "trigger": { "url-filter": "main.html" }
+        } ]
+    )JSON");
+
+    __block RetainPtr<NSURL> redirectedURL;
+    auto handler = adoptNS([TestURLSchemeHandler new]);
+    handler.get().startURLSchemeTaskHandler = ^(WKWebView *, id <WKURLSchemeTask> task) {
+        redirectedURL = task.request.URL;
+        respond(task, "");
+    };
+
+    auto delegate = adoptNS([TestNavigationDelegate new]);
+    delegate.get().decidePolicyForNavigationActionWithPreferences = ^(WKNavigationAction *, WKWebpagePreferences *preferences, void (^decisionHandler)(WKNavigationActionPolicy, WKWebpagePreferences *)) {
+        preferences._activeContentRuleListActionPatterns = nil;
+        decisionHandler(WKNavigationActionPolicyAllow, preferences);
+    };
+
+    auto configuration = adoptNS([WKWebViewConfiguration new]);
+    [[configuration userContentController] _addContentRuleList:list.get() extensionBaseURL:[NSURL URLWithString:@"extension-scheme://extension-host/"]];
+    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"testscheme"];
+    [configuration setURLSchemeHandler:handler.get() forURLScheme:@"extension-scheme"];
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSZeroRect configuration:configuration.get()]);
+    webView.get().navigationDelegate = delegate.get();
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"testscheme://testhost/main.html"]]];
+    while (!redirectedURL)
+        TestWebKitAPI::Util::spinRunLoop();
+    EXPECT_WK_STREQ([redirectedURL absoluteString], "extension-scheme://extension-host/redirected-to-extension%3Fno-query%23no-fragment");
+}
</ins></span></pre>
</div>
</div>

</body>
</html>