Index: embed/Makefile.am
===================================================================
RCS file: /cvs/gnome/epiphany/embed/Makefile.am,v
retrieving revision 1.21
diff -p -u -p -u -r1.21 Makefile.am
--- embed/Makefile.am	13 Sep 2004 09:21:05 -0000	1.21
+++ embed/Makefile.am	11 Nov 2004 00:23:38 -0000
@@ -37,6 +37,7 @@ INST_H_FILES = \
 	ephy-embed-prefs.h		\
 	ephy-embed-single.h		\
 	ephy-embed-shell.h		\
+	ephy-embed-shistory.h		\
 	ephy-encodings.h		\
 	ephy-history.h			\
 	ephy-password-manager.h		\
@@ -53,6 +54,7 @@ libephyembed_la_SOURCES = \
 	ephy-embed-persist.c		\
 	ephy-embed-single.c		\
 	ephy-embed-shell.c		\
+	ephy-embed-shistory.c		\
 	ephy-encodings.c		\
 	ephy-favicon-cache.c		\
 	ephy-history.c			\
Index: embed/ephy-embed-shistory.c
===================================================================
RCS file: embed/ephy-embed-shistory.c
diff -N embed/ephy-embed-shistory.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ embed/ephy-embed-shistory.c	11 Nov 2004 00:23:38 -0000
@@ -0,0 +1,145 @@
+/*
+ *  Copyright (C) 2003 Marco Pesenti Gritti
+ *  Copyright (C) 2003 Christian Persch
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *  $Id: ephy-password-shistory.c,v 1.6 2004/11/02 20:56:55 chpe Exp $
+ */
+
+#include "config.h"
+
+#include "ephy-embed-shistory.h"
+
+GType
+ephy_embed_shistory_get_type (void)
+{
+       static GType type = 0;
+
+	if (G_UNLIKELY (type == 0))
+	{
+		static const GTypeInfo our_info =
+		{
+			sizeof (EphyEmbedSHistoryIface),
+			NULL,
+			NULL,
+		};
+		
+		type = g_type_register_static (G_TYPE_INTERFACE,
+					       "EphyEmbedSHistory",
+					       &our_info,
+					       (GTypeFlags) 0);
+	}
+
+	return type;
+}
+
+void
+ephy_embed_shistory_clear (EphyEmbedSHistory *embed)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	iface->clear (embed);
+}
+
+int
+ephy_embed_shistory_serialise (EphyEmbedSHistory *embed,
+			       xmlTextWriterPtr writer)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	return iface->serialise (embed, writer);
+}
+
+int
+ephy_embed_shistory_deserialise	(EphyEmbedSHistory *embed,
+				 xmlNodePtr node)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	return iface->deserialise (embed, node);
+}
+
+/**
+ * ephy_embed_shistory_n_items:
+ * @embed: an #EphyEmbed
+ *
+ * Returns the number of items in @embed's history. In other words, returns the
+ * number of pages @embed has visited.
+ *
+ * The number is upper-bound by Mozilla's browser.sessionhistory.max_entries
+ * preference.
+ *
+ * Return value: the number of items in @embed's history
+ **/
+int
+ephy_embed_shistory_n_items (EphyEmbedSHistory *embed)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	return iface->shistory_n_items (embed);
+}
+
+/**
+ * ephy_embed_shistory_get_nth:
+ * @embed: an #EphyEmbed
+ * @nth: index of the desired page in @embed's browser history
+ * @is_relative: if %TRUE, add @embed's current history position to @nth
+ * @url: returned value of the history entry's URL
+ * @title: returned value of the history entry's title
+ *
+ * Fetches the @url and @title of the @nth item in @embed's session history.
+ * If @is_relative is %TRUE, @nth is an offset from the browser's current
+ * history position. For example, calling this function with @is_relative %TRUE
+ * and @nth %0 will return the URL and title of the current page.
+ **/
+void
+ephy_embed_shistory_get_nth (EphyEmbedSHistory *embed,
+			     int nth,
+			     gboolean is_relative,
+			     char **url,
+			     char **title)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	iface->shistory_get_nth (embed, nth, is_relative, url, title);
+}
+
+/**
+ * ephy_embed_shistory_get_pos:
+ * @embed: an #EphyEmbed
+ *
+ * Returns @embed's current position in its history. If the user never uses the
+ * "Back" button, this number will be the same as the return value of
+ * ephy_embed_shistory_n_items().
+ *
+ * Return value: @embed's current position in its history
+ **/
+int
+ephy_embed_shistory_get_pos (EphyEmbedSHistory *embed)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	return iface->shistory_get_pos (embed);
+}
+
+/**
+ * ephy_embed_shistory_go_nth:
+ * @embed: an #EphyEmbed
+ * @nth: desired history index
+ *
+ * Opens the webpage at location @nth in @embed's history.
+ **/
+void
+ephy_embed_shistory_go_nth (EphyEmbedSHistory *embed,
+			    int nth)
+{
+	EphyEmbedSHistoryIface *iface = EPHY_EMBED_SHISTORY_GET_IFACE (embed);
+	iface->shistory_go_nth (embed, nth);
+}
Index: embed/ephy-embed-shistory.h
===================================================================
RCS file: embed/ephy-embed-shistory.h
diff -N embed/ephy-embed-shistory.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ embed/ephy-embed-shistory.h	11 Nov 2004 00:23:38 -0000
@@ -0,0 +1,98 @@
+/*
+ *  Copyright (C) 2003 Marco Pesenti Gritti
+ *  Copyright (C) 2003 Christian Persch
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *  $Id: ephy-password-shistory.h,v 1.5 2004/08/21 16:33:58 chpe Exp $
+ */
+
+#ifndef EPHY_EMBED_SHISTORY_H
+#define EPHY_EMBED_SHISTORY_H
+
+#include <glib-object.h>
+#include <glib.h>
+
+#include <libxml/xmlwriter.h>
+#include <libxml/tree.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_EMBED_SHISTORY		(ephy_embed_shistory_get_type ())
+#define EPHY_EMBED_SHISTORY(o)			(G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_EMBED_SHISTORY, EphyEmbedSHistory))
+#define EPHY_EMBED_SHISTORY_IFACE(k)		(G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_EMBED_SHISTORY, EphyEmbedSHistoryIface))
+#define EPHY_IS_EMBED_SHISTORY(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED_SHISTORY))
+#define EPHY_IS_EMBED_SHISTORY_IFACE(k)		(G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED_SHISTORY))
+#define EPHY_EMBED_SHISTORY_GET_IFACE(inst)	(G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_EMBED_SHISTORY, EphyEmbedSHistoryIface))
+
+typedef struct _EphyEmbedSHistory	EphyEmbedSHistory;
+typedef struct _EphyEmbedSHistoryIface	EphyEmbedSHistoryIface;
+
+typedef struct _EphyEmbedSHistoryEntry	EphyEmbedSHistoryEntry;
+
+struct _EphyEmbedSHistoryEntry
+{
+	char *uri;
+	char *referrer_uri;
+	char *title;
+};
+
+struct _EphyEmbedSHistoryIface
+{
+	GTypeInterface base_iface;
+
+	/* Methods */
+	void	(* clear)		(EphyEmbedSHistory *embed);
+	int	(* serialise)		(EphyEmbedSHistory *embed,
+					 xmlTextWriterPtr writer);
+	int	(* deserialise)		(EphyEmbedSHistory *embed,
+					 xmlNodePtr node);
+	int	(* shistory_n_items)	(EphyEmbedSHistory *embed);
+	void	(* shistory_get_nth)	(EphyEmbedSHistory *embed,
+					 int nth,
+					 gboolean is_relative,
+					 char **url,
+					 char **title);
+	int	(* shistory_get_pos)	(EphyEmbedSHistory *embed);
+	void	(* shistory_go_nth)	(EphyEmbedSHistory *embed,
+					 int nth);
+};
+
+GType	ephy_embed_shistory_get_type	(void);
+
+void	ephy_embed_shistory_clear	(EphyEmbedSHistory *embed);
+
+int	ephy_embed_shistory_serialise	(EphyEmbedSHistory *embed,
+					 xmlTextWriterPtr writer);
+
+int	ephy_embed_shistory_deserialise	(EphyEmbedSHistory *embed,
+					 xmlNodePtr node);
+
+int	ephy_embed_shistory_n_items	(EphyEmbedSHistory *embed);
+
+void	ephy_embed_shistory_get_nth	(EphyEmbedSHistory *embed,
+					 int nth,
+					 gboolean is_relative,
+					 char **url,
+					 char **title);
+
+int	ephy_embed_shistory_get_pos	(EphyEmbedSHistory *embed);
+
+void	ephy_embed_shistory_go_nth	(EphyEmbedSHistory *embed,
+					 int nth);
+
+G_END_DECLS
+
+#endif
Index: embed/ephy-embed.c
===================================================================
RCS file: /cvs/gnome/epiphany/embed/ephy-embed.c,v
retrieving revision 1.47
diff -p -u -p -u -r1.47 ephy-embed.c
--- embed/ephy-embed.c	2 Nov 2004 20:56:55 -0000	1.47
+++ embed/ephy-embed.c	11 Nov 2004 00:23:38 -0000
@@ -576,81 +576,6 @@ ephy_embed_get_zoom (EphyEmbed *embed)
 }
 
 /**
- * ephy_embed_shistory_n_items:
- * @embed: an #EphyEmbed
- *
- * Returns the number of items in @embed's history. In other words, returns the
- * number of pages @embed has visited.
- *
- * The number is upper-bound by Mozilla's browser.sessionhistory.max_entries
- * preference.
- *
- * Return value: the number of items in @embed's history
- **/
-int
-ephy_embed_shistory_n_items  (EphyEmbed *embed)
-{
-	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
-	return iface->shistory_n_items (embed);
-}
-
-/**
- * ephy_embed_shistory_get_nth:
- * @embed: an #EphyEmbed
- * @nth: index of the desired page in @embed's browser history
- * @is_relative: if %TRUE, add @embed's current history position to @nth
- * @url: returned value of the history entry's URL
- * @title: returned value of the history entry's title
- *
- * Fetches the @url and @title of the @nth item in @embed's session history.
- * If @is_relative is %TRUE, @nth is an offset from the browser's current
- * history position. For example, calling this function with @is_relative %TRUE
- * and @nth %0 will return the URL and title of the current page.
- **/
-void
-ephy_embed_shistory_get_nth (EphyEmbed *embed,
-			     int nth,
-			     gboolean is_relative,
-			     char **url,
-			     char **title)
-{
-	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
-	iface->shistory_get_nth (embed, nth, is_relative, url, title);
-}
-
-/**
- * ephy_embed_shistory_get_pos:
- * @embed: an #EphyEmbed
- *
- * Returns @embed's current position in its history. If the user never uses the
- * "Back" button, this number will be the same as the return value of
- * ephy_embed_shistory_n_items().
- *
- * Return value: @embed's current position in its history
- **/
-int
-ephy_embed_shistory_get_pos (EphyEmbed *embed)
-{
-	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
-	return iface->shistory_get_pos (embed);
-}
-
-/**
- * ephy_embed_shistory_go_nth:
- * @embed: an #EphyEmbed
- * @nth: desired history index
- *
- * Opens the webpage at location @nth in @embed's history.
- **/
-void
-ephy_embed_shistory_go_nth (EphyEmbed *embed,
-			    int nth)
-{
-	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
-	iface->shistory_go_nth (embed, nth);
-}
-
-/**
  * ephy_embed_get_security_level:
  * @embed: an #EphyEmbed
  * @level: return value of security level
Index: embed/ephy-embed.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/ephy-embed.h,v
retrieving revision 1.43
diff -p -u -p -u -r1.43 ephy-embed.h
--- embed/ephy-embed.h	30 Oct 2004 17:46:05 -0000	1.43
+++ embed/ephy-embed.h	11 Nov 2004 00:23:38 -0000
@@ -153,15 +153,6 @@ struct _EphyEmbedIface
 							 gboolean toplevel);
 	char *		   (* get_link_message)		(EphyEmbed *embed);
 	char *		   (* get_js_status)		(EphyEmbed *embed);
-	int		   (* shistory_n_items)		(EphyEmbed *embed);
-	void		   (* shistory_get_nth)		(EphyEmbed *embed,
-							 int nth,
-							 gboolean is_relative,
-							 char **url,
-							 char **title);
-	int		   (* shistory_get_pos)		(EphyEmbed *embed);
-	void		   (* shistory_go_nth)		(EphyEmbed *embed,
-							 int nth);
 	void		   (* get_security_level)	(EphyEmbed *embed,
 						  	 EmbedSecurityLevel *level,
 						  	 char **description);
@@ -225,19 +216,6 @@ void		  ephy_embed_go_back			(EphyEmbed 
 void		  ephy_embed_go_forward			(EphyEmbed *embed);
 
 void		  ephy_embed_go_up			(EphyEmbed *embed);
-
-int		  ephy_embed_shistory_n_items		(EphyEmbed *embed);
-
-void		  ephy_embed_shistory_get_nth		(EphyEmbed *embed,
-							 int nth,
-							 gboolean is_relative,
-							 char **url,
-							 char **title);
-
-int		  ephy_embed_shistory_get_pos		(EphyEmbed *embed);
-
-void		  ephy_embed_shistory_go_nth		(EphyEmbed *embed,
-							 int nth);
 
 void		  ephy_embed_get_security_level		(EphyEmbed *embed,
 							 EmbedSecurityLevel *level,
Index: embed/mozilla/EphyBrowser.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/EphyBrowser.cpp,v
retrieving revision 1.61
diff -p -u -p -u -r1.61 EphyBrowser.cpp
--- embed/mozilla/EphyBrowser.cpp	2 Nov 2004 20:56:55 -0000	1.61
+++ embed/mozilla/EphyBrowser.cpp	11 Nov 2004 00:23:39 -0000
@@ -647,6 +647,139 @@ nsresult EphyBrowser::GetSHUrlAtIndex (P
 	return NS_OK;
 }
 
+nsresult EphyBrowser::ClearSHistory ()
+{
+	nsCOMPtr<nsISHistory> sh;
+	SHistory (getter_AddRefs (sh));
+	NS_ENSURE_TRUE (sh, NS_ERROR_FAILURE);
+
+	PRInt32 count = 0;
+	sh->GetCount (&count);
+	sh->PurgeHistory (count);
+}
+
+#include <libxml/xmlwriter.h>
+#include <libxml/tree.h>
+
+nsresult EphyBrowser::SerialiseSHEntry (void *writerptr, nsISHEntry *aEntry, int *_retval)
+{
+	xmlTextWriterPtr writer = (xmlTextWriterPtr) writerptr;
+	int ret = 0;
+
+	PRBool isSubFrame = PR_FALSE;
+	nsCOMPtr<nsIURI> uri;
+	PRUnichar *title = nsnull;
+
+	aEntry->GetIsSubFrame (&isSubFrame);
+	if (isSubFrame) goto out;
+
+	ret = xmlTextWriterStartElement (writer, (const xmlChar *) "entry");
+	if (ret < 0) goto out;
+
+	aEntry->GetURI (getter_AddRefs (uri));
+	if (uri)
+	{
+		nsEmbedCString spec;
+		uri->GetSpec (spec);
+
+		ret = xmlTextWriterWriteElement (writer, (const xmlChar *) "uri",
+						 (const xmlChar *) spec.get());
+		if (ret < 0) goto out;
+	}
+
+	aEntry->GetTitle (&title);
+	if (title)
+	{
+		nsEmbedCString cTitle;
+		NS_UTF16ToCString (nsEmbedString(title),
+				   NS_CSTRING_ENCODING_UTF8, cTitle);
+
+		ret = xmlTextWriterWriteElement (writer, (const xmlChar *) "title",
+						 (const xmlChar *) cTitle.get());
+		if (ret < 0) goto out;
+	}
+
+	ret = xmlTextWriterEndElement (writer); /* </entry> */
+out:
+	*_retval = ret;
+
+	return NS_OK;
+}
+
+nsresult EphyBrowser::SerialiseSHistory (void *writerptr, int *_retval)
+{
+	xmlTextWriterPtr writer = (xmlTextWriterPtr) writerptr;
+
+	nsCOMPtr<nsISHistory> sh;
+	nsCOMPtr<nsISimpleEnumerator> enumerator;
+
+	GetSHistory (getter_AddRefs (sh));
+	if (!sh) goto out;
+
+	sh->GetSHistoryEnumerator (getter_AddRefs (enumerator));
+	if (!enumerator) goto out;
+
+	ret = xmlTextWriterStartElement (writer, (const xmlChar *) "session-history");
+	if (ret < 0) goto out;
+
+	PRBool hasMore;
+	while (NS_SUCCEEDED (enumerator->HasMoreElements (&hasMore)) &&
+	       hasMore && ret >= 0)
+	{
+		nsCOMPtr<nsISupports> element;
+		enumerator->GetNext (getter_AddRefs (element));
+
+		nsCOMPtr<nsIHistoryEntry> hEntry (do_QueryInterface (element));
+		if (!hEntry) continue;
+
+		SerialiseSHEntry (writerptr, hEntry, &ret);
+	}
+	if (ret < 0) goto out;
+
+	ret = xmlTextWriterEndElement (writer); /* </session-history> */
+out:
+	*_retval = ret;
+
+	return NS_OK;
+}
+
+nsresult EphyBrowser::DeserialisedSHEntry (void *nodeptr, nsISHistory *aSHistory)
+{
+	xmlNodePtr child = (xmlNodePtr) nodeptr;
+	
+	while (child)
+	{
+		if (xmlStrEqual (child->name, (const xmlChar *) "uri"))
+		{
+		}
+		else if (xmlStrEqual (child->name, (const xmlChar *) "title"))
+		{
+		}
+
+		child = child->next;
+	}
+}
+
+nsresult EphyBrowser::DeserialisedSHistory (void *nodeptr, int *_retval)
+{
+	xmlNodePtr node = (xmlNodePtr) nodeptr;
+	xmlNodePtr child = node->children;
+
+	nsCOMPtr<nsISHistory> sh;
+	GetSHistory (getter_AddRefs (sh));
+	NS_ENSURE_TRUE (sh, NS_ERROR_FAILURE);
+
+	while (child)
+	{
+		if (xmlStrEqual (child->name, (const xmlChar *) "entry"))
+		{
+			DeserialisedSHEntry (child->children, sh);
+		}
+
+		child = child->next;
+	}
+}
+
 nsresult EphyBrowser::FindSetProperties (const PRUnichar *search_string,
 			                 PRBool case_sensitive,
 					 PRBool wrap_around)
Index: embed/mozilla/EphyBrowser.h
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/EphyBrowser.h,v
retrieving revision 1.29
diff -p -u -p -u -r1.29 EphyBrowser.h
--- embed/mozilla/EphyBrowser.h	2 Nov 2004 20:56:55 -0000	1.29
+++ embed/mozilla/EphyBrowser.h	11 Nov 2004 00:23:39 -0000
@@ -42,6 +42,8 @@
 #include "nsIContentViewer.h"
 #endif
 
+class nsISHEntry;
+
 class EphyEventListener : public nsIDOMEventListener
 {
 public:
@@ -113,6 +115,9 @@ public:
 	nsresult GetSHTitleAtIndex (PRInt32 index, PRUnichar **title);
 	nsresult GetSHUrlAtIndex (PRInt32 index, nsACString &url);
 	nsresult GoToHistoryIndex (PRInt16 index);
+	nsresult ClearSHistory ();
+	nsresult SerialiseSHistory (void *writerptr, int *_retval);
+	nsresult DeserialisedSHistory (void *nodeptr, int *_retval);
 
 #ifdef GTKMOZEMBED_BROKEN_RELOAD
 	enum ReloadType { RELOAD_NORMAL		 = 0,
@@ -159,6 +164,8 @@ private:
 	nsresult GetContentViewer (nsIContentViewer **aViewer);
 	nsresult GetDocumentHasModifiedForms (nsIDOMDocument *aDomDoc, PRUint32 *aNumTextFields, PRBool *aHasTextArea);
 	PRBool   CompareFormsText (nsAString &aDefaultText, nsAString &aUserText);
+	nsresult SerialiseSHEntry (void *writerptr, nsISHEntry *aEntry, int *_retval);
+	nsresult DeserialisedSHEntry (void *nodeptr, nsISHistory *aSHistory);
 };
 
 #endif
Index: embed/mozilla/mozilla-embed.cpp
===================================================================
RCS file: /cvs/gnome/epiphany/embed/mozilla/mozilla-embed.cpp,v
retrieving revision 1.88
diff -p -u -p -u -r1.88 mozilla-embed.cpp
--- embed/mozilla/mozilla-embed.cpp	2 Nov 2004 20:56:55 -0000	1.88
+++ embed/mozilla/mozilla-embed.cpp	11 Nov 2004 00:23:39 -0000
@@ -27,6 +27,7 @@
 #include "mozilla-embed-event.h"
 #include "ephy-embed-shell.h"
 #include "ephy-command-manager.h"
+#include "ephy-embed-shistory.h"
 #include "ephy-string.h"
 #include "ephy-debug.h"
 
@@ -47,6 +48,7 @@ static void	mozilla_embed_init		(Mozilla
 static void	mozilla_embed_destroy		(GtkObject *object);
 static void	mozilla_embed_finalize		(GObject *object);
 static void	ephy_embed_iface_init		(EphyEmbedIface *iface);
+static void	ephy_embed_shistory_iface_init	(EphyEmbedSHistoryIface *iface);
 
 static void mozilla_embed_location_changed_cb	(GtkMozEmbed *embed,
 						 MozillaEmbed *membed);
@@ -157,6 +159,13 @@ mozilla_embed_get_type (void)
         		NULL
      		 };
 	
+		static const GInterfaceInfo ephy_embed_shistory_info =
+		{
+			(GInterfaceInitFunc) ephy_embed_shistory_iface_init,
+        		NULL,
+        		NULL
+     		 };
+	
                 type = g_type_register_static (GTK_TYPE_MOZ_EMBED,
 					       "MozillaEmbed",
 					       &our_info, 
@@ -167,6 +176,9 @@ mozilla_embed_get_type (void)
 		g_type_add_interface_static (type,
                                    	     EPHY_TYPE_COMMAND_MANAGER,
                                    	     &ephy_command_manager_info);
+		g_type_add_interface_static (type,
+                                   	     EPHY_TYPE_EMBED_SHISTORY,
+                                   	     &ephy_embed_shistory_info);
         }
 
         return type;
@@ -560,7 +572,7 @@ impl_get_zoom (EphyEmbed *embed)
 }
 
 static int
-impl_shistory_n_items (EphyEmbed *embed)
+impl_shistory_n_items (EphyEmbedSHistory *embed)
 {
 	MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
 	nsresult rv;
@@ -572,7 +584,7 @@ impl_shistory_n_items (EphyEmbed *embed)
 }
 
 static void
-impl_shistory_get_nth (EphyEmbed *embed, 
+impl_shistory_get_nth (EphyEmbedSHistory *embed,
                        int nth,
                        gboolean is_relative,
                        char **aUrl,
@@ -609,7 +621,7 @@ impl_shistory_get_nth (EphyEmbed *embed,
 }
 
 static int
-impl_shistory_get_pos (EphyEmbed *embed)
+impl_shistory_get_pos (EphyEmbedSHistory *embed)
 {
 	MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
 	nsresult rv;
@@ -621,13 +633,50 @@ impl_shistory_get_pos (EphyEmbed *embed)
 }
 
 static void
-impl_shistory_go_nth (EphyEmbed *embed, 
+impl_shistory_go_nth (EphyEmbedSHistory *embed,
                       int nth)
 {
 	MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
 
 	mpriv->browser->GoToHistoryIndex (nth);
 }
+#include "nsISHEntry.h"
+#include "nsISHistory.h"
+#include "nsIHistoryEntry.h"
+#include "nsISimpleEnumerator.h"
+
+void
+impl_shistory_clear (EphyEmbedSHistory *embed)
+{
+	MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv;
+
+	priv->browser->ClearSHistory ();
+}
+
+
+int
+impl_shistory_serialise	(EphyEmbedSHistory *embed,
+			 xmlTextWriterPtr writer)
+{
+	MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (embed)->priv;
+	int ret = 0;
+
+	priv->browser->SerialiseSHistory ((void *) writer, &ret);
+
+	return ret;
+}
+
+int
+impl_shistory_deserialise (EphyEmbedSHistory *embed,
+			   xmlNodePtr node)
+{
+	MozillaEmbedPrivate *mpriv = MOZILLA_EMBED (embed)->priv;
+	int ret = 0;
+
+	priv->browser->DeserialisedSHistory ((void *) node, &ret);
+
+	return ret;
+}
 
 static void
 impl_get_security_level (EphyEmbed *embed, 
@@ -1136,10 +1185,6 @@ ephy_embed_iface_init (EphyEmbedIface *i
 	iface->reload = impl_reload;
 	iface->set_zoom = impl_set_zoom;
 	iface->get_zoom = impl_get_zoom;
-	iface->shistory_n_items = impl_shistory_n_items;
-	iface->shistory_get_nth = impl_shistory_get_nth;
-	iface->shistory_get_pos = impl_shistory_get_pos;
-	iface->shistory_go_nth = impl_shistory_go_nth;
 	iface->get_security_level = impl_get_security_level;
 	iface->find_next = impl_find_next;
 	iface->activate = impl_activate;
@@ -1152,6 +1197,18 @@ ephy_embed_iface_init (EphyEmbedIface *i
 	iface->print_preview_n_pages = impl_print_preview_n_pages;
 	iface->print_preview_navigate = impl_print_preview_navigate;
 	iface->has_modified_forms = impl_has_modified_forms;
+}
+
+static void
+ephy_embed_shistory_iface_init (EphyEmbedSHistoryIface *iface)
+{
+	iface->clear = impl_shistory_clear;
+	iface->serialise = impl_shistory_serialise;
+	iface->deserialise = impl_shistory_deserialise;
+	iface->shistory_n_items = impl_shistory_n_items;
+	iface->shistory_get_nth = impl_shistory_get_nth;
+	iface->shistory_get_pos = impl_shistory_get_pos;
+	iface->shistory_go_nth = impl_shistory_go_nth;
 }
 
 static void
Index: src/ephy-navigation-action.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-navigation-action.c,v
retrieving revision 1.20
diff -p -u -p -u -r1.20 ephy-navigation-action.c
--- src/ephy-navigation-action.c	2 Nov 2004 20:57:21 -0000	1.20
+++ src/ephy-navigation-action.c	11 Nov 2004 00:23:40 -0000
@@ -21,6 +21,8 @@
 #include "config.h"
 
 #include "ephy-navigation-action.h"
+#include "ephy-embed.h"
+#include "ephy-embed-shistory.h"
 #include "ephy-window.h"
 #include "ephy-string.h"
 #include "ephy-favicon-cache.h"
@@ -134,10 +136,10 @@ static void
 activate_back_or_forward_menu_item_cb (GtkWidget *menuitem,
 				       EphyWindow *window)
 {
-	EphyEmbed *embed;
+	EphyEmbedSHistory *embed;
 	int go_nth;
 
-	embed = ephy_window_get_active_embed (window);
+	embed = EPHY_EMBED_SHISTORY (ephy_window_get_active_embed (window));
 	g_return_if_fail (embed != NULL);
 
 	go_nth = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (menuitem), NTH_DATA_KEY));
@@ -166,11 +168,11 @@ build_back_or_forward_menu (EphyNavigati
 {
 	EphyWindow *window = action->priv->window;
 	GtkMenuShell *menu;
-	EphyEmbed *embed;
+	EphyEmbedSHistory *embed;
 	int pos, count;
 	int start, end;
 
-	embed = ephy_window_get_active_embed (window);
+	embed = EPHY_EMBED_SHISTORY (ephy_window_get_active_embed (window));
 	g_return_val_if_fail (embed != NULL, NULL);
 
 	pos = ephy_embed_shistory_get_pos (embed);
Index: src/ephy-session.c
===================================================================
RCS file: /cvs/gnome/epiphany/src/ephy-session.c,v
retrieving revision 1.29
diff -p -u -p -u -r1.29 ephy-session.c
--- src/ephy-session.c	7 Nov 2004 20:07:02 -0000	1.29
+++ src/ephy-session.c	11 Nov 2004 00:23:40 -0000
@@ -24,8 +24,10 @@
 
 #include "ephy-session.h"
 
-#include "ephy-window.h"
+#include "ephy-embed.h"
+#include "ephy-embed-shistory.h"
 #include "ephy-tab.h"
+#include "ephy-window.h"
 #include "ephy-shell.h"
 #include "ephy-history-window.h"
 #include "ephy-bookmarks-editor.h"
@@ -470,6 +472,9 @@ write_tab (xmlTextWriterPtr writer,
 	g_free (location);
 	if (ret < 0) return ret;
 
+	ret = ephy_embed_shistory_serialise (EPHY_EMBED_SHISTORY (embed), writer);
+	if (ret < 0) return ret;
+
 	ret = xmlTextWriterEndElement (writer); /* embed */
 	return ret;
 }
@@ -653,24 +658,46 @@ out:
 }
 
 static void
+parse_embed_shistory (xmlNodePtr child, EphyTab *tab)
+{
+	while (child != NULL)
+	{
+		if (xmLStrEqual (child->name, "session-history"))
+		{
+			EphyEmbed *embed;
+			EphyEmbedSHistory *shistory;
+
+			embed = ephy_tab_get_embed (tab);
+			shistory = EPHY_EMBED_SHISTORY (embed);
+			ephy_embed_shistory_deserialise (shistory, child);
+		}
+
+		child = child->next;
+	}
+}
+
+static void
 parse_embed (xmlNodePtr child, EphyWindow *window)
 {
 	while (child != NULL)
 	{
 		if (strcmp ((char *) child->name, "embed") == 0)
 		{
+			EphyTab *tab;
 			xmlChar *url;
 
 			g_return_if_fail (window != NULL);
 
 			url = xmlGetProp (child, (const xmlChar *) "url");
 
-			ephy_shell_new_tab (ephy_shell, window, NULL, (char *) url,
-					    EPHY_NEW_TAB_IN_EXISTING_WINDOW |
-					    EPHY_NEW_TAB_OPEN_PAGE |
-					    EPHY_NEW_TAB_APPEND_LAST);
+			tab = ephy_shell_new_tab (ephy_shell, window, NULL, (char *) url,
+						  EPHY_NEW_TAB_IN_EXISTING_WINDOW |
+						  EPHY_NEW_TAB_OPEN_PAGE |
+						  EPHY_NEW_TAB_APPEND_LAST);
 
 			xmlFree (url);
+
+			parse_embed_shistory (child->children, tab);
 		}
 
 		child = child->next;
