<!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>[194579] 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/194579">194579</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-01-05 00:12:50 -0800 (Tue, 05 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Allow to save and restore session
https://bugs.webkit.org/show_bug.cgi?id=115600

Reviewed by Michael Catanzaro.

Source/WebKit2:

Add new API to get and resore the web view session state.

* PlatformGTK.cmake: Add new files to compilation.
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkit_web_view_get_session_state): Create a new
WebKitWebViewSessionState representing the current session state.
(webkit_web_view_restore_session_state): Restore the web view
session state from the given WebKitWebViewSessionState.
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/WebKitWebViewSessionState.cpp: Added.
(_WebKitWebViewSessionState::_WebKitWebViewSessionState):
(toExternalURLsPolicy):
(toWebCoreExternalURLsPolicy):
(toHTMLBodyElementType):
(toHTTPBodyElementType):
(encodeHTTPBody):
(encodeFrameState):
(encodePageState):
(encodeBackForwardListItemState):
(encodeBackForwardListState):
(encodeSessionState):
(decodeHTTPBody):
(decodeFrameState):
(decodeBackForwardListItemState):
(decodeSessionState):
(webkitWebViewSessionStateCreate):
(webkitWebViewSessionStateGetSessionState):
(webkit_web_view_session_state_new): Create a
WebKitWebViewSessionState from serialized data.
(webkit_web_view_session_state_ref):
(webkit_web_view_session_state_unref):
(webkit_web_view_session_state_serialize): Serialize the WebKitWebViewSessionState.
* UIProcess/API/gtk/WebKitWebViewSessionState.h: Added.
* UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h: Added.
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols.
* UIProcess/API/gtk/docs/webkit2gtk-4.0.types: Add webkit_web_view_session_state_get_type.
* UIProcess/API/gtk/webkit2.h: Include WebKitWebViewSessionState.h.

Source/WTF:

Add GVariantIter specialization of GUniquePtr.

* wtf/glib/GTypedefs.h:
* wtf/glib/GUniquePtr.h:

Tools:

Add test case to check the new session API.

* TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp:
(testWebKitWebViewSessionState):
(testWebKitWebViewSessionStateWithFormData):
(beforeAll):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfglibGTypedefsh">trunk/Source/WTF/wtf/glib/GTypedefs.h</a></li>
<li><a href="#trunkSourceWTFwtfglibGUniquePtrh">trunk/Source/WTF/wtf/glib/GUniquePtr.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitAutocleanupsh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40types">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0.types</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkwebkit2h">trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestBackForwardListcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewSessionStatecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewSessionStateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewSessionStatePrivateh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WTF/ChangeLog        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-01-04  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Allow to save and restore session
+        https://bugs.webkit.org/show_bug.cgi?id=115600
+
+        Reviewed by Michael Catanzaro.
+
+        Add GVariantIter specialization of GUniquePtr.
+
+        * wtf/glib/GTypedefs.h:
+        * wtf/glib/GUniquePtr.h:
+
</ins><span class="cx"> 2016-01-04  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Turn on gesture events when building for Yosemite
</span></span></pre></div>
<a id="trunkSourceWTFwtfglibGTypedefsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/glib/GTypedefs.h (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/glib/GTypedefs.h        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WTF/wtf/glib/GTypedefs.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> typedef struct _GSource GSource;
</span><span class="cx"> typedef struct _GVariant GVariant;
</span><span class="cx"> typedef struct _GVariantBuilder GVariantBuilder;
</span><ins>+typedef struct _GVariantIter GVariantIter;
</ins><span class="cx"> typedef union _GdkEvent GdkEvent;
</span><span class="cx"> typedef struct _GTimer GTimer;
</span><span class="cx"> typedef struct _GKeyFile GKeyFile;
</span></span></pre></div>
<a id="trunkSourceWTFwtfglibGUniquePtrh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/glib/GUniquePtr.h (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/glib/GUniquePtr.h        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WTF/wtf/glib/GUniquePtr.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -44,7 +44,8 @@
</span><span class="cx">     macro(GDir, g_dir_close) \
</span><span class="cx">     macro(GTimer, g_timer_destroy) \
</span><span class="cx">     macro(GKeyFile, g_key_file_free) \
</span><del>-    macro(char*, g_strfreev)
</del><ins>+    macro(char*, g_strfreev) \
+    macro(GVariantIter, g_variant_iter_free)
</ins><span class="cx"> 
</span><span class="cx"> #define WTF_DEFINE_GPTR_DELETER(typeName, deleterFunc) \
</span><span class="cx">     template&lt;&gt; struct GPtrDeleter&lt;typeName&gt; \
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/ChangeLog        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2016-01-04  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Allow to save and restore session
+        https://bugs.webkit.org/show_bug.cgi?id=115600
+
+        Reviewed by Michael Catanzaro.
+
+        Add new API to get and resore the web view session state.
+
+        * PlatformGTK.cmake: Add new files to compilation.
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkit_web_view_get_session_state): Create a new
+        WebKitWebViewSessionState representing the current session state.
+        (webkit_web_view_restore_session_state): Restore the web view
+        session state from the given WebKitWebViewSessionState.
+        * UIProcess/API/gtk/WebKitWebView.h:
+        * UIProcess/API/gtk/WebKitWebViewSessionState.cpp: Added.
+        (_WebKitWebViewSessionState::_WebKitWebViewSessionState):
+        (toExternalURLsPolicy):
+        (toWebCoreExternalURLsPolicy):
+        (toHTMLBodyElementType):
+        (toHTTPBodyElementType):
+        (encodeHTTPBody):
+        (encodeFrameState):
+        (encodePageState):
+        (encodeBackForwardListItemState):
+        (encodeBackForwardListState):
+        (encodeSessionState):
+        (decodeHTTPBody):
+        (decodeFrameState):
+        (decodeBackForwardListItemState):
+        (decodeSessionState):
+        (webkitWebViewSessionStateCreate):
+        (webkitWebViewSessionStateGetSessionState):
+        (webkit_web_view_session_state_new): Create a
+        WebKitWebViewSessionState from serialized data.
+        (webkit_web_view_session_state_ref):
+        (webkit_web_view_session_state_unref):
+        (webkit_web_view_session_state_serialize): Serialize the WebKitWebViewSessionState.
+        * UIProcess/API/gtk/WebKitWebViewSessionState.h: Added.
+        * UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h: Added.
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols.
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0.types: Add webkit_web_view_session_state_get_type.
+        * UIProcess/API/gtk/webkit2.h: Include WebKitWebViewSessionState.h.
+
</ins><span class="cx"> 2016-01-04  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Use unique_ptr for NetworkDataTasks and references for NetworkSessionTaskClients
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -263,6 +263,9 @@
</span><span class="cx">     UIProcess/API/gtk/WebKitWebViewBaseAccessible.h
</span><span class="cx">     UIProcess/API/gtk/WebKitWebViewBasePrivate.h
</span><span class="cx">     UIProcess/API/gtk/WebKitWebViewPrivate.h
</span><ins>+    UIProcess/API/gtk/WebKitWebViewSessionState.cpp
+    UIProcess/API/gtk/WebKitWebViewSessionState.h
+    UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h
</ins><span class="cx">     UIProcess/API/gtk/WebKitWebsiteDataManager.cpp
</span><span class="cx">     UIProcess/API/gtk/WebKitWebsiteDataManager.h
</span><span class="cx">     UIProcess/API/gtk/WebKitWebsiteDataManagerPrivate.h
</span><span class="lines">@@ -428,6 +431,7 @@
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebResource.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebView.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebViewBase.h
</span><ins>+    ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebViewSessionState.h
</ins><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWebsiteDataManager.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitWindowProperties.h
</span><span class="cx">     ${WEBKIT2_DIR}/UIProcess/API/gtk/webkit2.h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitAutocleanupsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAutocleanups.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitNavigationAction, webkit_navigation_action_free)
</span><span class="cx"> G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserScript, webkit_user_script_unref)
</span><span class="cx"> G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserStyleSheet, webkit_user_style_sheet_unref)
</span><ins>+G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitWebViewSessionState, webkit_web_view_session_state_unref)
</ins><span class="cx"> 
</span><span class="cx"> #endif // __GI_SCANNER__
</span><span class="cx"> #endif // G_DEFINE_AUTOPTR_CLEANUP_FUNC
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> #include &quot;WebKitWebResourcePrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitWebViewBasePrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitWebViewPrivate.h&quot;
</span><ins>+#include &quot;WebKitWebViewSessionStatePrivate.h&quot;
</ins><span class="cx"> #include &quot;WebKitWindowPropertiesPrivate.h&quot;
</span><span class="cx"> #include &lt;JavaScriptCore/APICast.h&gt;
</span><span class="cx"> #include &lt;WebCore/CertificateInfo.h&gt;
</span><span class="lines">@@ -3717,3 +3718,38 @@
</span><span class="cx"> 
</span><span class="cx">     return webView-&gt;priv-&gt;editorState.get();
</span><span class="cx"> }
</span><ins>+
+/**
+ * webkit_web_view_get_session_state:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the current session state of @web_view
+ *
+ * Returns: (transfer full): a #WebKitWebViewSessionState
+ *
+ * Since: 2.12
+ */
+WebKitWebViewSessionState* webkit_web_view_get_session_state(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
+
+    SessionState sessionState = getPage(webView)-&gt;sessionState(nullptr);
+    return webkitWebViewSessionStateCreate(WTFMove(sessionState));
+}
+
+/**
+ * webkit_web_view_restore_session_state:
+ * @web_view: a #WebKitWebView
+ * @state: a #WebKitWebViewSessionState
+ *
+ * Restore the @web_view session state from @state
+ *
+ * Since: 2.12
+ */
+void webkit_web_view_restore_session_state(WebKitWebView* webView, WebKitWebViewSessionState* state)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+    g_return_if_fail(state);
+
+    getPage(webView)-&gt;restoreFromSessionState(webkitWebViewSessionStateGetSessionState(state), false);
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> #include &lt;webkit2/WebKitWebInspector.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitWebResource.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitWebViewBase.h&gt;
</span><ins>+#include &lt;webkit2/WebKitWebViewSessionState.h&gt;
</ins><span class="cx"> #include &lt;webkit2/WebKitWindowProperties.h&gt;
</span><span class="cx"> 
</span><span class="cx"> G_BEGIN_DECLS
</span><span class="lines">@@ -505,6 +506,13 @@
</span><span class="cx"> WEBKIT_API WebKitEditorState *
</span><span class="cx"> webkit_web_view_get_editor_state                     (WebKitWebView             *web_view);
</span><span class="cx"> 
</span><ins>+WEBKIT_API WebKitWebViewSessionState *
+webkit_web_view_get_session_state                    (WebKitWebView             *web_view);
+
+WEBKIT_API void
+webkit_web_view_restore_session_state                (WebKitWebView             *web_view,
+                                                      WebKitWebViewSessionState *state);
+
</ins><span class="cx"> G_END_DECLS
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewSessionStatecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.cpp (0 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.cpp                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.cpp        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -0,0 +1,453 @@
</span><ins>+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;WebKitWebViewSessionState.h&quot;
+
+#include &quot;WebKitWebViewSessionStatePrivate.h&quot;
+#include &lt;wtf/glib/GRefPtr.h&gt;
+#include &lt;wtf/glib/GUniquePtr.h&gt;
+
+using namespace WebKit;
+
+struct _WebKitWebViewSessionState {
+    _WebKitWebViewSessionState(SessionState&amp;&amp; state)
+        : sessionState(WTFMove(state))
+        , referenceCount(1)
+    {
+    }
+
+    SessionState sessionState;
+    int referenceCount;
+};
+
+G_DEFINE_BOXED_TYPE(WebKitWebViewSessionState, webkit_web_view_session_state, webkit_web_view_session_state_ref, webkit_web_view_session_state_unref)
+
+static const guint16 g_sessionStateVersion = 1;
+#define HTTP_BODY_ELEMENT_TYPE_STRING_V1 &quot;(uaysxmxmds)&quot;
+#define HTTP_BODY_ELEMENT_FORMAT_STRING_V1 &quot;(uay&amp;sxmxmd&amp;s)&quot;
+#define HTTP_BODY_TYPE_STRING_V1 &quot;m(sa&quot; HTTP_BODY_ELEMENT_TYPE_STRING_V1 &quot;)&quot;
+#define HTTP_BODY_FORMAT_STRING_V1 &quot;m(&amp;sa&quot; HTTP_BODY_ELEMENT_TYPE_STRING_V1 &quot;)&quot;
+#define FRAME_STATE_TYPE_STRING_V1  &quot;(ssssasmaytt(ii)d&quot; HTTP_BODY_TYPE_STRING_V1 &quot;av)&quot;
+#define FRAME_STATE_FORMAT_STRING_V1  &quot;(&amp;s&amp;s&amp;s&amp;sasmaytt(ii)d@&quot; HTTP_BODY_TYPE_STRING_V1 &quot;av)&quot;
+#define BACK_FORWARD_LIST_ITEM_TYPE_STRING_V1  &quot;(ts&quot; FRAME_STATE_TYPE_STRING_V1 &quot;u)&quot;
+#define BACK_FORWARD_LIST_ITEM_FORMAT_STRING_V1  &quot;(t&amp;s@&quot; FRAME_STATE_TYPE_STRING_V1 &quot;u)&quot;
+#define SESSION_STATE_TYPE_STRING_V1  &quot;(qa&quot; BACK_FORWARD_LIST_ITEM_TYPE_STRING_V1 &quot;mu)&quot;
+
+// Use our own enum types to ensure the serialized format even if the core enums change.
+enum ExternalURLsPolicy {
+    Allow,
+    AllowExternalSchemes,
+    NotAllow
+};
+
+static inline unsigned toExternalURLsPolicy(WebCore::ShouldOpenExternalURLsPolicy policy)
+{
+    switch (policy) {
+    case WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow:
+        return ExternalURLsPolicy::Allow;
+    case WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes:
+        return ExternalURLsPolicy::AllowExternalSchemes;
+    case WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow:
+        return ExternalURLsPolicy::NotAllow;
+    }
+
+    return ExternalURLsPolicy::NotAllow;
+}
+
+static inline WebCore::ShouldOpenExternalURLsPolicy toWebCoreExternalURLsPolicy(unsigned policy)
+{
+    switch (policy) {
+    case ExternalURLsPolicy::Allow:
+        return WebCore::ShouldOpenExternalURLsPolicy::ShouldAllow;
+    case ExternalURLsPolicy::AllowExternalSchemes:
+        return WebCore::ShouldOpenExternalURLsPolicy::ShouldAllowExternalSchemes;
+    case ExternalURLsPolicy::NotAllow:
+        return WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow;
+    }
+
+    return WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow;
+}
+
+enum HTMLBodyElementType {
+    Data,
+    File,
+    Blob
+};
+
+static inline unsigned toHTMLBodyElementType(HTTPBody::Element::Type type)
+{
+    switch (type) {
+    case HTTPBody::Element::Type::Data:
+        return HTMLBodyElementType::Data;
+    case HTTPBody::Element::Type::File:
+        return HTMLBodyElementType::File;
+    case HTTPBody::Element::Type::Blob:
+        return HTMLBodyElementType::Blob;
+    }
+
+    return HTMLBodyElementType::Data;
+}
+
+static inline HTTPBody::Element::Type toHTTPBodyElementType(unsigned type)
+{
+    switch (type) {
+    case HTMLBodyElementType::Data:
+        return HTTPBody::Element::Type::Data;
+    case HTMLBodyElementType::File:
+        return HTTPBody::Element::Type::File;
+    case HTMLBodyElementType::Blob:
+        return HTTPBody::Element::Type::Blob;
+    }
+
+    return HTTPBody::Element::Type::Data;
+}
+
+static inline void encodeHTTPBody(GVariantBuilder* sessionBuilder, const HTTPBody&amp; httpBody)
+{
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;(sa&quot; HTTP_BODY_ELEMENT_TYPE_STRING_V1 &quot;)&quot;));
+    g_variant_builder_add(sessionBuilder, &quot;s&quot;, httpBody.contentType.utf8().data());
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;a&quot; HTTP_BODY_ELEMENT_TYPE_STRING_V1));
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(HTTP_BODY_ELEMENT_TYPE_STRING_V1));
+    for (const auto&amp; element : httpBody.elements) {
+        g_variant_builder_add(sessionBuilder, &quot;u&quot;, toHTMLBodyElementType(element.type));
+        g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;ay&quot;));
+        for (auto item : element.data)
+            g_variant_builder_add(sessionBuilder, &quot;y&quot;, item);
+        g_variant_builder_close(sessionBuilder);
+        g_variant_builder_add(sessionBuilder, &quot;s&quot;, element.filePath.utf8().data());
+        g_variant_builder_add(sessionBuilder, &quot;x&quot;, element.fileStart);
+        if (element.fileLength)
+            g_variant_builder_add(sessionBuilder, &quot;mx&quot;, TRUE, element.fileLength.value());
+        else
+            g_variant_builder_add(sessionBuilder, &quot;mx&quot;, FALSE);
+        if (element.expectedFileModificationTime)
+            g_variant_builder_add(sessionBuilder, &quot;md&quot;, TRUE, element.expectedFileModificationTime.value());
+        else
+            g_variant_builder_add(sessionBuilder, &quot;md&quot;, FALSE);
+        g_variant_builder_add(sessionBuilder, &quot;s&quot;, element.blobURLString.utf8().data());
+    }
+    g_variant_builder_close(sessionBuilder);
+    g_variant_builder_close(sessionBuilder);
+    g_variant_builder_close(sessionBuilder);
+}
+
+static inline void encodeFrameState(GVariantBuilder* sessionBuilder, const FrameState&amp; frameState)
+{
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(FRAME_STATE_TYPE_STRING_V1));
+    g_variant_builder_add(sessionBuilder, &quot;s&quot;, frameState.urlString.utf8().data());
+    g_variant_builder_add(sessionBuilder, &quot;s&quot;, frameState.originalURLString.utf8().data());
+    g_variant_builder_add(sessionBuilder, &quot;s&quot;, frameState.referrer.utf8().data());
+    g_variant_builder_add(sessionBuilder, &quot;s&quot;, frameState.target.utf8().data());
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;as&quot;));
+    for (const auto&amp; state : frameState.documentState)
+        g_variant_builder_add(sessionBuilder, &quot;s&quot;, state.utf8().data());
+    g_variant_builder_close(sessionBuilder);
+    if (!frameState.stateObjectData)
+        g_variant_builder_add(sessionBuilder, &quot;may&quot;, FALSE);
+    else {
+        g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;may&quot;));
+        g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;ay&quot;));
+        for (auto item : frameState.stateObjectData.value())
+            g_variant_builder_add(sessionBuilder, &quot;y&quot;, item);
+        g_variant_builder_close(sessionBuilder);
+        g_variant_builder_close(sessionBuilder);
+    }
+    g_variant_builder_add(sessionBuilder, &quot;t&quot;, frameState.documentSequenceNumber);
+    g_variant_builder_add(sessionBuilder, &quot;t&quot;, frameState.itemSequenceNumber);
+    g_variant_builder_add(sessionBuilder, &quot;(ii)&quot;, frameState.scrollPosition.x(), frameState.scrollPosition.y());
+    g_variant_builder_add(sessionBuilder, &quot;d&quot;, frameState.pageScaleFactor);
+    if (!frameState.httpBody)
+        g_variant_builder_add(sessionBuilder, HTTP_BODY_TYPE_STRING_V1, FALSE);
+    else {
+        g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(HTTP_BODY_TYPE_STRING_V1));
+        encodeHTTPBody(sessionBuilder, frameState.httpBody.value());
+        g_variant_builder_close(sessionBuilder);
+    }
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;av&quot;));
+    for (const auto&amp; child : frameState.children)
+        encodeFrameState(sessionBuilder, child);
+    g_variant_builder_close(sessionBuilder);
+    g_variant_builder_close(sessionBuilder);
+}
+
+static inline void encodePageState(GVariantBuilder* sessionBuilder, const PageState&amp; pageState)
+{
+    g_variant_builder_add(sessionBuilder, &quot;s&quot;, pageState.title.utf8().data());
+    encodeFrameState(sessionBuilder, pageState.mainFrameState);
+    g_variant_builder_add(sessionBuilder, &quot;u&quot;, toExternalURLsPolicy(pageState.shouldOpenExternalURLsPolicy));
+}
+
+static inline void encodeBackForwardListItemState(GVariantBuilder* sessionBuilder, const BackForwardListItemState&amp; item)
+{
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(BACK_FORWARD_LIST_ITEM_TYPE_STRING_V1));
+    g_variant_builder_add(sessionBuilder, &quot;t&quot;, item.identifier);
+    encodePageState(sessionBuilder, item.pageState);
+    g_variant_builder_close(sessionBuilder);
+}
+
+static inline void encodeBackForwardListState(GVariantBuilder* sessionBuilder, const BackForwardListState&amp; backForwardListState)
+{
+    g_variant_builder_open(sessionBuilder, G_VARIANT_TYPE(&quot;a&quot; BACK_FORWARD_LIST_ITEM_TYPE_STRING_V1));
+    for (const auto&amp; item : backForwardListState.items)
+        encodeBackForwardListItemState(sessionBuilder, item);
+    g_variant_builder_close(sessionBuilder);
+
+    if (backForwardListState.currentIndex)
+        g_variant_builder_add(sessionBuilder, &quot;mu&quot;, TRUE, backForwardListState.currentIndex.value());
+    else
+        g_variant_builder_add(sessionBuilder, &quot;mu&quot;, FALSE);
+}
+
+static GBytes* encodeSessionState(const SessionState&amp; sessionState)
+{
+    GVariantBuilder sessionBuilder;
+    g_variant_builder_init(&amp;sessionBuilder, G_VARIANT_TYPE(SESSION_STATE_TYPE_STRING_V1));
+    g_variant_builder_add(&amp;sessionBuilder, &quot;q&quot;, g_sessionStateVersion);
+    encodeBackForwardListState(&amp;sessionBuilder, sessionState.backForwardListState);
+    GRefPtr&lt;GVariant&gt; variant = g_variant_builder_end(&amp;sessionBuilder);
+    return g_variant_get_data_as_bytes(variant.get());
+}
+
+static inline bool decodeHTTPBody(GVariant* httpBodyVariant, HTTPBody&amp; httpBody)
+{
+    gboolean hasHTTPBody;
+    const char* contentType;
+    GUniqueOutPtr&lt;GVariantIter&gt; elementsIter;
+    g_variant_get(httpBodyVariant, HTTP_BODY_FORMAT_STRING_V1, &amp;hasHTTPBody, &amp;contentType, &amp;elementsIter.outPtr());
+    if (!hasHTTPBody)
+        return false;
+    httpBody.contentType = String::fromUTF8(contentType);
+    gsize elementsLength = g_variant_iter_n_children(elementsIter.get());
+    if (!elementsLength)
+        return true;
+    httpBody.elements.reserveInitialCapacity(elementsLength);
+    unsigned type;
+    GVariantIter* dataIter;
+    const char* filePath;
+    gint64 fileStart;
+    gboolean hasFileLength;
+    gint64 fileLength;
+    gboolean hasFileModificationTime;
+    gdouble fileModificationTime;
+    const char* blobURLString;
+    while (g_variant_iter_loop(elementsIter.get(), HTTP_BODY_ELEMENT_FORMAT_STRING_V1, &amp;type, &amp;dataIter, &amp;filePath, &amp;fileStart, &amp;hasFileLength, &amp;fileLength, &amp;hasFileModificationTime, &amp;fileModificationTime, &amp;blobURLString)) {
+        HTTPBody::Element element;
+        element.type = toHTTPBodyElementType(type);
+        if (gsize dataLength = g_variant_iter_n_children(dataIter)) {
+            element.data.reserveInitialCapacity(dataLength);
+            guchar dataValue;
+            while (g_variant_iter_next(dataIter, &quot;y&quot;, &amp;dataValue))
+                element.data.uncheckedAppend(dataValue);
+        }
+        element.filePath = String::fromUTF8(filePath);
+        element.fileStart = fileStart;
+        if (hasFileLength)
+            element.fileLength = fileLength;
+        if (hasFileModificationTime)
+            element.expectedFileModificationTime = fileModificationTime;
+        element.blobURLString = String::fromUTF8(blobURLString);
+
+        httpBody.elements.uncheckedAppend(WTFMove(element));
+    }
+
+    return true;
+}
+
+static inline void decodeFrameState(GVariant* frameStateVariant, FrameState&amp; frameState)
+{
+    const char* urlString;
+    const char* originalURLString;
+    const char* referrer;
+    const char* target;
+    GUniqueOutPtr&lt;GVariantIter&gt; documentStateIter;
+    GUniqueOutPtr&lt;GVariantIter&gt; stateObjectDataIter;
+    guint64 documentSequenceNumber;
+    guint64 itemSequenceNumber;
+    gint32 scrollPositionX, scrollPositionY;
+    gdouble pageScaleFactor;
+    GVariant* httpBodyVariant;
+    GUniqueOutPtr&lt;GVariantIter&gt; childrenIter;
+    g_variant_get(frameStateVariant, FRAME_STATE_FORMAT_STRING_V1, &amp;urlString, &amp;originalURLString, &amp;referrer, &amp;target,
+        &amp;documentStateIter.outPtr(), &amp;stateObjectDataIter.outPtr(), &amp;documentSequenceNumber, &amp;itemSequenceNumber,
+        &amp;scrollPositionX, &amp;scrollPositionY, &amp;pageScaleFactor, &amp;httpBodyVariant, &amp;childrenIter.outPtr());
+    frameState.urlString = String::fromUTF8(urlString);
+    frameState.originalURLString = String::fromUTF8(originalURLString);
+    frameState.referrer = String::fromUTF8(referrer);
+    frameState.target = String::fromUTF8(target);
+    if (gsize documentStateLength = g_variant_iter_n_children(documentStateIter.get())) {
+        frameState.documentState.reserveInitialCapacity(documentStateLength);
+        const char* documentStateString;
+        while (g_variant_iter_next(documentStateIter.get(), &quot;&amp;s&quot;, &amp;documentStateString))
+            frameState.documentState.uncheckedAppend(String::fromUTF8(documentStateString));
+    }
+    if (stateObjectDataIter) {
+        Vector&lt;uint8_t&gt; stateObjectVector;
+        if (gsize stateObjectDataLength = g_variant_iter_n_children(stateObjectDataIter.get())) {
+            stateObjectVector.reserveInitialCapacity(stateObjectDataLength);
+            guchar stateObjectDataValue;
+            while (g_variant_iter_next(stateObjectDataIter.get(), &quot;y&quot;, &amp;stateObjectDataValue))
+                stateObjectVector.uncheckedAppend(stateObjectDataValue);
+        }
+        frameState.stateObjectData = WTFMove(stateObjectVector);
+    }
+    frameState.documentSequenceNumber = documentSequenceNumber;
+    frameState.itemSequenceNumber = itemSequenceNumber;
+    frameState.scrollPosition.setX(scrollPositionX);
+    frameState.scrollPosition.setY(scrollPositionY);
+    frameState.pageScaleFactor = pageScaleFactor;
+    HTTPBody httpBody;
+    if (decodeHTTPBody(httpBodyVariant, httpBody))
+        frameState.httpBody = WTFMove(httpBody);
+    g_variant_unref(httpBodyVariant);
+    while (GRefPtr&lt;GVariant&gt; child = adoptGRef(g_variant_iter_next_value(childrenIter.get()))) {
+        FrameState childFrameState;
+        decodeFrameState(child.get(), childFrameState);
+        frameState.children.append(WTFMove(childFrameState));
+    }
+}
+
+static inline void decodeBackForwardListItemState(GVariantIter* backForwardListStateIter, BackForwardListState&amp; backForwardListState)
+{
+    gsize backForwardListStateLength = g_variant_iter_n_children(backForwardListStateIter);
+    if (!backForwardListStateLength)
+        return;
+
+    backForwardListState.items.reserveInitialCapacity(backForwardListStateLength);
+    guint64 identifier;
+    const char* title;
+    GVariant* frameStateVariant;
+    unsigned shouldOpenExternalURLsPolicy;
+    while (g_variant_iter_loop(backForwardListStateIter, BACK_FORWARD_LIST_ITEM_FORMAT_STRING_V1, &amp;identifier, &amp;title, &amp;frameStateVariant, &amp;shouldOpenExternalURLsPolicy)) {
+        BackForwardListItemState state;
+        state.identifier = identifier;
+        state.pageState.title = String::fromUTF8(title);
+        decodeFrameState(frameStateVariant, state.pageState.mainFrameState);
+        state.pageState.shouldOpenExternalURLsPolicy = toWebCoreExternalURLsPolicy(shouldOpenExternalURLsPolicy);
+        backForwardListState.items.uncheckedAppend(WTFMove(state));
+    }
+}
+
+static bool decodeSessionState(GBytes* data, SessionState&amp; sessionState)
+{
+    GRefPtr&lt;GVariant&gt; variant = g_variant_new_from_bytes(G_VARIANT_TYPE(SESSION_STATE_TYPE_STRING_V1), data, FALSE);
+    if (!g_variant_is_normal_form(variant.get()))
+        return false;
+
+    guint16 version;
+    GUniqueOutPtr&lt;GVariantIter&gt; backForwardListStateIter;
+    gboolean hasCurrentIndex;
+    guint32 currentIndex;
+    g_variant_get(variant.get(), SESSION_STATE_TYPE_STRING_V1, &amp;version, &amp;backForwardListStateIter.outPtr(), &amp;hasCurrentIndex, &amp;currentIndex);
+    if (!version || version &gt; g_sessionStateVersion)
+        return false;
+
+    decodeBackForwardListItemState(backForwardListStateIter.get(), sessionState.backForwardListState);
+
+    if (hasCurrentIndex)
+        sessionState.backForwardListState.currentIndex = currentIndex;
+    return true;
+}
+
+WebKitWebViewSessionState* webkitWebViewSessionStateCreate(SessionState&amp;&amp; sessionState)
+{
+    WebKitWebViewSessionState* state = static_cast&lt;WebKitWebViewSessionState*&gt;(fastMalloc(sizeof(WebKitWebViewSessionState)));
+    new (state) WebKitWebViewSessionState(WTFMove(sessionState));
+    return state;
+}
+
+const SessionState&amp; webkitWebViewSessionStateGetSessionState(WebKitWebViewSessionState* state)
+{
+    return state-&gt;sessionState;
+}
+
+/**
+ * webkit_web_view_session_state_new:
+ * @data: a #GBytes
+ *
+ * Creates a new #WebKitWebViewSessionState from seralized data.
+ *
+ * Returns: (transfer full): a new #WebKitWebViewSessionState, or %NULL if @data doesn't contain a
+ *     valid serialized #WebKitWebViewSessionState.
+ *
+ * Since: 2.12
+ */
+WebKitWebViewSessionState* webkit_web_view_session_state_new(GBytes* data)
+{
+    g_return_val_if_fail(data, nullptr);
+
+    SessionState sessionState;
+    if (!decodeSessionState(data, sessionState))
+        return nullptr;
+    return webkitWebViewSessionStateCreate(WTFMove(sessionState));
+}
+
+/**
+ * webkit_web_view_session_state_ref:
+ * @state: a #WebKitWebViewSessionState
+ *
+ * Atomically increments the reference count of @state by one. This
+ * function is MT-safe and may be called from any thread.
+ *
+ * Returns: The passed in #WebKitWebViewSessionState
+ *
+ * Since: 2.12
+ */
+WebKitWebViewSessionState* webkit_web_view_session_state_ref(WebKitWebViewSessionState* state)
+{
+    g_return_val_if_fail(state, nullptr);
+    g_atomic_int_inc(&amp;state-&gt;referenceCount);
+    return state;
+}
+
+/**
+ * webkit_web_view_session_state_unref:
+ * @state: a #WebKitWebViewSessionState
+ *
+ * Atomically decrements the reference count of @state by one. If the
+ * reference count drops to 0, all memory allocated by the #WebKitWebViewSessionState is
+ * released. This function is MT-safe and may be called from any thread.
+ *
+ * Since: 2.12
+ */
+void webkit_web_view_session_state_unref(WebKitWebViewSessionState* state)
+{
+    g_return_if_fail(state);
+    if (g_atomic_int_dec_and_test(&amp;state-&gt;referenceCount)) {
+        state-&gt;~WebKitWebViewSessionState();
+        fastFree(state);
+    }
+}
+
+/**
+ * webkit_web_view_session_state_serialize:
+ * @state: a #WebKitWebViewSessionState
+ *
+ * Serializes a #WebKitWebViewSessionState.
+ *
+ * Returns: (transfer full): a #GBytes containing the @state serialized.
+ *
+ * Since: 2.12
+ */
+GBytes* webkit_web_view_session_state_serialize(WebKitWebViewSessionState* state)
+{
+    g_return_val_if_fail(state, nullptr);
+
+    return encodeSessionState(state-&gt;sessionState);
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewSessionStateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.h (0 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionState.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) &amp;&amp; !defined(WEBKIT2_COMPILATION)
+#error &quot;Only &lt;webkit2/webkit2.h&gt; can be included directly.&quot;
+#endif
+
+#ifndef WebKitWebViewSessionState_h
+#define WebKitWebViewSessionState_h
+
+#include &lt;glib-object.h&gt;
+#include &lt;webkit2/WebKitDefines.h&gt;
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_VIEW_SESSION_STATE (webkit_web_view_session_state_get_type())
+
+typedef struct _WebKitWebViewSessionState WebKitWebViewSessionState;
+
+WEBKIT_API GType
+webkit_web_view_session_state_get_type  (void);
+
+WEBKIT_API WebKitWebViewSessionState *
+webkit_web_view_session_state_new       (GBytes *data);
+
+WEBKIT_API WebKitWebViewSessionState *
+webkit_web_view_session_state_ref       (WebKitWebViewSessionState *state);
+
+WEBKIT_API void
+webkit_web_view_session_state_unref     (WebKitWebViewSessionState *state);
+
+WEBKIT_API GBytes *
+webkit_web_view_session_state_serialize (WebKitWebViewSessionState *state);
+
+G_END_DECLS
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewSessionStatePrivateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h (0 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewSessionStatePrivate.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+/*
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include &quot;SessionState.h&quot;
+#include &quot;WebKitWebViewSessionState.h&quot;
+
+#ifndef WebKitWebViewSessionStatePrivate_h
+#define WebKitWebViewSessionStatePrivate_h
+
+WebKitWebViewSessionState* webkitWebViewSessionStateCreate(WebKit::SessionState&amp;&amp;);
+const WebKit::SessionState&amp; webkitWebViewSessionStateGetSessionState(WebKitWebViewSessionState*);
+
+#endif // WebKitWebViewSessionStatePrivate_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40sectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -212,6 +212,8 @@
</span><span class="cx"> webkit_web_view_set_editable
</span><span class="cx"> webkit_web_view_is_editable
</span><span class="cx"> webkit_web_view_get_editor_state
</span><ins>+webkit_web_view_get_session_state
+webkit_web_view_restore_session_state
</ins><span class="cx"> 
</span><span class="cx"> &lt;SUBSECTION WebKitJavascriptResult&gt;
</span><span class="cx"> WebKitJavascriptResult
</span><span class="lines">@@ -230,6 +232,13 @@
</span><span class="cx"> webkit_script_dialog_prompt_set_text
</span><span class="cx"> webkit_web_view_get_main_resource
</span><span class="cx"> 
</span><ins>+&lt;SUBSECTION WebKitWebViewSessionState&gt;
+WebKitWebViewSessionState
+webkit_web_view_session_state_new
+webkit_web_view_session_state_ref
+webkit_web_view_session_state_unref
+webkit_web_view_session_state_serialize
+
</ins><span class="cx"> &lt;SUBSECTION Standard&gt;
</span><span class="cx"> WebKitWebViewClass
</span><span class="cx"> WEBKIT_WEB_VIEW
</span><span class="lines">@@ -240,11 +249,13 @@
</span><span class="cx"> WEBKIT_WEB_VIEW_GET_CLASS
</span><span class="cx"> WEBKIT_TYPE_JAVASCRIPT_RESULT
</span><span class="cx"> WEBKIT_TYPE_SCRIPT_DIALOG
</span><ins>+WEBKIT_TYPE_WEB_VIEW_SESSION_STATE
</ins><span class="cx"> 
</span><span class="cx"> &lt;SUBSECTION Private&gt;
</span><span class="cx"> webkit_web_view_get_type
</span><span class="cx"> webkit_javascript_result_get_type
</span><span class="cx"> webkit_script_dialog_get_type
</span><ins>+webkit_web_view_session_state_get_type
</ins><span class="cx"> WebKitWebViewPrivate
</span><span class="cx"> &lt;/SECTION&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtk40types"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0.types (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0.types        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0.types        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -33,3 +33,4 @@
</span><span class="cx"> webkit_editor_state_get_type
</span><span class="cx"> webkit_install_missing_media_plugins_permission_request_get_type
</span><span class="cx"> webkit_console_message_get_type
</span><ins>+webkit_web_view_session_state_get_type
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkwebkit2h"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx"> #include &lt;webkit2/WebKitWebResource.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitWebView.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitWebViewBase.h&gt;
</span><ins>+#include &lt;webkit2/WebKitWebViewSessionState.h&gt;
</ins><span class="cx"> #include &lt;webkit2/WebKitWebsiteDataManager.h&gt;
</span><span class="cx"> #include &lt;webkit2/WebKitWindowProperties.h&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Tools/ChangeLog        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-01-04  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Allow to save and restore session
+        https://bugs.webkit.org/show_bug.cgi?id=115600
+
+        Reviewed by Michael Catanzaro.
+
+        Add test case to check the new session API.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp:
+        (testWebKitWebViewSessionState):
+        (testWebKitWebViewSessionStateWithFormData):
+        (beforeAll):
+
</ins><span class="cx"> 2016-01-04  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Bump EFL version to 1.16.1
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestBackForwardListcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp (194578 => 194579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp        2016-01-05 07:46:14 UTC (rev 194578)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestBackForwardList.cpp        2016-01-05 08:12:50 UTC (rev 194579)
</span><span class="lines">@@ -264,6 +264,108 @@
</span><span class="cx">     g_assert_cmpuint(webkit_back_forward_list_get_length(test-&gt;m_list), ==, kBackForwardListLimit);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void testWebKitWebViewSessionState(BackForwardListTest* test, gconstpointer)
+{
+    WebKitWebViewSessionState* state = webkit_web_view_get_session_state(test-&gt;m_webView);
+    g_assert(state);
+    GRefPtr&lt;WebKitWebView&gt; view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    WebKitBackForwardList* bfList = webkit_web_view_get_back_forward_list(view.get());
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_restore_session_state(view.get(), state);
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    GRefPtr&lt;GBytes&gt; data = adoptGRef(webkit_web_view_session_state_serialize(state));
+    g_assert(data);
+    state = webkit_web_view_session_state_new(data.get());
+    g_assert(state);
+    view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    bfList = webkit_web_view_get_back_forward_list(view.get());
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_restore_session_state(view.get(), state);
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_session_state_unref(state);
+
+    CString uriPage1 = kServer-&gt;getURIForPath(&quot;/Page1&quot;);
+    test-&gt;m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+    test-&gt;loadURI(uriPage1.data());
+    test-&gt;waitUntilLoadFinished();
+
+    CString uriPage2 = kServer-&gt;getURIForPath(&quot;/Page2&quot;);
+    test-&gt;m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+    test-&gt;loadURI(uriPage2.data());
+    test-&gt;waitUntilLoadFinished();
+
+    CString uriPage3 = kServer-&gt;getURIForPath(&quot;/Page3&quot;);
+    test-&gt;m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+    test-&gt;loadURI(uriPage3.data());
+    test-&gt;waitUntilLoadFinished();
+
+    test-&gt;m_changedFlags = BackForwardListTest::CurrentItem;
+    test-&gt;goBack();
+    test-&gt;waitUntilLoadFinished();
+
+    state = webkit_web_view_get_session_state(test-&gt;m_webView);
+    g_assert(state);
+
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_restore_session_state(view.get(), state);
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 3);
+
+    BackForwardListTest::checkItem(webkit_back_forward_list_get_nth_item(bfList, -1), &quot;Page1&quot;, uriPage1.data(), uriPage1.data());
+    BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(bfList), &quot;Page2&quot;, uriPage2.data(), uriPage2.data());
+    BackForwardListTest::checkItem(webkit_back_forward_list_get_nth_item(bfList, 1), &quot;Page3&quot;, uriPage3.data(), uriPage3.data());
+
+    data = adoptGRef(webkit_web_view_session_state_serialize(state));
+    g_assert(data);
+    webkit_web_view_session_state_unref(state);
+    state = webkit_web_view_session_state_new(data.get());
+    g_assert(state);
+
+    view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    bfList = webkit_web_view_get_back_forward_list(view.get());
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_restore_session_state(view.get(), state);
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 3);
+    webkit_web_view_session_state_unref(state);
+
+    BackForwardListTest::checkItem(webkit_back_forward_list_get_nth_item(bfList, -1), &quot;Page1&quot;, uriPage1.data(), uriPage1.data());
+    BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(bfList), &quot;Page2&quot;, uriPage2.data(), uriPage2.data());
+    BackForwardListTest::checkItem(webkit_back_forward_list_get_nth_item(bfList, 1), &quot;Page3&quot;, uriPage3.data(), uriPage3.data());
+
+    static const char* invalidSessionData = &quot;invalid session data&quot;;
+    data = adoptGRef(g_bytes_new_static(invalidSessionData, strlen(invalidSessionData)));
+    g_assert(!webkit_web_view_session_state_new(data.get()));
+}
+
+static void testWebKitWebViewSessionStateWithFormData(BackForwardListTest* test, gconstpointer)
+{
+    GUniquePtr&lt;char&gt; htmlPath(g_build_filename(Test::getResourcesDir(Test::WebKit2Resources).data(), &quot;simple-form.html&quot;, nullptr));
+    GUniquePtr&lt;char&gt; htmlURL(g_filename_to_uri(htmlPath.get(), nullptr, nullptr));
+    test-&gt;m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+    test-&gt;loadURI(htmlURL.get());
+    test-&gt;waitUntilLoadFinished();
+
+    webkit_web_view_run_javascript(test-&gt;m_webView, &quot;submitForm();&quot;, nullptr, nullptr, nullptr);
+    test-&gt;waitUntilLoadFinished();
+
+    WebKitWebViewSessionState* state = webkit_web_view_get_session_state(test-&gt;m_webView);
+    g_assert(state);
+    GRefPtr&lt;WebKitWebView&gt; view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    WebKitBackForwardList* bfList = webkit_web_view_get_back_forward_list(view.get());
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_restore_session_state(view.get(), state);
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 2);
+    GRefPtr&lt;GBytes&gt; data = adoptGRef(webkit_web_view_session_state_serialize(state));
+    g_assert(data);
+    state = webkit_web_view_session_state_new(data.get());
+    g_assert(state);
+    view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+    bfList = webkit_web_view_get_back_forward_list(view.get());
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 0);
+    webkit_web_view_restore_session_state(view.get(), state);
+    g_assert_cmpuint(webkit_back_forward_list_get_length(bfList), ==, 2);
+    webkit_web_view_session_state_unref(state);
+}
+
</ins><span class="cx"> void beforeAll()
</span><span class="cx"> {
</span><span class="cx">     kServer = new WebKitTestServer();
</span><span class="lines">@@ -271,6 +373,8 @@
</span><span class="cx"> 
</span><span class="cx">     BackForwardListTest::add(&quot;BackForwardList&quot;, &quot;navigation&quot;, testBackForwardListNavigation);
</span><span class="cx">     BackForwardListTest::add(&quot;BackForwardList&quot;, &quot;list-limit-and-cache&quot;, testBackForwardListLimitAndCache);
</span><ins>+    BackForwardListTest::add(&quot;WebKitWebView&quot;, &quot;session-state&quot;, testWebKitWebViewSessionState);
+    BackForwardListTest::add(&quot;WebKitWebView&quot;, &quot;session-state-with-form-data&quot;, testWebKitWebViewSessionStateWithFormData);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void afterAll()
</span></span></pre>
</div>
</div>

</body>
</html>