<!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>[180889] trunk/Source/WebKit2</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/180889">180889</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2015-03-02 10:42:12 -0800 (Mon, 02 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>WebsiteDataStore should support getting cookie host names
https://bugs.webkit.org/show_bug.cgi?id=142178

Reviewed by Dan Bernstein.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::fetchWebsiteData):
Assert that we're destroyed from the main thread since we end up copying the website data struct.

* Shared/WebsiteData/WebsiteData.cpp:
(WebKit::WebsiteData::encode):
(WebKit::WebsiteData::decode):
* Shared/WebsiteData/WebsiteData.h:
Add a hostnamesWithCookies member.

* UIProcess/WebsiteData/WebsiteDataRecord.cpp:
(WebKit::WebsiteDataRecord::displayNameForCookieHostName):
Add a new function that will return the display name for a cookie host name.

(WebKit::WebsiteDataRecord::addCookieHostName):
* UIProcess/WebsiteData/WebsiteDataRecord.h:
Add a hash set of cookie host names.

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::fetchData):
Create data records for each host name with cookies.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebsiteDataWebsiteDatacpp">trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebsiteDataWebsiteDatah">trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataRecordcpp">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataRecordh">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/ChangeLog        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-03-02  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        WebsiteDataStore should support getting cookie host names
+        https://bugs.webkit.org/show_bug.cgi?id=142178
+
+        Reviewed by Dan Bernstein.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::fetchWebsiteData):
+        Assert that we're destroyed from the main thread since we end up copying the website data struct.
+
+        * Shared/WebsiteData/WebsiteData.cpp:
+        (WebKit::WebsiteData::encode):
+        (WebKit::WebsiteData::decode):
+        * Shared/WebsiteData/WebsiteData.h:
+        Add a hostnamesWithCookies member.
+
+        * UIProcess/WebsiteData/WebsiteDataRecord.cpp:
+        (WebKit::WebsiteDataRecord::displayNameForCookieHostName):
+        Add a new function that will return the display name for a cookie host name.
+
+        (WebKit::WebsiteDataRecord::addCookieHostName):
+        * UIProcess/WebsiteData/WebsiteDataRecord.h:
+        Add a hash set of cookie host names.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::fetchData):
+        Create data records for each host name with cookies.
+
</ins><span class="cx"> 2015-03-02  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2][Mac] WebPageProxy::supressVisibilityUpdates() should suppress visibility updates.
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -295,6 +295,8 @@
</span><span class="cx"> 
</span><span class="cx">         ~CallbackAggregator()
</span><span class="cx">         {
</span><ins>+            ASSERT(RunLoop::isMain());
+
</ins><span class="cx">             auto completionHandler = WTF::move(m_completionHandler);
</span><span class="cx">             auto websiteData = WTF::move(m_websiteData);
</span><span class="cx"> 
</span><span class="lines">@@ -311,6 +313,11 @@
</span><span class="cx">         parentProcessConnection()-&gt;send(Messages::NetworkProcessProxy::DidFetchWebsiteData(callbackID, websiteData), 0);
</span><span class="cx">     }));
</span><span class="cx"> 
</span><ins>+    if (websiteDataTypes &amp; WebsiteDataTypeCookies) {
+        if (auto* networkStorageSession = SessionTracker::session(sessionID))
+            getHostnamesWithCookies(*networkStorageSession, callbackAggregator-&gt;m_websiteData.hostNamesWithCookies);
+    }
+
</ins><span class="cx">     if (websiteDataTypes &amp; WebsiteDataTypeDiskCache) {
</span><span class="cx">         fetchDiskCacheEntries(sessionID, [callbackAggregator](Vector&lt;WebsiteData::Entry&gt; entries) {
</span><span class="cx">             callbackAggregator-&gt;m_websiteData.entries.appendVector(entries);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebsiteDataWebsiteDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.cpp        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -53,12 +53,15 @@
</span><span class="cx"> void WebsiteData::encode(IPC::ArgumentEncoder&amp; encoder) const
</span><span class="cx"> {
</span><span class="cx">     encoder &lt;&lt; entries;
</span><ins>+    encoder &lt;&lt; hostNamesWithCookies;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebsiteData::decode(IPC::ArgumentDecoder&amp; decoder, WebsiteData&amp; result)
</span><span class="cx"> {
</span><span class="cx">     if (!decoder.decode(result.entries))
</span><span class="cx">         return false;
</span><ins>+    if (!decoder.decode(result.hostNamesWithCookies))
+        return false;
</ins><span class="cx"> 
</span><span class="cx">     return true;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebsiteDataWebsiteDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.h (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.h        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/Shared/WebsiteData/WebsiteData.h        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;WebsiteDataTypes.h&quot;
</span><span class="cx"> #include &lt;WebCore/SecurityOrigin.h&gt;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace IPC {
</span><span class="lines">@@ -47,6 +48,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;Entry&gt; entries;
</span><ins>+    HashSet&lt;String&gt; hostNamesWithCookies;
</ins><span class="cx"> 
</span><span class="cx">     void encode(IPC::ArgumentEncoder&amp;) const;
</span><span class="cx">     static bool decode(IPC::ArgumentDecoder&amp;, WebsiteData&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataRecordcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -31,6 +31,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+String WebsiteDataRecord::displayNameForCookieHostName(const String&amp; hostName)
+{
+    // FIXME: This needs to handle the local file domain for cookies.
+
+#if ENABLE(PUBLIC_SUFFIX_LIST)
+    return WebCore::topPrivatelyControlledDomain(hostName.startsWith('.') ? hostName.substring(1) : hostName);
+#endif
+
+    return String();
+}
+
</ins><span class="cx"> String WebsiteDataRecord::displayNameForOrigin(const WebCore::SecurityOrigin&amp; securityOrigin)
</span><span class="cx"> {
</span><span class="cx">     const auto&amp; protocol = securityOrigin.protocol();
</span><span class="lines">@@ -55,4 +66,11 @@
</span><span class="cx">     origins.add(WTF::move(origin));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebsiteDataRecord::addCookieHostName(const String&amp; hostName)
+{
+    types |= WebsiteDataTypeCookies;
+
+    cookieHostNames.add(hostName);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataRecordh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.h (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.h        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.h        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;WebsiteDataTypes.h&quot;
</span><span class="cx"> #include &lt;WebCore/SecurityOriginHash.h&gt;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><ins>+#include &lt;wtf/text/StringHash.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -38,13 +39,16 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> struct WebsiteDataRecord {
</span><ins>+    static String displayNameForCookieHostName(const String&amp; hostName);
</ins><span class="cx">     static String displayNameForOrigin(const WebCore::SecurityOrigin&amp;);
</span><span class="cx"> 
</span><span class="cx">     void add(WebsiteDataTypes, RefPtr&lt;WebCore::SecurityOrigin&gt;&amp;&amp;);
</span><ins>+    void addCookieHostName(const String&amp; hostName);
</ins><span class="cx"> 
</span><span class="cx">     String displayName;
</span><span class="cx">     unsigned types { 0 };
</span><span class="cx">     HashSet&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; origins;
</span><ins>+    HashSet&lt;String&gt; cookieHostNames;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (180888 => 180889)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2015-03-02 18:18:16 UTC (rev 180888)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2015-03-02 18:42:12 UTC (rev 180889)
</span><span class="lines">@@ -164,6 +164,18 @@
</span><span class="cx">                 record.add(entry.type, WTF::move(entry.origin));
</span><span class="cx">             }
</span><span class="cx"> 
</span><ins>+            for (auto&amp; hostName : websiteData.hostNamesWithCookies) {
+                auto displayName = WebsiteDataRecord::displayNameForCookieHostName(hostName);
+                if (!displayName)
+                    continue;
+
+                auto&amp; record = m_websiteDataRecords.add(displayName, WebsiteDataRecord { }).iterator-&gt;value;
+                if (!record.displayName)
+                    record.displayName = WTF::move(displayName);
+
+                record.addCookieHostName(hostName);
+            }
+
</ins><span class="cx">             callIfNeeded();
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>