<!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>[245401] 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/245401">245401</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2019-05-16 11:08:30 -0700 (Thu, 16 May 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add SPI to set a list of hosts to which to send custom header fields cross-origin
https://bugs.webkit.org/show_bug.cgi?id=197397

Patch by Alex Christensen <achristensen@webkit.org> on 2019-05-16
Reviewed by Geoff Garen.

Source/WebCore:

In <a href="http://trac.webkit.org/projects/webkit/changeset/223001">r223001</a> I added the ability to send custom headers, but with a restriction that they will not be sent except to the origin of the main document.
We need the ability to specify what origins to send these headers to even if they are not first party requests.
We get this information in a list of strings which are the hosts to send the headers to.  Some of the strings have an asterisk at the beginning,
indicating that the headers are to be sent to all subdomains.

I repurposed some ObjC SPI that was never adopted, but I keep testing the C API that was to verify no regression.
I also added some new API tests for the new behavior.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* loader/CustomHeaderFields.cpp: Added.
(WebCore::CustomHeaderFields::thirdPartyDomainsMatch const):
* loader/CustomHeaderFields.h: Added.
(WebCore::CustomHeaderFields::encode const):
(WebCore::CustomHeaderFields::decode):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::setCustomHeaderFields): Deleted.
* loader/DocumentLoader.h:
(WebCore::DocumentLoader::setCustomHeaderFields):
(WebCore::DocumentLoader::customHeaderFields const):
(WebCore::DocumentLoader::customHeaderFields): Deleted.
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):

Source/WebKit:

* Shared/API/APIObject.h:
* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* Shared/WebsitePoliciesData.cpp:
(WebKit::WebsitePoliciesData::decode):
* Shared/WebsitePoliciesData.h:
* SourcesCocoa.txt:
* UIProcess/API/APICustomHeaderFields.h: Added.
* UIProcess/API/APIWebsitePolicies.cpp:
(API::WebsitePolicies::WebsitePolicies):
(API::WebsitePolicies::copy const):
(API::WebsitePolicies::data):
* UIProcess/API/APIWebsitePolicies.h:
* UIProcess/API/C/WKWebsitePolicies.cpp:
(WKWebsitePoliciesCopyCustomHeaderFields):
(WKWebsitePoliciesSetCustomHeaderFields):
* UIProcess/API/Cocoa/WKWebpagePreferences.mm:
(-[WKWebpagePreferences _customHeaderFields]):
(-[WKWebpagePreferences _setCustomHeaderFields:]):
* UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
* UIProcess/API/Cocoa/_WKCustomHeaderFields.h: Added.
* UIProcess/API/Cocoa/_WKCustomHeaderFields.mm: Added.
(-[_WKCustomHeaderFields init]):
(-[_WKCustomHeaderFields dealloc]):
(-[_WKCustomHeaderFields fields]):
(-[_WKCustomHeaderFields setFields:]):
(-[_WKCustomHeaderFields thirdPartyDomains]):
(-[_WKCustomHeaderFields setThirdPartyDomains:]):
(-[_WKCustomHeaderFields _apiObject]):
* UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h: Added.
* UIProcess/API/Cocoa/_WKWebsitePolicies.h:
* UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
(-[_WKWebsitePolicies customHeaderFields]): Deleted.
(-[_WKWebsitePolicies setCustomHeaderFields:]): Deleted.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::takeFocus):
(WebKit::WebViewImpl::accessibilityAttributeValue):
* WebKit.xcodeproj/project.pbxproj:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
(TEST):
(expectLegacyHeaders):
(expectHeaders):
(-[CustomHeaderFieldsDelegate webView:decidePolicyForNavigationAction:preferences:decisionHandler:]):
(-[CustomHeaderFieldsDelegate webView:startURLSchemeTask:]):
(-[CustomHeaderFieldsDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreHeaderscmake">trunk/Source/WebCore/Headers.cmake</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoadercpp">trunk/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoaderh">trunk/Source/WebCore/loader/DocumentLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitSharedAPIAPIObjecth">trunk/Source/WebKit/Shared/API/APIObject.h</a></li>
<li><a href="#trunkSourceWebKitSharedCocoaAPIObjectmm">trunk/Source/WebKit/Shared/Cocoa/APIObject.mm</a></li>
<li><a href="#trunkSourceWebKitSharedWebsitePoliciesDatacpp">trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebsitePoliciesDatah">trunk/Source/WebKit/Shared/WebsitePoliciesData.h</a></li>
<li><a href="#trunkSourceWebKitSourcesCocoatxt">trunk/Source/WebKit/SourcesCocoa.txt</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIWebsitePoliciescpp">trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIWebsitePoliciesh">trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKWebsitePoliciescpp">trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebpagePreferencesmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebpagePreferencesPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKWebsitePoliciesmm">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm</a></li>
<li><a href="#trunkSourceWebKitWebKitxcodeprojprojectpbxproj">trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaWebsitePoliciesmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreloaderCustomHeaderFieldscpp">trunk/Source/WebCore/loader/CustomHeaderFields.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderCustomHeaderFieldsh">trunk/Source/WebCore/loader/CustomHeaderFields.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPICustomHeaderFieldsh">trunk/Source/WebKit/UIProcess/API/APICustomHeaderFields.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKCustomHeaderFieldsh">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKCustomHeaderFieldsmm">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKCustomHeaderFieldsInternalh">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/ChangeLog      2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2019-05-16  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to set a list of hosts to which to send custom header fields cross-origin
+        https://bugs.webkit.org/show_bug.cgi?id=197397
+
+        Reviewed by Geoff Garen.
+
+        In r223001 I added the ability to send custom headers, but with a restriction that they will not be sent except to the origin of the main document.
+        We need the ability to specify what origins to send these headers to even if they are not first party requests.
+        We get this information in a list of strings which are the hosts to send the headers to.  Some of the strings have an asterisk at the beginning,
+        indicating that the headers are to be sent to all subdomains.
+
+        I repurposed some ObjC SPI that was never adopted, but I keep testing the C API that was to verify no regression.
+        I also added some new API tests for the new behavior.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/CustomHeaderFields.cpp: Added.
+        (WebCore::CustomHeaderFields::thirdPartyDomainsMatch const):
+        * loader/CustomHeaderFields.h: Added.
+        (WebCore::CustomHeaderFields::encode const):
+        (WebCore::CustomHeaderFields::decode):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::setCustomHeaderFields): Deleted.
+        * loader/DocumentLoader.h:
+        (WebCore::DocumentLoader::setCustomHeaderFields):
+        (WebCore::DocumentLoader::customHeaderFields const):
+        (WebCore::DocumentLoader::customHeaderFields): Deleted.
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestResource):
+
</ins><span class="cx"> 2019-05-16  Ali Juma  <ajuma@chromium.org>
</span><span class="cx"> 
</span><span class="cx">         [IntersectionObserver] Regression: No initial observation when nothing else triggers rendering
</span></span></pre></div>
<a id="trunkSourceWebCoreHeaderscmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Headers.cmake (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Headers.cmake       2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/Headers.cmake  2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -654,6 +654,7 @@
</span><span class="cx">     loader/CookieJar.h
</span><span class="cx">     loader/CrossOriginAccessControl.h
</span><span class="cx">     loader/CrossOriginPreflightResultCache.h
</span><ins>+    loader/CustomHeaderFields.h
</ins><span class="cx">     loader/DocumentLoader.h
</span><span class="cx">     loader/DocumentWriter.h
</span><span class="cx">     loader/EmptyClients.h
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/Sources.txt    2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -1364,6 +1364,7 @@
</span><span class="cx"> loader/CrossOriginAccessControl.cpp
</span><span class="cx"> loader/CrossOriginPreflightChecker.cpp
</span><span class="cx"> loader/CrossOriginPreflightResultCache.cpp
</span><ins>+loader/CustomHeaderFields.cpp @no-unify
</ins><span class="cx"> loader/DocumentLoader.cpp
</span><span class="cx"> loader/DocumentThreadableLoader.cpp
</span><span class="cx"> loader/DocumentWriter.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -1872,6 +1872,7 @@
</span><span class="cx">          5C4304B0191AC908000E2BC0 /* EXTShaderTextureLOD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4304AD191AC908000E2BC0 /* EXTShaderTextureLOD.cpp */; };
</span><span class="cx">          5C4304B1191AC908000E2BC0 /* EXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304AE191AC908000E2BC0 /* EXTShaderTextureLOD.h */; };
</span><span class="cx">          5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C4304B4191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h */; };
</span><ins>+               5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           5C7C88D81D0F1F4A009D2F6D /* SocketProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7C88D71D0F1F2B009D2F6D /* SocketProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5C9C2DB52241A67B00996B0B /* ContentRuleListResults.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9C2DB32241A67300996B0B /* ContentRuleListResults.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5C9EF2F321F06190003BDC56 /* StorageSessionProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C9EF2F221F06171003BDC56 /* StorageSessionProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -1878,6 +1879,7 @@
</span><span class="cx">          5CA1DEC61F71F1C700E71BD3 /* HTTPHeaderField.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CA1DEC41F71E68700E71BD3 /* HTTPHeaderField.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5CB37FFF1C62D2A100F20188 /* ScrollAnimatorMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB37FFD1C62D27800F20188 /* ScrollAnimatorMock.h */; };
</span><span class="cx">          5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC8DAB1AAA302200E1C803 /* MediaAccessibilitySoftLink.h */; };
</span><ins>+               5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */; };
</ins><span class="cx">           5CD9F5661AA0F73C00DA45FF /* DFABytecode.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305D1AA0F6A90029C816 /* DFABytecode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5CD9F5671AA0F74200DA45FF /* DFABytecodeCompiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C39305F1AA0F6A90029C816 /* DFABytecodeCompiler.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5CD9F5681AA0F74600DA45FF /* DFABytecodeInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C3930611AA0F6A90029C816 /* DFABytecodeInterpreter.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -8832,6 +8834,8 @@
</span><span class="cx">          5C5381B11D87D45700E2EBE6 /* URLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLSearchParams.h; sourceTree = "<group>"; };
</span><span class="cx">          5C5381B31D87E08100E2EBE6 /* JSURLSearchParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSURLSearchParams.cpp; sourceTree = "<group>"; };
</span><span class="cx">          5C5381B41D87E08100E2EBE6 /* JSURLSearchParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSURLSearchParams.h; sourceTree = "<group>"; };
</span><ins>+               5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomHeaderFields.h; sourceTree = "<group>"; };
+               5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CustomHeaderFields.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           5C668E641E7C6C3500D32B3B /* SocketStreamHandleImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketStreamHandleImpl.cpp; sourceTree = "<group>"; };
</span><span class="cx">          5C688AA01D380509000B54FA /* ThreadableWebSocketChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ThreadableWebSocketChannel.cpp; sourceTree = "<group>"; };
</span><span class="cx">          5C688AA21D38126F000B54FA /* SocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SocketProvider.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -25011,6 +25015,8 @@
</span><span class="cx">                          41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */,
</span><span class="cx">                          E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */,
</span><span class="cx">                          E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */,
</span><ins>+                               5C5D2386227A077C000B9BDA /* CustomHeaderFields.cpp */,
+                               5C5D2383227A063A000B9BDA /* CustomHeaderFields.h */,
</ins><span class="cx">                           93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */,
</span><span class="cx">                          656D371E0ADBA5DE00A4554D /* DocumentLoader.h */,
</span><span class="cx">                          0B9056150F2578BE0095FF6A /* DocumentThreadableLoader.cpp */,
</span><span class="lines">@@ -28685,6 +28691,7 @@
</span><span class="cx">                          93D437A01D57B19A00AB85EA /* CustomElementReactionQueue.h in Headers */,
</span><span class="cx">                          9BD4E91B1C462CFC005065BC /* CustomElementRegistry.h in Headers */,
</span><span class="cx">                          62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */,
</span><ins>+                               5C5D2385227A0652000B9BDA /* CustomHeaderFields.h in Headers */,
</ins><span class="cx">                           4B1E13E721790D660042CF98 /* CustomPaintCanvas.h in Headers */,
</span><span class="cx">                          4B7AE4932177B56F00C59959 /* CustomPaintImage.h in Headers */,
</span><span class="cx">                          A8CB413E0E8633FD0032C4F0 /* DashArray.h in Headers */,
</span><span class="lines">@@ -32609,6 +32616,7 @@
</span><span class="cx">                          07AFF4231EFB144900B545B3 /* CoreAudioCaptureSourceIOS.mm in Sources */,
</span><span class="cx">                          46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */,
</span><span class="cx">                          1ABA76CA11D20E50004C201C /* CSSPropertyNames.cpp in Sources */,
</span><ins>+                               5CBD59592280E926002B22AA /* CustomHeaderFields.cpp in Sources */,
</ins><span class="cx">                           BE23480C18A9870B00E4B6E8 /* DataCue.cpp in Sources */,
</span><span class="cx">                          4463CF682212FA68001A8577 /* DataDetectorsCoreSoftLink.mm in Sources */,
</span><span class="cx">                          E58B45BB20AD07DD00991025 /* DataListButtonElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderCustomHeaderFieldscpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/CustomHeaderFields.cpp (0 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CustomHeaderFields.cpp                               (rev 0)
+++ trunk/Source/WebCore/loader/CustomHeaderFields.cpp  2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CustomHeaderFields.h"
+
+#include "HTTPHeaderField.h"
+#include "RegistrableDomain.h"
+
+namespace WebCore {
+
+bool CustomHeaderFields::thirdPartyDomainsMatch(const URL& url) const
+{
+    if (thirdPartyDomains.isEmpty())
+        return false;
+
+    auto registrableDomainLength = RegistrableDomain(url).string().length();
+    for (const auto& domainOrPattern : thirdPartyDomains) {
+        if (domainOrPattern == url.host())
+            return true;
+        if (domainOrPattern.startsWith("*.")
+            && url.host().endsWith(StringView(domainOrPattern).substring(1))
+            && domainOrPattern.length() > registrableDomainLength)
+            return true;
+    }
+
+    return false;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderCustomHeaderFieldsh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/CustomHeaderFields.h (0 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CustomHeaderFields.h                         (rev 0)
+++ trunk/Source/WebCore/loader/CustomHeaderFields.h    2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "HTTPHeaderField.h"
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct WEBCORE_EXPORT CustomHeaderFields {
+    Vector<HTTPHeaderField> fields;
+    Vector<String> thirdPartyDomains;
+
+    bool thirdPartyDomainsMatch(const URL&) const;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static Optional<CustomHeaderFields> decode(Decoder&);
+};
+
+template<class Encoder>
+void CustomHeaderFields::encode(Encoder& encoder) const
+{
+    encoder << fields;
+    encoder << thirdPartyDomains;
+}
+
+template<class Decoder>
+Optional<CustomHeaderFields> CustomHeaderFields::decode(Decoder& decoder)
+{
+    Optional<Vector<HTTPHeaderField>> fields;
+    decoder >> fields;
+    if (!fields)
+        return WTF::nullopt;
+    
+    Optional<Vector<String>> thirdPartyDomains;
+    decoder >> thirdPartyDomains;
+    if (!thirdPartyDomains)
+        return WTF::nullopt;
+    
+    return {{ WTFMove(*fields), WTFMove(*thirdPartyDomains) }};
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp   2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp      2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include "CachedResourceLoader.h"
</span><span class="cx"> #include "ContentExtensionError.h"
</span><span class="cx"> #include "ContentSecurityPolicy.h"
</span><ins>+#include "CustomHeaderFields.h"
</ins><span class="cx"> #include "DOMWindow.h"
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "DocumentParser.h"
</span><span class="lines">@@ -53,7 +54,6 @@
</span><span class="cx"> #include "FrameTree.h"
</span><span class="cx"> #include "HTMLFormElement.h"
</span><span class="cx"> #include "HTMLFrameOwnerElement.h"
</span><del>-#include "HTTPHeaderField.h"
</del><span class="cx"> #include "HTTPHeaderNames.h"
</span><span class="cx"> #include "HistoryItem.h"
</span><span class="cx"> #include "HistoryController.h"
</span><span class="lines">@@ -1322,11 +1322,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void DocumentLoader::setCustomHeaderFields(Vector<HTTPHeaderField>&& fields)
-{
-    m_customHeaderFields = WTFMove(fields);
-}
-
</del><span class="cx"> bool DocumentLoader::isLoadingInAPISense() const
</span><span class="cx"> {
</span><span class="cx">     // Once a frame has loaded, we no longer need to consider subresources,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.h (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.h     2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/loader/DocumentLoader.h        2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -76,10 +76,10 @@
</span><span class="cx"> class CachedRawResource;
</span><span class="cx"> class CachedResourceLoader;
</span><span class="cx"> class ContentFilter;
</span><ins>+struct CustomHeaderFields;
</ins><span class="cx"> class FormState;
</span><span class="cx"> class Frame;
</span><span class="cx"> class FrameLoader;
</span><del>-class HTTPHeaderField;
</del><span class="cx"> class IconLoader;
</span><span class="cx"> class Page;
</span><span class="cx"> class PreviewConverter;
</span><span class="lines">@@ -371,8 +371,8 @@
</span><span class="cx">     void finishedLoadingApplicationManifest(ApplicationManifestLoader&);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    WEBCORE_EXPORT void setCustomHeaderFields(Vector<HTTPHeaderField>&& fields);
-    const Vector<HTTPHeaderField>& customHeaderFields() { return m_customHeaderFields; }
</del><ins>+    void setCustomHeaderFields(Vector<CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); }
+    const Vector<CustomHeaderFields>& customHeaderFields() const { return m_customHeaderFields; }
</ins><span class="cx"> 
</span><span class="cx">     void setAllowsWebArchiveForMainFrame(bool allowsWebArchiveForMainFrame) { m_allowsWebArchiveForMainFrame = allowsWebArchiveForMainFrame; }
</span><span class="cx">     bool allowsWebArchiveForMainFrame() const { return m_allowsWebArchiveForMainFrame; }
</span><span class="lines">@@ -564,7 +564,7 @@
</span><span class="cx">     HashMap<std::unique_ptr<ApplicationManifestLoader>, uint64_t> m_applicationManifestLoaders;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    Vector<HTTPHeaderField> m_customHeaderFields;
</del><ins>+    Vector<CustomHeaderFields> m_customHeaderFields;
</ins><span class="cx">     
</span><span class="cx">     bool m_subresourceLoadersArePageCacheAcceptable { false };
</span><span class="cx">     ShouldOpenExternalURLsPolicy m_shouldOpenExternalURLsPolicy { ShouldOpenExternalURLsPolicy::ShouldNotAllow };
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp       2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp  2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> #include "ContentRuleListResults.h"
</span><span class="cx"> #include "ContentSecurityPolicy.h"
</span><span class="cx"> #include "CrossOriginAccessControl.h"
</span><ins>+#include "CustomHeaderFields.h"
</ins><span class="cx"> #include "DOMWindow.h"
</span><span class="cx"> #include "DiagnosticLoggingClient.h"
</span><span class="cx"> #include "DiagnosticLoggingKeys.h"
</span><span class="lines">@@ -858,9 +859,11 @@
</span><span class="cx">             sameOriginRequest = document()->topDocument().securityOrigin().isSameSchemeHostPort(requestedOrigin.get())
</span><span class="cx">                 && document()->securityOrigin().isSameSchemeHostPort(requestedOrigin.get());
</span><span class="cx">         }
</span><del>-        if (sameOriginRequest) {
-            for (auto& field : m_documentLoader->customHeaderFields())
-                request.resourceRequest().setHTTPHeaderField(field.name(), field.value());
</del><ins>+        for (auto& fields : m_documentLoader->customHeaderFields()) {
+            if (sameOriginRequest || fields.thirdPartyDomainsMatch(url)) {
+                for (auto& field : fields.fields)
+                    request.resourceRequest().setHTTPHeaderField(field.name(), field.value());
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/ChangeLog       2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2019-05-16  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to set a list of hosts to which to send custom header fields cross-origin
+        https://bugs.webkit.org/show_bug.cgi?id=197397
+
+        Reviewed by Geoff Garen.
+
+        * Shared/API/APIObject.h:
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject):
+        * Shared/WebsitePoliciesData.cpp:
+        (WebKit::WebsitePoliciesData::decode):
+        * Shared/WebsitePoliciesData.h:
+        * SourcesCocoa.txt:
+        * UIProcess/API/APICustomHeaderFields.h: Added.
+        * UIProcess/API/APIWebsitePolicies.cpp:
+        (API::WebsitePolicies::WebsitePolicies):
+        (API::WebsitePolicies::copy const):
+        (API::WebsitePolicies::data):
+        * UIProcess/API/APIWebsitePolicies.h:
+        * UIProcess/API/C/WKWebsitePolicies.cpp:
+        (WKWebsitePoliciesCopyCustomHeaderFields):
+        (WKWebsitePoliciesSetCustomHeaderFields):
+        * UIProcess/API/Cocoa/WKWebpagePreferences.mm:
+        (-[WKWebpagePreferences _customHeaderFields]):
+        (-[WKWebpagePreferences _setCustomHeaderFields:]):
+        * UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h:
+        * UIProcess/API/Cocoa/_WKCustomHeaderFields.h: Added.
+        * UIProcess/API/Cocoa/_WKCustomHeaderFields.mm: Added.
+        (-[_WKCustomHeaderFields init]):
+        (-[_WKCustomHeaderFields dealloc]):
+        (-[_WKCustomHeaderFields fields]):
+        (-[_WKCustomHeaderFields setFields:]):
+        (-[_WKCustomHeaderFields thirdPartyDomains]):
+        (-[_WKCustomHeaderFields setThirdPartyDomains:]):
+        (-[_WKCustomHeaderFields _apiObject]):
+        * UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h: Added.
+        * UIProcess/API/Cocoa/_WKWebsitePolicies.h:
+        * UIProcess/API/Cocoa/_WKWebsitePolicies.mm:
+        (-[_WKWebsitePolicies customHeaderFields]): Deleted.
+        (-[_WKWebsitePolicies setCustomHeaderFields:]): Deleted.
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::takeFocus):
+        (WebKit::WebViewImpl::accessibilityAttributeValue):
+        * WebKit.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2019-05-16  Ryan Walklin  <ryan@testtoast.com>
</span><span class="cx"> 
</span><span class="cx">         [WPE] Rendering on a HiDPI display looks scaled up instead of rendered at 2x
</span></span></pre></div>
<a id="trunkSourceWebKitSharedAPIAPIObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/API/APIObject.h (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/API/APIObject.h       2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/Shared/API/APIObject.h  2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -111,6 +111,7 @@
</span><span class="cx">         ContentRuleListStore,
</span><span class="cx">         ContextMenuListener,
</span><span class="cx">         CookieManager,
</span><ins>+        CustomHeaderFields,
</ins><span class="cx">         InternalDebugFeature,
</span><span class="cx">         Download,
</span><span class="cx">         ExperimentalFeature,
</span></span></pre></div>
<a id="trunkSourceWebKitSharedCocoaAPIObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/Cocoa/APIObject.mm (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/Cocoa/APIObject.mm    2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/Shared/Cocoa/APIObject.mm       2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -70,6 +70,7 @@
</span><span class="cx"> #import "_WKAttachmentInternal.h"
</span><span class="cx"> #import "_WKAutomationSessionInternal.h"
</span><span class="cx"> #import "_WKContentRuleListActionInternal.h"
</span><ins>+#import "_WKCustomHeaderFieldsInternal.h"
</ins><span class="cx"> #import "_WKDownloadInternal.h"
</span><span class="cx"> #import "_WKExperimentalFeatureInternal.h"
</span><span class="cx"> #import "_WKFrameHandleInternal.h"
</span><span class="lines">@@ -312,6 +313,10 @@
</span><span class="cx">         wrapper = [WKContentRuleListStore alloc];
</span><span class="cx">         break;
</span><span class="cx"> 
</span><ins>+    case Type::CustomHeaderFields:
+        wrapper = [_WKCustomHeaderFields alloc];
+        break;
+
</ins><span class="cx">     case Type::UserContentWorld:
</span><span class="cx">         wrapper = [_WKUserContentWorld alloc];
</span><span class="cx">         break;
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebsitePoliciesDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp       2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp  2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "ArgumentCoders.h"
</span><span class="cx"> #include "WebProcess.h"
</span><ins>+#include <WebCore/CustomHeaderFields.h>
</ins><span class="cx"> #include <WebCore/DocumentLoader.h>
</span><span class="cx"> #include <WebCore/Frame.h>
</span><span class="cx"> #include <WebCore/Page.h>
</span><span class="lines">@@ -77,7 +78,7 @@
</span><span class="cx">     if (!allowedAutoplayQuirks)
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx">     
</span><del>-    Optional<Vector<WebCore::HTTPHeaderField>> customHeaderFields;
</del><ins>+    Optional<Vector<WebCore::CustomHeaderFields>> customHeaderFields;
</ins><span class="cx">     decoder >> customHeaderFields;
</span><span class="cx">     if (!customHeaderFields)
</span><span class="cx">         return WTF::nullopt;
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebsitePoliciesDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.h (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebsitePoliciesData.h 2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.h    2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -32,8 +32,8 @@
</span><span class="cx"> #include "WebsiteMetaViewportPolicy.h"
</span><span class="cx"> #include "WebsitePopUpPolicy.h"
</span><span class="cx"> #include "WebsiteSimulatedMouseEventsDispatchPolicy.h"
</span><ins>+#include <WebCore/CustomHeaderFields.h>
</ins><span class="cx"> #include <WebCore/DeviceOrientationOrMotionPermissionState.h>
</span><del>-#include <WebCore/HTTPHeaderField.h>
</del><span class="cx"> #include <wtf/OptionSet.h>
</span><span class="cx"> 
</span><span class="cx"> namespace IPC {
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> #if ENABLE(DEVICE_ORIENTATION)
</span><span class="cx">     WebCore::DeviceOrientationOrMotionPermissionState deviceOrientationAndMotionAccessState;
</span><span class="cx"> #endif
</span><del>-    Vector<WebCore::HTTPHeaderField> customHeaderFields;
</del><ins>+    Vector<WebCore::CustomHeaderFields> customHeaderFields;
</ins><span class="cx">     WebsitePopUpPolicy popUpPolicy { WebsitePopUpPolicy::Default };
</span><span class="cx">     Optional<WebsiteDataStoreParameters> websiteDataStoreParameters;
</span><span class="cx">     String customUserAgent;
</span></span></pre></div>
<a id="trunkSourceWebKitSourcesCocoatxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/SourcesCocoa.txt (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/SourcesCocoa.txt     2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/SourcesCocoa.txt        2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -242,6 +242,7 @@
</span><span class="cx"> UIProcess/API/Cocoa/_WKAutomationSessionConfiguration.mm
</span><span class="cx"> UIProcess/API/Cocoa/_WKContentRuleListAction.mm
</span><span class="cx"> UIProcess/API/Cocoa/_WKContextMenuElementInfo.mm
</span><ins>+UIProcess/API/Cocoa/_WKCustomHeaderFields.mm @no-unify
</ins><span class="cx"> UIProcess/API/Cocoa/_WKDownload.mm
</span><span class="cx"> UIProcess/API/Cocoa/_WKElementAction.mm
</span><span class="cx"> UIProcess/API/Cocoa/_WKErrorRecoveryAttempting.mm
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPICustomHeaderFieldsh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/UIProcess/API/APICustomHeaderFields.h (0 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APICustomHeaderFields.h                                (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/APICustomHeaderFields.h   2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "APIObject.h"
+#include <WebCore/CustomHeaderFields.h>
+
+namespace API {
+
+class CustomHeaderFields final : public ObjectImpl<Object::Type::CustomHeaderFields> {
+public:
+    template<typename... Args> static Ref<CustomHeaderFields> create(Args&&... args)
+    {
+        return adoptRef(*new CustomHeaderFields(std::forward<Args>(args)...));
+    }
+
+    CustomHeaderFields() = default;
+
+    const Vector<WebCore::HTTPHeaderField>& fields() const { return m_fields.fields; }
+    void setFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_fields.fields = WTFMove(fields); }
+
+    const Vector<WTF::String> thirdPartyDomains() const { return m_fields.thirdPartyDomains; }
+    void setThirdPartyDomains(Vector<WTF::String>&& domains) { m_fields.thirdPartyDomains = WTFMove(domains); }
+
+    const WebCore::CustomHeaderFields& coreFields() const { return m_fields; }
+
+private:
+    CustomHeaderFields(const WebCore::CustomHeaderFields& fields)
+        : m_fields(fields) { }
+
+    WebCore::CustomHeaderFields m_fields;
+};
+
+} // namespace API
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIWebsitePoliciescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp 2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.cpp    2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -33,10 +33,11 @@
</span><span class="cx"> 
</span><span class="cx"> WebsitePolicies::WebsitePolicies() = default;
</span><span class="cx"> 
</span><del>-WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebsiteDataStore>&& websiteDataStore)
</del><ins>+WebsitePolicies::WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks, WebKit::WebsiteAutoplayPolicy autoplayPolicy, Vector<WebCore::HTTPHeaderField>&& legacyCustomHeaderFields, Vector<WebCore::CustomHeaderFields>&& customHeaderFields, WebKit::WebsitePopUpPolicy popUpPolicy, RefPtr<WebsiteDataStore>&& websiteDataStore)
</ins><span class="cx">     : m_contentBlockersEnabled(contentBlockersEnabled)
</span><span class="cx">     , m_allowedAutoplayQuirks(allowedAutoplayQuirks)
</span><span class="cx">     , m_autoplayPolicy(autoplayPolicy)
</span><ins>+    , m_legacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields))
</ins><span class="cx">     , m_customHeaderFields(WTFMove(customHeaderFields))
</span><span class="cx">     , m_popUpPolicy(popUpPolicy)
</span><span class="cx">     , m_websiteDataStore(WTFMove(websiteDataStore))
</span><span class="lines">@@ -60,10 +61,17 @@
</span><span class="cx">     policies->setMetaViewportPolicy(m_metaViewportPolicy);
</span><span class="cx">     policies->setMediaSourcePolicy(m_mediaSourcePolicy);
</span><span class="cx">     policies->setSimulatedMouseEventsDispatchPolicy(m_simulatedMouseEventsDispatchPolicy);
</span><del>-    Vector<WebCore::HTTPHeaderField> customHeaderFields;
</del><ins>+    
+    Vector<WebCore::HTTPHeaderField> legacyCustomHeaderFields;
+    legacyCustomHeaderFields.reserveInitialCapacity(m_legacyCustomHeaderFields.size());
+    for (auto& field : m_legacyCustomHeaderFields)
+        legacyCustomHeaderFields.uncheckedAppend(field);
+    policies->setLegacyCustomHeaderFields(WTFMove(legacyCustomHeaderFields));
+
+    Vector<WebCore::CustomHeaderFields> customHeaderFields;
</ins><span class="cx">     customHeaderFields.reserveInitialCapacity(m_customHeaderFields.size());
</span><span class="cx">     for (auto& field : m_customHeaderFields)
</span><del>-        customHeaderFields.append(WebCore::HTTPHeaderField(field));
</del><ins>+        customHeaderFields.uncheckedAppend(field);
</ins><span class="cx">     policies->setCustomHeaderFields(WTFMove(customHeaderFields));
</span><span class="cx">     policies->setAllowSiteSpecificQuirksToOverrideCompatibilityMode(m_allowSiteSpecificQuirksToOverrideCompatibilityMode);
</span><span class="cx">     policies->setApplicationNameForUserAgentWithModernCompatibility(m_applicationNameForUserAgentWithModernCompatibility);
</span><span class="lines">@@ -81,6 +89,14 @@
</span><span class="cx"> 
</span><span class="cx"> WebKit::WebsitePoliciesData WebsitePolicies::data()
</span><span class="cx"> {
</span><ins>+    bool hasLegacyCustomHeaderFields = legacyCustomHeaderFields().size();
+    Vector<WebCore::CustomHeaderFields> customHeaderFields;
+    customHeaderFields.reserveInitialCapacity(this->customHeaderFields().size() + hasLegacyCustomHeaderFields);
+    for (auto& field : this->customHeaderFields())
+        customHeaderFields.uncheckedAppend(field);
+    if (hasLegacyCustomHeaderFields)
+        customHeaderFields.uncheckedAppend({ legacyCustomHeaderFields(), { }});
+
</ins><span class="cx">     return {
</span><span class="cx">         contentBlockersEnabled(),
</span><span class="cx">         allowedAutoplayQuirks(),
</span><span class="lines">@@ -88,7 +104,7 @@
</span><span class="cx"> #if ENABLE(DEVICE_ORIENTATION)
</span><span class="cx">         deviceOrientationAndMotionAccessState(),
</span><span class="cx"> #endif
</span><del>-        customHeaderFields(),
</del><ins>+        WTFMove(customHeaderFields),
</ins><span class="cx">         popUpPolicy(),
</span><span class="cx">         m_websiteDataStore ? Optional<WebKit::WebsiteDataStoreParameters> { m_websiteDataStore->websiteDataStore().parameters() } : WTF::nullopt,
</span><span class="cx">         m_customUserAgent,
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIWebsitePoliciesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h   2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h      2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "WebsiteMetaViewportPolicy.h"
</span><span class="cx"> #include "WebsitePopUpPolicy.h"
</span><span class="cx"> #include "WebsiteSimulatedMouseEventsDispatchPolicy.h"
</span><ins>+#include <WebCore/CustomHeaderFields.h>
</ins><span class="cx"> #include <WebCore/DeviceOrientationOrMotionPermissionState.h>
</span><span class="cx"> #include <WebCore/HTTPHeaderField.h>
</span><span class="cx"> #include <wtf/OptionSet.h>
</span><span class="lines">@@ -68,10 +69,12 @@
</span><span class="cx">     void setDeviceOrientationAndMotionAccessState(WebCore::DeviceOrientationOrMotionPermissionState state) { m_deviceOrientationAndMotionAccessState = state; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    const Vector<WebCore::HTTPHeaderField>& customHeaderFields() const { return m_customHeaderFields; }
-    Vector<WebCore::HTTPHeaderField>&& takeCustomHeaderFields() { return WTFMove(m_customHeaderFields); }
-    void setCustomHeaderFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_customHeaderFields = WTFMove(fields); }
</del><ins>+    const Vector<WebCore::HTTPHeaderField>& legacyCustomHeaderFields() const { return m_legacyCustomHeaderFields; }
+    void setLegacyCustomHeaderFields(Vector<WebCore::HTTPHeaderField>&& fields) { m_legacyCustomHeaderFields = WTFMove(fields); }
</ins><span class="cx"> 
</span><ins>+    const Vector<WebCore::CustomHeaderFields>& customHeaderFields() const { return m_customHeaderFields; }
+    void setCustomHeaderFields(Vector<WebCore::CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); }
+
</ins><span class="cx">     WebKit::WebsitePopUpPolicy popUpPolicy() const { return m_popUpPolicy; }
</span><span class="cx">     void setPopUpPolicy(WebKit::WebsitePopUpPolicy policy) { m_popUpPolicy = policy; }
</span><span class="cx"> 
</span><span class="lines">@@ -108,7 +111,7 @@
</span><span class="cx">     void setApplicationNameForUserAgentWithModernCompatibility(const WTF::String& applicationName) { m_applicationNameForUserAgentWithModernCompatibility = applicationName; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&);
</del><ins>+    WebsitePolicies(bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&);
</ins><span class="cx"> 
</span><span class="cx">     bool m_contentBlockersEnabled { true };
</span><span class="cx">     OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks;
</span><span class="lines">@@ -116,7 +119,8 @@
</span><span class="cx"> #if ENABLE(DEVICE_ORIENTATION)
</span><span class="cx">     WebCore::DeviceOrientationOrMotionPermissionState m_deviceOrientationAndMotionAccessState { WebCore::DeviceOrientationOrMotionPermissionState::Prompt };
</span><span class="cx"> #endif
</span><del>-    Vector<WebCore::HTTPHeaderField> m_customHeaderFields;
</del><ins>+    Vector<WebCore::HTTPHeaderField> m_legacyCustomHeaderFields;
+    Vector<WebCore::CustomHeaderFields> m_customHeaderFields;
</ins><span class="cx">     WebKit::WebsitePopUpPolicy m_popUpPolicy { WebKit::WebsitePopUpPolicy::Default };
</span><span class="cx">     RefPtr<WebsiteDataStore> m_websiteDataStore;
</span><span class="cx">     WTF::String m_customUserAgent;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKWebsitePoliciescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp        2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/UIProcess/API/C/WKWebsitePolicies.cpp   2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> WK_EXPORT WKDictionaryRef WKWebsitePoliciesCopyCustomHeaderFields(WKWebsitePoliciesRef websitePolicies)
</span><span class="cx"> {
</span><span class="cx">     HashMap<WTF::String, RefPtr<API::Object>> fields;
</span><del>-    for (const auto& field : toImpl(websitePolicies)->customHeaderFields())
</del><ins>+    for (const auto& field : toImpl(websitePolicies)->legacyCustomHeaderFields())
</ins><span class="cx">         fields.add(field.name(), API::String::create(field.value()));
</span><span class="cx">     return toAPI(API::Dictionary::create(WTFMove(fields)).ptr());
</span><span class="cx"> }
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">         if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
</span><span class="cx">             fields.uncheckedAppend(WTFMove(*field));
</span><span class="cx">     }
</span><del>-    toImpl(websitePolicies)->setCustomHeaderFields(WTFMove(fields));
</del><ins>+    toImpl(websitePolicies)->setLegacyCustomHeaderFields(WTFMove(fields));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WKWebsitePoliciesSetAllowedAutoplayQuirks(WKWebsitePoliciesRef websitePolicies, WKWebsiteAutoplayQuirk allowedQuirks)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebpagePreferencesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm  2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.mm     2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -26,9 +26,11 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "WKWebpagePreferences.h"
</span><span class="cx"> 
</span><ins>+#import "APICustomHeaderFields.h"
</ins><span class="cx"> #import "WKWebpagePreferencesInternal.h"
</span><span class="cx"> #import "WKWebsiteDataStoreInternal.h"
</span><span class="cx"> #import "WebCompatibilityMode.h"
</span><ins>+#import "_WKCustomHeaderFieldsInternal.h"
</ins><span class="cx"> #import "_WKWebsitePoliciesInternal.h"
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><span class="lines">@@ -214,26 +216,22 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (NSDictionary<NSString *, NSString *> *)_customHeaderFields
</del><ins>+- (NSArray<_WKCustomHeaderFields *> *)_customHeaderFields
</ins><span class="cx"> {
</span><span class="cx">     const auto& fields = _websitePolicies->customHeaderFields();
</span><del>-    auto dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:fields.size()]);
</del><ins>+    NSMutableArray *array = [[[NSMutableArray alloc] initWithCapacity:fields.size()] autorelease];
</ins><span class="cx">     for (const auto& field : fields)
</span><del>-        [dictionary setObject:field.value() forKey:field.name()];
-    return dictionary.autorelease();
</del><ins>+        [array addObject:wrapper(API::CustomHeaderFields::create(field))];
+    return array;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields
</del><ins>+- (void)_setCustomHeaderFields:(NSArray<_WKCustomHeaderFields *> *)fields
</ins><span class="cx"> {
</span><del>-    Vector<WebCore::HTTPHeaderField> parsedFields;
-    parsedFields.reserveInitialCapacity(fields.count);
-
-    for (NSString *name in fields) {
-        auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]);
-        if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
-            parsedFields.uncheckedAppend(WTFMove(*field));
-    }
-    _websitePolicies->setCustomHeaderFields(WTFMove(parsedFields));
</del><ins>+    Vector<WebCore::CustomHeaderFields> vector;
+    vector.reserveInitialCapacity(fields.count);
+    for (_WKCustomHeaderFields *element in fields)
+        vector.uncheckedAppend(static_cast<API::CustomHeaderFields&>([element _apiObject]).coreFields());
+    _websitePolicies->setCustomHeaderFields(WTFMove(vector));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKWebsiteDataStore *)_websiteDataStore
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebpagePreferencesPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h    2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferencesPrivate.h       2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -55,12 +55,14 @@
</span><span class="cx">     _WKWebsiteDeviceOrientationAndMotionAccessPolicyDeny,
</span><span class="cx"> } WK_API_AVAILABLE(macos(10.14), ios(12.0));
</span><span class="cx"> 
</span><ins>+@class _WKCustomHeaderFields;
+
</ins><span class="cx"> @interface WKWebpagePreferences (WKPrivate)
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, setter=_setContentBlockersEnabled:) BOOL _contentBlockersEnabled;
</span><span class="cx"> @property (nonatomic, setter=_setAllowedAutoplayQuirks:) _WKWebsiteAutoplayQuirk _allowedAutoplayQuirks;
</span><span class="cx"> @property (nonatomic, setter=_setAutoplayPolicy:) _WKWebsiteAutoplayPolicy _autoplayPolicy;
</span><del>-@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSDictionary<NSString *, NSString *> *_customHeaderFields;
</del><ins>+@property (nonatomic, copy, setter=_setCustomHeaderFields:) NSArray<_WKCustomHeaderFields *> *_customHeaderFields;
</ins><span class="cx"> @property (nonatomic, setter=_setPopUpPolicy:) _WKWebsitePopUpPolicy _popUpPolicy;
</span><span class="cx"> @property (nonatomic, strong, setter=_setWebsiteDataStore:) WKWebsiteDataStore *_websiteDataStore;
</span><span class="cx"> @property (nonatomic, copy, setter=_setCustomUserAgent:) NSString *_customUserAgent;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKCustomHeaderFieldsh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h (0 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h                          (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.h     2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WKFoundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+WK_CLASS_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA))
+@interface _WKCustomHeaderFields : NSObject
+
+@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *fields;
+@property (nonatomic, copy) NSArray<NSString *> *thirdPartyDomains;
+
+@end
+
+NS_ASSUME_NONNULL_END
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKCustomHeaderFieldsmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm (0 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm                         (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFields.mm    2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "_WKCustomHeaderFields.h"
+
+#import "_WKCustomHeaderFieldsInternal.h"
+#import <wtf/BlockPtr.h>
+
+@implementation _WKCustomHeaderFields
+
+- (instancetype)init
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    API::Object::constructInWrapper<API::CustomHeaderFields>(self);
+    return self;
+}
+
+- (void)dealloc
+{
+    _fields->API::CustomHeaderFields::~CustomHeaderFields();
+    [super dealloc];
+}
+
+- (NSDictionary<NSString *, NSString *> *)fields
+{
+    auto& vector = _fields->fields();
+    NSMutableDictionary<NSString *, NSString *> *dictionary = [NSMutableDictionary dictionaryWithCapacity:vector.size()];
+    for (auto& field : vector)
+        [dictionary setObject:field.value() forKey:field.name()];
+    return dictionary;
+}
+
+- (void)setFields:(NSDictionary<NSString *, NSString *> *)fields
+{
+    Vector<WebCore::HTTPHeaderField> vector;
+    vector.reserveInitialCapacity(fields.count);
+    [fields enumerateKeysAndObjectsUsingBlock:makeBlockPtr([&](id key, id value, BOOL* stop) {
+        if (auto field = WebCore::HTTPHeaderField::create((NSString *)key, (NSString *)value); field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
+            vector.uncheckedAppend(WTFMove(*field));
+    }).get()];
+    _fields->setFields(WTFMove(vector));
+}
+
+- (NSArray<NSString *> *)thirdPartyDomains
+{
+    auto& domains = _fields->thirdPartyDomains();
+    NSMutableArray *array = [NSMutableArray arrayWithCapacity:domains.size()];
+    for (auto& domain : domains)
+        [array addObject:domain];
+    return array;
+}
+
+- (void)setThirdPartyDomains:(NSArray<NSString *> *)thirdPartyDomains
+{
+    Vector<String> domains;
+    domains.reserveInitialCapacity(thirdPartyDomains.count);
+    for (NSString *domain in thirdPartyDomains)
+        domains.uncheckedAppend(domain);
+    _fields->setThirdPartyDomains(WTFMove(domains));
+}
+
+- (API::Object&)_apiObject
+{
+    return *_fields;
+}
+
+@end
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKCustomHeaderFieldsInternalh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h (0 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h                          (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKCustomHeaderFieldsInternal.h     2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "APICustomHeaderFields.h"
+#import "WKObject.h"
+#import "_WKCustomHeaderFields.h"
+
+namespace WebKit {
+
+template<> struct WrapperTraits<API::CustomHeaderFields> {
+    using WrapperClass = _WKCustomHeaderFields;
+};
+
+}
+
+@interface _WKCustomHeaderFields () <WKObject> {
+@package
+    API::ObjectStorage<API::CustomHeaderFields> _fields;
+}
+@end
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKWebsitePoliciesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm    2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKWebsitePolicies.mm       2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -97,12 +97,24 @@
</span><span class="cx"> 
</span><span class="cx"> - (NSDictionary<NSString *, NSString *> *)customHeaderFields
</span><span class="cx"> {
</span><del>-    return [_webpagePreferences _customHeaderFields];
</del><ins>+    auto& fields = static_cast<API::WebsitePolicies&>([_webpagePreferences _apiObject]).legacyCustomHeaderFields();
+    auto dictionary = [NSMutableDictionary dictionaryWithCapacity:fields.size()];
+    for (const auto& field : fields)
+        [dictionary setObject:field.value() forKey:field.name()];
+    return dictionary;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setCustomHeaderFields:(NSDictionary<NSString *, NSString *> *)fields
</span><span class="cx"> {
</span><del>-    [_webpagePreferences _setCustomHeaderFields:fields];
</del><ins>+    auto websitePolicies = static_cast<API::WebsitePolicies&>([_webpagePreferences _apiObject]);
+    Vector<WebCore::HTTPHeaderField> parsedFields;
+    parsedFields.reserveInitialCapacity(fields.count);
+    for (NSString *name in fields) {
+        auto field = WebCore::HTTPHeaderField::create(name, [fields objectForKey:name]);
+        if (field && startsWithLettersIgnoringASCIICase(field->name(), "x-"))
+            parsedFields.uncheckedAppend(WTFMove(*field));
+    }
+    websitePolicies.setLegacyCustomHeaderFields(WTFMove(parsedFields));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WKWebsiteDataStore *)websiteDataStore
</span></span></pre></div>
<a id="trunkSourceWebKitWebKitxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj     2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj        2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -1078,6 +1078,7 @@
</span><span class="cx">          5C5CEC33220912B300D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; };
</span><span class="cx">          5C5CEC34220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; };
</span><span class="cx">          5C5CEC35220912B400D6BBB0 /* AuxiliaryProcessMain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */; };
</span><ins>+               5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           5C62FDF91EFC271C00CE072E /* WKURLSchemeTaskPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5C7FB47021E97DC5009E3241 /* WebCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = 5C7FB46F21E97C0C009E3241 /* WebCookieJar.h */; };
</span><span class="cx">          5C8BC797218CBB4800813886 /* SafeBrowsing.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5C8BC796218CB58A00813886 /* SafeBrowsing.xcassets */; };
</span><span class="lines">@@ -1092,6 +1093,7 @@
</span><span class="cx">          5CB2378C1DF0DE6E00117AA3 /* _WKWebsitePolicies.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB237891DF0DD4300117AA3 /* _WKWebsitePolicies.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5CB2378E1DF0E0D300117AA3 /* _WKWebsitePoliciesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB2378D1DF0E0C200117AA3 /* _WKWebsitePoliciesInternal.h */; };
</span><span class="cx">          5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
</span><ins>+               5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */; };
</ins><span class="cx">           5CD286511E7235990094FDC8 /* WKContentRuleListStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD2864D1E722F440094FDC8 /* WKContentRuleListStore.h */; settings = {ATTRIBUTES = (Public, ); }; };
</span><span class="cx">          5CD286531E7235AA0094FDC8 /* _WKUserContentFilterPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD286491E722F440094FDC8 /* _WKUserContentFilterPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          5CD286541E7235B10094FDC8 /* WKContentRuleList.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD2864A1E722F440094FDC8 /* WKContentRuleList.h */; settings = {ATTRIBUTES = (Public, ); }; };
</span><span class="lines">@@ -3528,6 +3530,10 @@
</span><span class="cx">          5C5CEC31220912AF00D6BBB0 /* AuxiliaryProcessMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AuxiliaryProcessMain.cpp; path = Cocoa/AuxiliaryProcessMain.cpp; sourceTree = "<group>"; };
</span><span class="cx">          5C5CEC382209583200D6BBB0 /* DaemonEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonEntryPoint.h; sourceTree = "<group>"; };
</span><span class="cx">          5C5CEC392209583200D6BBB0 /* DaemonEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DaemonEntryPoint.mm; sourceTree = "<group>"; };
</span><ins>+               5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFieldsInternal.h; sourceTree = "<group>"; };
+               5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKCustomHeaderFields.mm; sourceTree = "<group>"; };
+               5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKCustomHeaderFields.h; sourceTree = "<group>"; };
+               5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APICustomHeaderFields.h; sourceTree = "<group>"; };
</ins><span class="cx">           5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; };
</span><span class="cx">          5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; };
</span><span class="cx">          5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImplCocoa.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -6141,6 +6147,9 @@
</span><span class="cx">                          5C4609E422430E4D009943C2 /* _WKContentRuleListActionInternal.h */,
</span><span class="cx">                          1A5704F61BE01FF400874AF1 /* _WKContextMenuElementInfo.h */,
</span><span class="cx">                          1A5704F51BE01FF400874AF1 /* _WKContextMenuElementInfo.mm */,
</span><ins>+                               5C5D2389227A1892000B9BDA /* _WKCustomHeaderFields.h */,
+                               5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */,
+                               5C5D2387227A1891000B9BDA /* _WKCustomHeaderFieldsInternal.h */,
</ins><span class="cx">                           83891B681A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h */,
</span><span class="cx">                          A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */,
</span><span class="cx">                          A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */,
</span><span class="lines">@@ -7705,6 +7714,7 @@
</span><span class="cx">                          7C3A06A51AAB903E009D74BA /* APIContentRuleListStore.cpp */,
</span><span class="cx">                          7C3A06A61AAB903E009D74BA /* APIContentRuleListStore.h */,
</span><span class="cx">                          076E884D1A13CADF005E90FC /* APIContextMenuClient.h */,
</span><ins>+                               5C5D238A227A1D9B000B9BDA /* APICustomHeaderFields.h */,
</ins><span class="cx">                           7A821F4F1E2F7A5C00604577 /* APICustomProtocolManagerClient.h */,
</span><span class="cx">                          83891B621A68B3420030F386 /* APIDiagnosticLoggingClient.h */,
</span><span class="cx">                          1F7D36C018DA513F00D9D659 /* APIDownloadClient.h */,
</span><span class="lines">@@ -9018,6 +9028,7 @@
</span><span class="cx">                          5C4609E7224317B4009943C2 /* _WKContentRuleListAction.h in Headers */,
</span><span class="cx">                          5C4609E8224317BB009943C2 /* _WKContentRuleListActionInternal.h in Headers */,
</span><span class="cx">                          1A5704F81BE01FF400874AF1 /* _WKContextMenuElementInfo.h in Headers */,
</span><ins>+                               5C5D238C227A2CDA000B9BDA /* _WKCustomHeaderFields.h in Headers */,
</ins><span class="cx">                           83891B691A68BEBC0030F386 /* _WKDiagnosticLoggingDelegate.h in Headers */,
</span><span class="cx">                          A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */,
</span><span class="cx">                          A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */,
</span><span class="lines">@@ -10957,6 +10968,7 @@
</span><span class="cx">                  isa = PBXSourcesBuildPhase;
</span><span class="cx">                  buildActionMask = 2147483647;
</span><span class="cx">                  files = (
</span><ins>+                               5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */,
</ins><span class="cx">                           99E7189A21F79D9E0055E975 /* _WKTouchEventGenerator.mm in Sources */,
</span><span class="cx">                          2D92A784212B6AB100F493FD /* ActivityAssertion.cpp in Sources */,
</span><span class="cx">                          2D92A77B212B6A7100F493FD /* ArgumentCoders.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Tools/ChangeLog       2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2019-05-16  Alex Christensen  <achristensen@webkit.org>
+
+        Add SPI to set a list of hosts to which to send custom header fields cross-origin
+        https://bugs.webkit.org/show_bug.cgi?id=197397
+
+        Reviewed by Geoff Garen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+        (TEST):
+        (expectLegacyHeaders):
+        (expectHeaders):
+        (-[CustomHeaderFieldsDelegate webView:decidePolicyForNavigationAction:preferences:decisionHandler:]):
+        (-[CustomHeaderFieldsDelegate webView:startURLSchemeTask:]):
+        (-[CustomHeaderFieldsDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]): Deleted.
+
</ins><span class="cx"> 2019-05-15  Aakash Jain  <aakash_jain@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Replace double-quotes with single quotes in steps.py
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaWebsitePoliciesmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (245400 => 245401)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm   2019-05-16 17:31:01 UTC (rev 245400)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm      2019-05-16 18:08:30 UTC (rev 245401)
</span><span class="lines">@@ -28,10 +28,12 @@
</span><span class="cx"> #import "PlatformUtilities.h"
</span><span class="cx"> #import "TestNavigationDelegate.h"
</span><span class="cx"> #import "TestWKWebView.h"
</span><ins>+#import <WebKit/WKMutableDictionary.h>
</ins><span class="cx"> #import <WebKit/WKNavigationDelegatePrivate.h>
</span><span class="cx"> #import <WebKit/WKPagePrivate.h>
</span><span class="cx"> #import <WebKit/WKPreferencesPrivate.h>
</span><span class="cx"> #import <WebKit/WKPreferencesRefPrivate.h>
</span><ins>+#import <WebKit/WKString.h>
</ins><span class="cx"> #import <WebKit/WKUIDelegatePrivate.h>
</span><span class="cx"> #import <WebKit/WKURLSchemeTaskPrivate.h>
</span><span class="cx"> #import <WebKit/WKUserContentControllerPrivate.h>
</span><span class="lines">@@ -38,6 +40,7 @@
</span><span class="cx"> #import <WebKit/WKWebViewPrivate.h>
</span><span class="cx"> #import <WebKit/WKWebsiteDataStorePrivate.h>
</span><span class="cx"> #import <WebKit/WKWebsitePolicies.h>
</span><ins>+#import <WebKit/_WKCustomHeaderFields.h>
</ins><span class="cx"> #import <WebKit/_WKUserContentExtensionStorePrivate.h>
</span><span class="cx"> #import <WebKit/_WKWebsiteDataStoreConfiguration.h>
</span><span class="cx"> #import <WebKit/_WKWebsitePolicies.h>
</span><span class="lines">@@ -907,9 +910,9 @@
</span><span class="cx"> 
</span><span class="cx"> TEST(WebKit, InvalidCustomHeaders)
</span><span class="cx"> {
</span><del>-    auto websitePolicies = adoptNS([[_WKWebsitePolicies alloc] init]);
-    [websitePolicies setCustomHeaderFields:@{@"invalidheader" : @"", @"noncustom" : @"header", @"    x-Custom ":@"  Needs Canonicalization\t ", @"x-other" : @"other value"}];
-    NSDictionary<NSString *, NSString *> *canonicalized = [websitePolicies customHeaderFields];
</del><ins>+    auto customHeaderFields = adoptNS([[_WKCustomHeaderFields alloc] init]);
+    [customHeaderFields setFields:@{@"invalidheader" : @"", @"noncustom" : @"header", @"    x-Custom ":@"  Needs Canonicalization\t ", @"x-other" : @"other value"}];
+    NSDictionary<NSString *, NSString *> *canonicalized = [customHeaderFields fields];
</ins><span class="cx">     EXPECT_EQ(canonicalized.count, 2u);
</span><span class="cx">     EXPECT_STREQ([canonicalized objectForKey:@"x-Custom"].UTF8String, "Needs Canonicalization");
</span><span class="cx">     EXPECT_STREQ([canonicalized objectForKey:@"x-other"].UTF8String, "other value");
</span><span class="lines">@@ -919,8 +922,9 @@
</span><span class="cx"> static bool secondTestDone;
</span><span class="cx"> static bool thirdTestDone;
</span><span class="cx"> static bool fourthTestDone;
</span><ins>+static bool fifthTestDone;
</ins><span class="cx"> 
</span><del>-static void expectHeaders(id <WKURLSchemeTask> task, bool expected)
</del><ins>+static void expectLegacyHeaders(id <WKURLSchemeTask> task, bool expected)
</ins><span class="cx"> {
</span><span class="cx">     NSURLRequest *request = task.request;
</span><span class="cx">     if (expected) {
</span><span class="lines">@@ -932,6 +936,18 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void expectHeaders(id <WKURLSchemeTask> task, bool expected)
+{
+    NSURLRequest *request = task.request;
+    if (expected) {
+        EXPECT_STREQ([[request valueForHTTPHeaderField:@"X-key3"] UTF8String], "value3");
+        EXPECT_STREQ([[request valueForHTTPHeaderField:@"X-key4"] UTF8String], "value4");
+    } else {
+        EXPECT_TRUE([request valueForHTTPHeaderField:@"X-key3"] == nil);
+        EXPECT_TRUE([request valueForHTTPHeaderField:@"X-key4"] == nil);
+    }
+}
+
</ins><span class="cx"> static void respond(id <WKURLSchemeTask>task, NSString *html = nil)
</span><span class="cx"> {
</span><span class="cx">     [task didReceiveResponse:[[[NSURLResponse alloc] initWithURL:task.request.URL MIMEType:@"text/html" expectedContentLength:html.length textEncodingName:nil] autorelease]];
</span><span class="lines">@@ -944,18 +960,29 @@
</span><span class="cx"> 
</span><span class="cx"> @implementation CustomHeaderFieldsDelegate
</span><span class="cx"> 
</span><del>-IGNORE_WARNINGS_BEGIN("deprecated-implementations")
-- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler
-IGNORE_WARNINGS_END
</del><ins>+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction preferences:(WKWebpagePreferences *)preferences decisionHandler:(void (^)(WKNavigationActionPolicy, WKWebpagePreferences *))decisionHandler
</ins><span class="cx"> {
</span><del>-    _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
-    [websitePolicies setCustomHeaderFields:@{@"X-key1": @"value1", @"X-key2": @"value2"}];
</del><ins>+    auto legacyHeaderFieldDictionary = adoptWK(WKMutableDictionaryCreate());
+    WKDictionarySetItem(legacyHeaderFieldDictionary.get(), adoptWK(WKStringCreateWithUTF8CString("X-key1")).get(), adoptWK(WKStringCreateWithUTF8CString("value1")).get());
+    WKDictionarySetItem(legacyHeaderFieldDictionary.get(), adoptWK(WKStringCreateWithUTF8CString("X-key2")).get(), adoptWK(WKStringCreateWithUTF8CString("value2")).get());
+    WKWebsitePoliciesSetCustomHeaderFields((WKWebsitePoliciesRef)preferences, legacyHeaderFieldDictionary.get());
+
+    _WKCustomHeaderFields *headerFields = [[[_WKCustomHeaderFields alloc] init] autorelease];
+    [headerFields setFields:@{@"X-key3": @"value3", @"X-key4": @"value4"}];
+    [headerFields setThirdPartyDomains:@[
+        @"*.hostwithasterisk.com",
+        @"hostwithoutasterisk.com",
+        @"*.com" // should be ignored.
+    ]];
+    
+    [preferences _setCustomHeaderFields:@[headerFields]];
+    
</ins><span class="cx">     if ([navigationAction.request.URL.path isEqualToString:@"/mainresource"]) {
</span><span class="cx">         dispatch_async(dispatch_get_main_queue(), ^{
</span><del>-            decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
</del><ins>+            decisionHandler(WKNavigationActionPolicyAllow, preferences);
</ins><span class="cx">         });
</span><span class="cx">     } else
</span><del>-        decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
</del><ins>+        decisionHandler(WKNavigationActionPolicyAllow, preferences);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
</span><span class="lines">@@ -962,43 +989,63 @@
</span><span class="cx"> {
</span><span class="cx">     NSString *path = urlSchemeTask.request.URL.path;
</span><span class="cx">     if ([path isEqualToString:@"/mainresource"]) {
</span><del>-        expectHeaders(urlSchemeTask, true);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, true);
</ins><span class="cx">         respond(urlSchemeTask, @"<script>fetch('subresource').then(function(response){fetch('test://differentsecurityorigin/crossoriginsubresource',{mode:'no-cors'})})</script>");
</span><span class="cx">     } else if ([path isEqualToString:@"/subresource"]) {
</span><del>-        expectHeaders(urlSchemeTask, true);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, true);
</ins><span class="cx">         respond(urlSchemeTask);
</span><span class="cx">     } else if ([path isEqualToString:@"/crossoriginsubresource"]) {
</span><del>-        expectHeaders(urlSchemeTask, false);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, false);
</ins><span class="cx">         respond(urlSchemeTask);
</span><span class="cx">         firstTestDone = true;
</span><span class="cx">     } else if ([path isEqualToString:@"/mainresourcewithiframe"]) {
</span><del>-        expectHeaders(urlSchemeTask, true);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, true);
</ins><span class="cx">         respond(urlSchemeTask, @"<iframe src='test://iframeorigin/iframemainresource'></iframe>");
</span><span class="cx">     } else if ([path isEqualToString:@"/iframemainresource"]) {
</span><del>-        expectHeaders(urlSchemeTask, false);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, false);
</ins><span class="cx">         respond(urlSchemeTask, @"<script>fetch('iframesubresource').then(function(response){fetch('test://mainframeorigin/originaloriginsubresource',{mode:'no-cors'})})</script>");
</span><span class="cx">     } else if ([path isEqualToString:@"/iframesubresource"]) {
</span><del>-        expectHeaders(urlSchemeTask, false);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, false);
</ins><span class="cx">         respond(urlSchemeTask);
</span><span class="cx">     } else if ([path isEqualToString:@"/originaloriginsubresource"]) {
</span><del>-        expectHeaders(urlSchemeTask, false);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, false);
</ins><span class="cx">         respond(urlSchemeTask);
</span><span class="cx">         secondTestDone = true;
</span><span class="cx">     } else if ([path isEqualToString:@"/nestedtop"]) {
</span><del>-        expectHeaders(urlSchemeTask, true);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, true);
</ins><span class="cx">         respond(urlSchemeTask, @"<iframe src='test://otherorigin/nestedmid'></iframe>");
</span><span class="cx">     } else if ([path isEqualToString:@"/nestedmid"]) {
</span><del>-        expectHeaders(urlSchemeTask, false);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, false);
</ins><span class="cx">         respond(urlSchemeTask, @"<iframe src='test://toporigin/nestedbottom'></iframe>");
</span><span class="cx">     } else if ([path isEqualToString:@"/nestedbottom"]) {
</span><del>-        expectHeaders(urlSchemeTask, true);
</del><ins>+        expectLegacyHeaders(urlSchemeTask, true);
</ins><span class="cx">         respond(urlSchemeTask);
</span><span class="cx">         thirdTestDone = true;
</span><span class="cx">     } else if ([path isEqualToString:@"/requestfromaboutblank"]) {
</span><ins>+        expectLegacyHeaders(urlSchemeTask, true);
+        respond(urlSchemeTask);
+        fourthTestDone = true;
+    } else if ([path isEqualToString:@"/testcustomheaderfieldhosts"]) {
</ins><span class="cx">         expectHeaders(urlSchemeTask, true);
</span><ins>+        NSString *html = @"<script>fetch('test://a.b.c.sub.hostwithasterisk.com/hosttest1',{mode:'no-cors'})"
+            ".then(function(response){fetch('test://subhostwithasterisk.com/hosttest2',{mode:'no-cors'})})"
+            ".then(function(response){fetch('test://hostwithoutasterisk.com/hosttest3',{mode:'no-cors'})})"
+            ".then(function(response){fetch('test://a.b.c.sub.hostwithoutasterisk.com/hosttest4',{mode:'no-cors'})})</script>";
+        respond(urlSchemeTask, html);
+    } else if ([path isEqualToString:@"/hosttest1"]) {
+        expectHeaders(urlSchemeTask, true);
</ins><span class="cx">         respond(urlSchemeTask);
</span><del>-        fourthTestDone = true;
-    } else
</del><ins>+    } else if ([path isEqualToString:@"/hosttest2"]) {
+        expectHeaders(urlSchemeTask, false);
+        respond(urlSchemeTask);
+    } else if ([path isEqualToString:@"/hosttest3"]) {
+        expectHeaders(urlSchemeTask, true);
+        respond(urlSchemeTask);
+    } else if ([path isEqualToString:@"/hosttest4"]) {
+        expectHeaders(urlSchemeTask, false);
+        respond(urlSchemeTask);
+        fifthTestDone = true;
+    } else if ([path isEqualToString:@"/testcustomheaderfieldhosts"])
</ins><span class="cx">         EXPECT_TRUE(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1023,6 +1070,9 @@
</span><span class="cx"> 
</span><span class="cx">     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://toporigin/nestedtop"]]];
</span><span class="cx">     TestWebKitAPI::Util::run(&thirdTestDone);
</span><ins>+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test://host/testcustomheaderfieldhosts"]]];
+    TestWebKitAPI::Util::run(&fifthTestDone);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static unsigned loadCount;
</span></span></pre>
</div>
</div>

</body>
</html>