Index: embed/ephy-embed.h
===================================================================
--- embed/ephy-embed.h	(revisione 7514)
+++ embed/ephy-embed.h	(copia locale)
@@ -101,6 +101,20 @@ typedef enum
 	EPHY_EMBED_DOCUMENT_OTHER
 } EphyEmbedDocumentType;
 
+typedef enum
+{
+	EPHY_EMBED_NAV_UP	= 1 << 0,
+	EPHY_EMBED_NAV_BACK	= 1 << 1,
+	EPHY_EMBED_NAV_FORWARD	= 1 << 2
+} EphyEmbedNavigationFlags;
+
+typedef enum
+{
+	EPHY_EMBED_ADDRESS_EXPIRE_NOW,
+	EPHY_EMBED_ADDRESS_EXPIRE_NEXT,
+	EPHY_EMBED_ADDRESS_EXPIRE_CURRENT
+} EphyEmbedAddressExpire;
+
 struct _EphyEmbedIface
 {
 	GTypeInterface base_iface;
Index: embed/mozilla/mozilla-embed.h
===================================================================
--- embed/mozilla/mozilla-embed.h	(revisione 7514)
+++ embed/mozilla/mozilla-embed.h	(copia locale)
@@ -56,6 +56,19 @@ struct MozillaEmbedClass
 
 GType	         mozilla_embed_get_type         (void);
 
+//added
+
+const char *	mozilla_embed_get_status_message (MozillaEmbed *embed);
+
+const char *	mozilla_embed_get_typed_address (MozillaEmbed *embed);
+
+void		mozilla_embed_set_typed_address (MozillaEmbed *embed,
+						 const char *address,
+						 EphyEmbedAddressExpire expire);
+
+void		mozilla_embed_set_icon_address (MozillaEmbed *embed,
+						const char *address);
+
 /* The following are private to the embed implementation */
 
 gpointer        _mozilla_embed_get_ephy_browser (MozillaEmbed *embed);
Index: embed/mozilla/mozilla-embed.cpp
===================================================================
--- embed/mozilla/mozilla-embed.cpp	(revisione 7514)
+++ embed/mozilla/mozilla-embed.cpp	(copia locale)
@@ -43,6 +43,20 @@
 #include "ephy-embed-single.h"
 #include "ephy-string.h"
 #include "mozilla-embed-event.h"
+#include "ephy-embed-type-builtins.h"
+#include "ephy-window.h"
+#include "ephy-history.h"
+#include "ephy-favicon-cache.h"
+#include "ephy-permission-manager.h"
+#include "ephy-shell.h"
+#include "eel-gconf-extensions.h"
+
+#include <glib/gi18n.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include <libgnomevfs/gnome-vfs-result.h>
+#include <libgnomevfs/gnome-vfs-monitor.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
 
 #include "mozilla-embed.h"
 
@@ -52,8 +66,6 @@ static void	mozilla_embed_destroy		(GtkO
 static void	mozilla_embed_finalize		(GObject *object);
 static void	ephy_embed_iface_init		(EphyEmbedIface *iface);
 
-static void mozilla_embed_location_changed_cb	(GtkMozEmbed *embed,
-						 MozillaEmbed *membed);
 static void mozilla_embed_net_state_all_cb	(GtkMozEmbed *embed,
 						 const char *aURI,
 						 gint state,
@@ -77,6 +89,13 @@ static void mozilla_embed_security_chang
 						 PRUint32 state,
 						 MozillaEmbed *membed);
 static EphyEmbedSecurityLevel mozilla_embed_security_level (PRUint32 state);
+//added later
+static guint popup_blocker_n_hidden (MozillaEmbed *embed);
+static gboolean mozilla_embed_get_popups_allowed (MozillaEmbed *embed);
+static void mozilla_embed_set_popups_allowed (MozillaEmbed *embed, gboolean allowed);
+static void mozilla_embed_set_link_message (MozillaEmbed *embed, char *message);
+static void mozilla_embed_set_title (MozillaEmbed *embed, char *title);
+static void mozilla_embed_address_cb (GtkMozEmbed *embed, MozillaEmbed *membed);
 
 #define MOZILLA_EMBED_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED, MozillaEmbedPrivate))
 
@@ -92,10 +111,82 @@ struct MozillaEmbedPrivate
 {
 	EphyBrowser *browser;
 	MozillaEmbedLoadState load_state;
+	
+	// Copied from EphyTab
+	char *status_message;
+	char *link_message;
+	char *address;
+	char *typed_address;
+	char *title;
+	char *loading_title;
+	char *icon_address;
+	GdkPixbuf *icon;
+	int cur_requests;
+	int total_requests;
+	int width;
+	int height;
+	float zoom;
+	GSList *hidden_popups;
+	GSList *shown_popups;
+	EphyEmbedNavigationFlags nav_flags;
+	EphyEmbedDocumentType document_type;
+	guint idle_resize_handler;
+
+	gint8 load_percent;
+	/* Flags */
+	guint is_blank : 1;
+	guint visibility : 1;
+	guint is_loading : 1;
+	guint is_setting_zoom : 1;
+	EphyEmbedSecurityLevel security_level;
+	/* guint security_level : 3; ? */
+	EphyEmbedAddressExpire address_expire;
+	/* guint address_expire : 2; ? */
+
+	/* File watch */
+	GnomeVFSMonitorHandle *monitor;
+	guint reload_scheduled_id;
+	guint reload_delay_ticks;
 };
 
 #define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"
 
+/* Added from EphyTab */
+
+typedef struct
+{
+	char *url;
+	char *name;
+	char *features;
+} PopupInfo;
+
+enum
+{
+	PROP_0,
+	PROP_ADDRESS,
+	PROP_DOCUMENT_TYPE,
+	PROP_ICON,
+	PROP_ICON_ADDRESS,
+	PROP_LOAD_PROGRESS,
+	PROP_LOAD_STATUS,
+	PROP_MESSAGE,
+	PROP_NAVIGATION,
+	PROP_SECURITY,
+	PROP_HIDDEN_POPUP_COUNT,
+	PROP_POPUPS_ALLOWED,
+	PROP_TITLE,
+	PROP_TYPED_ADDRESS,
+	PROP_VISIBLE,
+	PROP_ZOOM
+};
+
+#define MAX_HIDDEN_POPUPS	5
+#define RELOAD_DELAY		250 /* ms */
+#define RELOAD_DELAY_MAX_TICKS	40  /* RELOAD_DELAY * RELOAD_DELAY_MAX_TICKS = 10 s */
+#define MAX_TITLE_LENGTH	512 /* characters */
+
+/* */
+
 static GObjectClass *parent_class = NULL;
 
 static void
@@ -232,6 +323,104 @@ mozilla_embed_constructor (GType type, g
 }
 
 static void
+mozilla_embed_get_property (GObject *object,
+			    guint prop_id,
+			    GValue *value,
+			    GParamSpec *pspec)
+{
+	MozillaEmbed *embed = MOZILLA_EMBED (object);
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	switch (prop_id)
+	{
+		case PROP_ADDRESS:
+			g_value_set_string (value, priv->address);
+			break;
+		case PROP_DOCUMENT_TYPE:
+			g_value_set_enum (value, priv->document_type);
+			break;
+		case PROP_ICON:
+			g_value_set_object (value, priv->icon);
+			break;
+		case PROP_ICON_ADDRESS:
+			g_value_set_string (value, priv->icon_address);
+			break;
+		case PROP_LOAD_PROGRESS:
+			g_value_set_int (value, priv->load_percent);
+			break;
+		case PROP_LOAD_STATUS:
+			g_value_set_boolean (value, priv->is_loading);
+			break;
+		case PROP_MESSAGE:
+			g_value_set_string (value, mozilla_embed_get_status_message (embed));
+			break;
+		case PROP_NAVIGATION:
+			g_value_set_flags (value, priv->nav_flags);
+			break;
+		case PROP_SECURITY:
+			g_value_set_enum (value, priv->security_level);
+			break;
+		case PROP_HIDDEN_POPUP_COUNT:
+			g_value_set_int (value, popup_blocker_n_hidden (embed));
+			break;
+		case PROP_POPUPS_ALLOWED:
+			g_value_set_boolean
+				(value, mozilla_embed_get_popups_allowed (embed));
+			break;
+		case PROP_TITLE:
+			g_value_set_string (value, priv->title);
+			break;
+		case PROP_TYPED_ADDRESS:
+			g_value_set_string (value, mozilla_embed_get_typed_address (embed));
+			break;
+		case PROP_VISIBLE:
+			g_value_set_boolean (value, priv->visibility);
+			break;
+		case PROP_ZOOM:
+			g_value_set_float (value, priv->zoom);
+			break;
+	}
+}
+
+static void
+mozilla_embed_set_property (GObject *object,
+		       guint prop_id,
+		       const GValue *value,
+		       GParamSpec *pspec)
+{
+	MozillaEmbed *embed = MOZILLA_EMBED (object);
+
+	switch (prop_id)
+
+	{
+		case PROP_TYPED_ADDRESS:
+			mozilla_embed_set_typed_address (embed, g_value_get_string (value),
+							 EPHY_EMBED_ADDRESS_EXPIRE_NOW);
+			break;
+		case PROP_POPUPS_ALLOWED:
+			mozilla_embed_set_popups_allowed (embed, g_value_get_boolean (value));
+			break;
+		case PROP_ICON_ADDRESS:
+			mozilla_embed_set_icon_address (embed, g_value_get_string (value));
+			break;
+		case PROP_ADDRESS:
+		case PROP_DOCUMENT_TYPE:
+		case PROP_ICON:
+		case PROP_LOAD_PROGRESS:
+		case PROP_LOAD_STATUS:
+		case PROP_MESSAGE:
+		case PROP_NAVIGATION:
+		case PROP_SECURITY:
+		case PROP_HIDDEN_POPUP_COUNT:
+		case PROP_TITLE:
+		case PROP_VISIBLE:
+		case PROP_ZOOM:
+			/* read only */
+			break;
+	}
+}
+
+static void
 mozilla_embed_class_init (MozillaEmbedClass *klass)
 {
         GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -242,23 +431,322 @@ mozilla_embed_class_init (MozillaEmbedCl
 
 	object_class->constructor = mozilla_embed_constructor;
 	object_class->finalize = mozilla_embed_finalize;
+	object_class->get_property = mozilla_embed_get_property;
+	object_class->set_property = mozilla_embed_set_property;
 
 	gtk_object_class->destroy = mozilla_embed_destroy;
 
 	widget_class->grab_focus = mozilla_embed_grab_focus;
 	widget_class->realize = mozilla_embed_realize;
+	
+	g_object_class_install_property (object_class,
+					 PROP_ADDRESS,
+					 g_param_spec_string ("address",
+							      "Address",
+							      "The tab's address",
+							      "",
+							      (GParamFlags)
+							      (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_DOCUMENT_TYPE,
+					 g_param_spec_enum ("document-type",
+							    "Document Type",
+							    "The tab's documen type",
+							    EPHY_TYPE_EMBED_DOCUMENT_TYPE,
+							    EPHY_EMBED_DOCUMENT_HTML,
+							    (GParamFlags)
+							    (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_ICON,
+					 g_param_spec_object ("icon",
+							      "Icon",
+							      "The tab icon's",
+							      GDK_TYPE_PIXBUF,
+							      (GParamFlags)
+							      (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_ICON_ADDRESS,
+					 g_param_spec_string ("icon-address",
+							      "Icon address",
+							      "The tab icon's address",
+							      NULL,
+							      (GParamFlags)
+							      (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_LOAD_PROGRESS,
+					 g_param_spec_int ("load-progress",
+							   "Load progress",
+							   "The tab's load progress in percent",
+							   0,
+							   100,
+							   0,
+							   (GParamFlags)
+							   (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_LOAD_STATUS,
+					 g_param_spec_boolean ("load-status",
+							       "Load status",
+							       "The tab's load status",
+							       FALSE,
+							       (GParamFlags)
+							       (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_MESSAGE,
+					 g_param_spec_string ("message",
+							      "Message",
+							      "The tab's statusbar message",
+							      NULL,
+							      (GParamFlags)
+							      (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_NAVIGATION,
+					 g_param_spec_flags ("navigation",
+							     "Navigation flags",
+							     "The tab's navigation flags",
+							     EPHY_TYPE_TAB_NAVIGATION_FLAGS,
+							     0,
+							     (GParamFlags)
+							     (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_SECURITY,
+					 g_param_spec_enum ("security-level",
+							    "Security Level",
+							    "The tab's security level",
+							    EPHY_TYPE_EMBED_SECURITY_LEVEL,
+							    EPHY_EMBED_STATE_IS_UNKNOWN,
+							    (GParamFlags)
+							    (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_HIDDEN_POPUP_COUNT,
+					 g_param_spec_int ("hidden-popup-count",
+							   "Number of Blocked Popups",
+							   "The tab's number of blocked popup windows",
+							   0,
+							   G_MAXINT,
+							   0,
+							   (GParamFlags)
+							   (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_POPUPS_ALLOWED,
+					 g_param_spec_boolean ("popups-allowed",
+						 	       "Popups Allowed",
+							       "Whether popup windows are to be displayed",
+							       FALSE,
+							       (GParamFlags)
+							       (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_TITLE,
+					 g_param_spec_string ("title",
+							      "Title",
+							      "The tab's title",
+							      _("Blank page"),
+							      (GParamFlags)
+							      (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_TYPED_ADDRESS,
+					 g_param_spec_string ("typed-address",
+							      "Typed Address",
+							      "The typed address",
+							      "",
+							      (GParamFlags)
+							      (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_VISIBLE,
+					 g_param_spec_boolean ("visibility",
+							       "Visibility",
+							       "The tab's visibility",
+							       TRUE,
+							       (GParamFlags)
+							       (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
+
+	g_object_class_install_property (object_class,
+					 PROP_ZOOM,
+					 g_param_spec_float ("zoom",
+							     "Zoom",
+							     "The tab's zoom",
+							     ZOOM_MINIMAL,
+							     ZOOM_MAXIMAL,
+							     1.0,
+							     (GParamFlags)
+							     (G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)));
 
 	g_type_class_add_private (object_class, sizeof(MozillaEmbedPrivate));
 }
 
 static void
+mozilla_embed_visibility_cb (GtkMozEmbed *embed,
+			     gboolean visibility,
+			     MozillaEmbed *membed)
+{
+	/* if (visibility)
+	{
+		gtk_widget_show (GTK_WIDGET (embed));
+	}
+	else
+	{
+		gtk_widget_hide (GTK_WIDGET (embed));
+	} */
+
+	membed->priv->visibility = visibility;
+
+	g_object_notify (G_OBJECT (embed), "visibility");
+}
+
+static char *
+get_title_from_address (const char *address)
+{
+	GnomeVFSURI *uri;
+	char *title;
+
+	if (address == NULL) return NULL;
+		
+	uri = gnome_vfs_uri_new (address);
+	if (uri == NULL) return g_strdup (address);
+		
+	title = gnome_vfs_uri_to_string (uri,
+			GNOME_VFS_URI_HIDE_USER_NAME |
+			GNOME_VFS_URI_HIDE_PASSWORD |
+			GNOME_VFS_URI_HIDE_HOST_PORT |
+			GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD |
+			GNOME_VFS_URI_HIDE_FRAGMENT_IDENTIFIER);
+	gnome_vfs_uri_unref (uri);
+
+	return title;
+}
+
+static void
+mozilla_embed_set_loading_title (MozillaEmbed *embed,
+			    const char *title,
+			    gboolean is_address)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+	char *freeme = NULL;
+
+	g_free (priv->loading_title);
+	priv->loading_title = NULL;
+
+	if (is_address)
+	{
+		title = freeme = get_title_from_address (title);	
+	}
+
+	if (title != NULL && title[0] != '\0')
+	{
+		/* translators: %s here is the address of the web page */
+		priv->loading_title = g_strdup_printf (_("Loading “%s”…"), title);
+	}
+	else
+	{
+		priv->loading_title = g_strdup (_("Loading…"));
+	}
+
+	g_free (freeme);
+}
+
+static void
+mozilla_embed_title_cb (MozillaEmbed *embed)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+	GObject *object = G_OBJECT (embed);
+
+	g_object_freeze_notify (object);
+
+	mozilla_embed_set_title (embed, gtk_moz_embed_get_title (GTK_MOZ_EMBED (embed)));
+
+	mozilla_embed_set_loading_title (embed, priv->title, FALSE);
+
+	g_object_thaw_notify (object);
+}
+
+/* consumes |address| */
+static void
+mozilla_embed_set_address (MozillaEmbed *embed,
+			   char *address)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+	GObject *object = G_OBJECT (embed);
+
+	g_free (priv->address);
+	priv->address = address;
+
+	priv->is_blank = address == NULL ||
+			 strcmp (address, "about:blank") == 0;
+
+	if (priv->is_loading &&
+	    priv->address_expire == EPHY_EMBED_ADDRESS_EXPIRE_NOW &&
+	    priv->typed_address != NULL)
+	{
+		g_free (priv->typed_address);
+		priv->typed_address = NULL;
+
+		g_object_notify (object, "typed-address");
+	}
+
+	g_object_notify (object, "address");
+}
+
+static gboolean
+mozilla_embed_open_uri_cb (GtkMozEmbed *embed,
+			   const char *uri,
+			   MozillaEmbed *membed)
+{
+	MozillaEmbedPrivate *priv = membed->priv;
+
+	/* Set the address here if we have a blank page.
+	 * See bug #147840.
+	 */
+	if (priv->is_blank)
+	{
+		mozilla_embed_set_address (membed, g_strdup (uri));
+		mozilla_embed_set_loading_title (membed, uri, TRUE);
+	}
+
+	/* allow load to proceed */
+	return FALSE;
+}
+
+static void
+mozilla_embed_document_type_cb (EphyEmbed *embed,
+			   EphyEmbedDocumentType type,
+			   MozillaEmbed *membed)
+{
+	if (membed->priv->document_type != type)
+	{
+		membed->priv->document_type = type;
+
+		g_object_notify (G_OBJECT (membed), "document-type");
+	}
+}
+
+static void
+mozilla_embed_link_message_cb (GtkMozEmbed *embed,
+			       MozillaEmbed *membed)
+{
+	mozilla_embed_set_link_message (membed, gtk_moz_embed_get_link_message (embed));
+}
+
+static void
 mozilla_embed_init (MozillaEmbed *embed)
 {
-        embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed);
+        MozillaEmbedPrivate *priv = embed->priv;
+	embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed);
 	embed->priv->browser = new EphyBrowser ();
 
 	g_signal_connect_object (embed, "location",
-				 G_CALLBACK (mozilla_embed_location_changed_cb),
+				 G_CALLBACK (mozilla_embed_address_cb),
 				 embed, (GConnectFlags) 0);
 	g_signal_connect_object (embed, "net_state_all",
 				 G_CALLBACK (mozilla_embed_net_state_all_cb),
@@ -278,6 +766,82 @@ mozilla_embed_init (MozillaEmbed *embed)
 	g_signal_connect_object (embed, "security_change",
 				 G_CALLBACK (mozilla_embed_security_change_cb),
 				 embed, (GConnectFlags) 0);
+	
+	/* Added from EphyTab */
+	priv->total_requests = 0;
+	priv->cur_requests = 0;
+	priv->width = -1;
+	priv->height = -1;
+	priv->load_percent = 0;
+	priv->is_loading = FALSE;
+	priv->security_level = EPHY_EMBED_STATE_IS_UNKNOWN;
+	priv->document_type = EPHY_EMBED_DOCUMENT_HTML;
+	priv->zoom = 1.0;
+	priv->title = NULL;
+	priv->is_blank = TRUE;
+	priv->icon_address = NULL;
+	priv->icon = NULL;
+	priv->address = NULL;
+	priv->typed_address = NULL;
+	priv->title = NULL;
+	priv->loading_title = NULL;
+	priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW;
+	priv->reload_delay_ticks = 0;
+	
+	g_signal_connect_object (embed, "link_message",
+				 G_CALLBACK (mozilla_embed_link_message_cb),
+				 embed, (GConnectFlags) 0);
+
+	g_signal_connect_object (embed, "ge_document_type",
+				 G_CALLBACK (mozilla_embed_document_type_cb),
+				 embed, (GConnectFlags) 0);
+				 
+	g_signal_connect_object (embed, "open_uri",
+				 G_CALLBACK (mozilla_embed_open_uri_cb),
+				 embed, (GConnectFlags) 0);			 
+	/*	
+	## This signal is useless as we connect directly to location from
+	## GtkMozEmbed and we work with that string.
+	## g_signal_connect_object (embed, "ge_location",
+	##			 G_CALLBACK (mozilla_embed_address_cb),
+	##			 tab, 0);
+	*/
+	g_signal_connect_object (embed, "title",
+				 G_CALLBACK (mozilla_embed_title_cb),
+				 embed, (GConnectFlags) 0);
+	/*
+	g_signal_connect_object (embed, "ge_zoom_change",
+				 G_CALLBACK (mozilla_embed_zoom_changed_cb),
+				 tab, 0);
+	## These signals are useless, we do it all when connecting from gtkmozembed
+	## g_signal_connect_object (embed, "ge_net_state",
+	##			 G_CALLBACK (mozilla_embed_net_state_cb),
+	##			 tab, 0);
+	## g_signal_connect_object (embed, "ge_new_window",
+	##			 G_CALLBACK (mozilla_embed_new_window_cb),
+	##			 tab, 0);
+	g_signal_connect_object (embed, "ge_popup_blocked",
+				 G_CALLBACK (mozilla_embed_popup_blocked_cb),
+				 tab, 0);
+	*/
+	g_signal_connect_object (embed, "visibility",
+				 G_CALLBACK (mozilla_embed_visibility_cb),
+				 embed, (GConnectFlags) 0);
+	/*
+	g_signal_connect_object (embed, "ge_dom_mouse_click",
+				 G_CALLBACK (mozilla_embed_dom_mouse_click_cb),
+				 tab, 0);
+	## g_signal_connect_object (embed, "ge_security_change",
+	##			 G_CALLBACK (mozilla_embed_security_change_cb),
+	##			 tab, 0);
+	g_signal_connect_object (embed, "ge_favicon",
+				 G_CALLBACK (mozilla_embed_favicon_cb),
+				 tab, 0);
+	g_signal_connect_object (embed, "ge_content_change",
+				 G_CALLBACK (mozilla_embed_content_change_cb),
+				 tab, 0);
+	*/
+	/* */
 }
 
 gpointer
@@ -849,14 +1413,340 @@ impl_has_modified_forms (EphyEmbed *embe
 }
 
 static void
-mozilla_embed_location_changed_cb (GtkMozEmbed *embed, 
-				   MozillaEmbed *membed)
+mozilla_embed_set_link_message (MozillaEmbed *embed, char *message)
 {
-	char *location;
+	char *status_message;
+	char **splitted_message;
+	MozillaEmbedPrivate *priv = embed->priv;
+	g_return_if_fail (EPHY_IS_EMBED (embed));
 
-	location = gtk_moz_embed_get_location (embed);
-	g_signal_emit_by_name (membed, "ge_location", location);
-	g_free (location);
+	g_free (priv->link_message);
+	status_message = ephy_string_blank_chr (message);
+	
+	if (status_message && g_str_has_prefix (status_message, "mailto:"))
+	{
+		int i = 1;
+		char *p;
+		GString *tmp;
+		
+		/* We first want to eliminate all the things after "?", like
+		 * cc, subject and alike.
+		 */
+		
+		p = strchr (status_message, '?');
+		if (p != NULL) *p = '\0';
+		
+		/* Then we also want to check if there is more than an email address
+		 * in the mailto: list.
+		 */
+		
+		splitted_message = g_strsplit_set (status_message, ";", -1);
+		tmp = g_string_new (g_strdup_printf (_("Send an email message to “%s”"),
+						     (splitted_message[0] + 7)));
+		
+		while (splitted_message [i] != NULL)
+		{
+			g_string_append_printf (tmp, ", “%s”", splitted_message[i]);
+			i++;
+		}
+		
+		priv->link_message = g_string_free (tmp, FALSE);
+		
+		g_free (status_message);
+		g_strfreev (splitted_message);
+	}
+	else
+	{
+		priv->link_message = status_message;
+	}
+
+	g_object_notify (G_OBJECT (embed), "message");
+}
+
+static void
+mozilla_embed_file_monitor_cancel (MozillaEmbed *embed)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	if (priv->monitor != NULL)
+	{
+		LOG ("Cancelling file monitor");
+
+		gnome_vfs_monitor_cancel (priv->monitor);
+		priv->monitor = NULL;
+	}
+
+	if (priv->reload_scheduled_id != 0)
+	{
+		LOG ("Cancelling scheduled reload");
+
+		g_source_remove (priv->reload_scheduled_id);
+		priv->reload_scheduled_id = 0;
+	}
+
+	priv->reload_delay_ticks = 0;
+}
+
+static gboolean
+mozilla_embed_file_monitor_reload_cb (MozillaEmbed *embed)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	if (priv->reload_delay_ticks > 0)
+	{
+		priv->reload_delay_ticks--;
+
+		/* Run again */
+		return TRUE;
+	}
+
+	if (priv->is_loading)
+	{
+		/* Wait a bit to reload if we're still loading! */
+		priv->reload_delay_ticks = RELOAD_DELAY_MAX_TICKS / 2;
+
+		/* Run again */
+		return TRUE;
+	}
+
+	LOG ("Reloading file '%s'", priv->address);
+
+	priv->reload_scheduled_id = 0;
+
+	ephy_embed_reload (EPHY_EMBED (embed), TRUE);
+
+	/* don't run again */
+	return FALSE;
+}
+
+static void
+mozilla_embed_file_monitor_cb (GnomeVFSMonitorHandle *handle,
+			       const gchar *monitor_uri,
+			       const gchar *info_uri,
+			       GnomeVFSMonitorEventType event_type,
+			       MozillaEmbed *embed)
+{
+	gboolean uri_is_directory;
+	gboolean should_reload;
+	char* local_path;
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	LOG ("File '%s' has changed, scheduling reload", monitor_uri);
+
+	local_path = gnome_vfs_get_local_path_from_uri(monitor_uri);
+	uri_is_directory = g_file_test(local_path, G_FILE_TEST_IS_DIR);
+	g_free(local_path);
+
+	switch (event_type)
+	{
+		/* These events will always trigger a reload: */
+		case GNOME_VFS_MONITOR_EVENT_CHANGED:
+		case GNOME_VFS_MONITOR_EVENT_CREATED:
+			should_reload = TRUE;
+			break;
+
+		/* These events will only trigger a reload for directories: */
+		case GNOME_VFS_MONITOR_EVENT_DELETED:
+		case GNOME_VFS_MONITOR_EVENT_METADATA_CHANGED:
+			should_reload = uri_is_directory;
+			break;
+
+		/* These events don't trigger a reload: */
+		case GNOME_VFS_MONITOR_EVENT_STARTEXECUTING:
+		case GNOME_VFS_MONITOR_EVENT_STOPEXECUTING:
+		default:
+			should_reload = FALSE;
+			break;
+	}
+
+	if (should_reload) {
+		/* We make a lot of assumptions here, but basically we know
+		 * that we just have to reload, by construction.
+		 * Delay the reload a little bit so we don't endlessly
+		 * reload while a file is written.
+		 */
+		if (priv->reload_delay_ticks == 0)
+		{
+			priv->reload_delay_ticks = 1;
+		}
+		else
+		{
+			/* Exponential backoff */
+			priv->reload_delay_ticks = MIN (priv->reload_delay_ticks * 2,
+					RELOAD_DELAY_MAX_TICKS);
+		}
+
+		if (priv->reload_scheduled_id == 0)
+		{
+			priv->reload_scheduled_id =
+				g_timeout_add (RELOAD_DELAY,
+						(GSourceFunc) mozilla_embed_file_monitor_reload_cb, embed);
+		}
+	}
+}
+
+static void
+mozilla_embed_update_file_monitor (MozillaEmbed *embed,
+				   const gchar *address)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+	GnomeVFSMonitorHandle *handle = NULL;
+	gboolean local;
+	char* local_path;
+	GnomeVFSMonitorType monitor_type;
+
+	if (priv->monitor != NULL &&
+	    priv->address != NULL && address != NULL &&
+	    strcmp (priv->address, address) == 0)
+	
+	{
+		/* same address, no change needed */
+		return;
+	}
+
+	mozilla_embed_file_monitor_cancel (embed);
+
+	local = g_str_has_prefix (address, "file://");
+	if (local == FALSE) return;
+	
+	local_path = gnome_vfs_get_local_path_from_uri(address);
+	monitor_type = g_file_test(local_path, G_FILE_TEST_IS_DIR)
+		? GNOME_VFS_MONITOR_DIRECTORY
+		: GNOME_VFS_MONITOR_FILE;
+	g_free(local_path);
+
+	if (gnome_vfs_monitor_add (&handle, address,
+				   monitor_type,
+				   (GnomeVFSMonitorCallback) mozilla_embed_file_monitor_cb,
+				   embed) == GNOME_VFS_OK)
+	{
+		LOG ("Installed monitor for file '%s'", address);
+
+		priv->monitor = handle;
+	}
+}
+
+static void
+mozilla_embed_load_icon (MozillaEmbed *embed)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+	EphyEmbedShell *shell;
+	EphyFaviconCache *cache;
+
+	if (priv->icon_address == NULL || priv->icon != NULL) return;
+
+	shell = ephy_embed_shell_get_default ();
+	cache = EPHY_FAVICON_CACHE (ephy_embed_shell_get_favicon_cache (shell));
+
+	/* ephy_favicon_cache_get returns a reference already */
+	priv->icon = ephy_favicon_cache_get (cache, priv->icon_address);
+
+	g_object_notify (G_OBJECT (embed), "icon");
+}
+
+void
+mozilla_embed_set_icon_address (MozillaEmbed *embed,
+				const char *address)
+{
+	GObject *object = G_OBJECT (embed);
+	MozillaEmbedPrivate *priv = embed->priv;
+	EphyBookmarks *eb;
+	EphyHistory *history;
+
+	g_free (priv->icon_address);
+	priv->icon_address = g_strdup (address);
+
+	if (priv->icon != NULL)
+	{
+		g_object_unref (priv->icon);
+		priv->icon = NULL;
+
+		g_object_notify (object, "icon");
+	}
+
+	if (priv->icon_address)
+	{
+		eb = ephy_shell_get_bookmarks (ephy_shell);
+		history = EPHY_HISTORY
+			(ephy_embed_shell_get_global_history (embed_shell));
+		ephy_bookmarks_set_icon (eb, priv->address,
+				         priv->icon_address);
+		ephy_history_set_icon (history, priv->address,
+				       priv->icon_address);
+
+		mozilla_embed_load_icon (embed);
+	}
+
+	g_object_notify (object, "icon-address");
+}
+
+static void
+mozilla_embed_update_navigation_flags (MozillaEmbed *embed)
+{
+	EphyEmbedNavigationFlags flags = 0;
+
+	if (ephy_embed_can_go_up (EPHY_EMBED (embed)))
+	{
+		flags |= EPHY_EMBED_NAV_UP;
+	}
+
+	if (ephy_embed_can_go_back (EPHY_EMBED (embed)))
+	{
+		flags |= EPHY_EMBED_NAV_BACK;
+	}
+
+	if (ephy_embed_can_go_forward (EPHY_EMBED (embed)))
+	{
+		flags |= EPHY_EMBED_NAV_FORWARD;
+	}
+
+	if (flags != embed->priv->nav_flags)
+	{
+		embed->priv->nav_flags = flags;
+
+		g_object_notify (G_OBJECT (embed), "navigation");
+	}
+}
+
+static void
+mozilla_embed_address_cb (GtkMozEmbed *embed,
+			  MozillaEmbed *membed)
+{
+	GObject *object = G_OBJECT (membed);
+	char *address;
+
+	address = gtk_moz_embed_get_location (embed);
+
+	g_object_freeze_notify (object);
+
+	/* do this up here so we still have the old address around */
+	mozilla_embed_update_file_monitor (membed, address);
+
+	/* Do not expose about:blank to the user, an empty address
+	   bar will do better */
+	if (address == NULL || address[0] == '\0' ||
+	    strcmp (address, "about:blank") == 0)
+	{
+		mozilla_embed_set_address (membed, NULL);
+		mozilla_embed_set_title (membed, NULL);
+	}
+	else
+	{
+		char *embed_address;
+
+		/* we do this to get rid of an eventual password in the URL */
+		embed_address = ephy_embed_get_location (EPHY_EMBED (membed), TRUE);
+		mozilla_embed_set_address (membed, embed_address);
+		mozilla_embed_set_loading_title (membed, embed_address, TRUE);
+	}
+
+	mozilla_embed_set_link_message (membed, NULL);
+	mozilla_embed_set_icon_address (membed, NULL);
+	mozilla_embed_update_navigation_flags (membed);
+
+	g_object_notify (object, "title");
+
+	g_object_thaw_notify (object);
 }
 
 static void
@@ -918,11 +1808,164 @@ update_load_state (MozillaEmbed *membed,
 }
 
 static void
-mozilla_embed_net_state_all_cb (GtkMozEmbed *embed, const char *aURI,
+update_net_state_message (MozillaEmbed *embed, const char *uri, EphyEmbedNetState flags)
+{
+	GnomeVFSURI *vfs_uri = NULL;
+	const char *msg = NULL;
+	const char *host = NULL;
+
+	if (uri != NULL)
+	{
+		vfs_uri = gnome_vfs_uri_new (uri);
+	}
+
+	if (vfs_uri != NULL)
+	{
+		host = gnome_vfs_uri_get_host_name (vfs_uri);
+	}
+
+	if (host == NULL || host[0] == '\0') goto out;
+
+	/* IS_REQUEST and IS_NETWORK can be both set */
+	if (flags & EPHY_EMBED_STATE_IS_REQUEST)
+	{
+		if (flags & EPHY_EMBED_STATE_REDIRECTING)
+		{
+			msg = _("Redirecting to “%s”…");
+		}
+		else if (flags & EPHY_EMBED_STATE_TRANSFERRING)
+		{
+			msg = _("Transferring data from “%s”…");
+		}
+		else if (flags & EPHY_EMBED_STATE_NEGOTIATING)
+		{
+			msg = _("Waiting for authorization from “%s”…");
+		}
+	}
+
+	if (flags & EPHY_EMBED_STATE_IS_NETWORK)
+	{
+		if (flags & EPHY_EMBED_STATE_START)
+		{
+			msg = _("Loading “%s”…");
+		}
+	}
+
+	if ((flags & EPHY_EMBED_STATE_IS_NETWORK) &&
+	    (flags & EPHY_EMBED_STATE_STOP))
+	{
+		g_free (embed->priv->status_message);
+		embed->priv->status_message = NULL;
+		g_object_notify (G_OBJECT (embed), "message");
+
+	}
+	else if (msg != NULL)
+	{
+		g_free (embed->priv->status_message);
+		g_free (embed->priv->loading_title);
+		embed->priv->status_message = g_strdup_printf (msg, host);
+		embed->priv->loading_title = g_strdup_printf (msg, host);
+		g_object_notify (G_OBJECT (embed), "message");
+		g_object_notify (G_OBJECT (embed), "title");
+	}
+
+out:
+	if (vfs_uri != NULL)
+	{
+		gnome_vfs_uri_unref (vfs_uri);
+	}
+}
+
+void
+mozilla_embed_set_load_percent (MozillaEmbed *embed, int percent)
+{
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+
+	if (percent != embed->priv->load_percent)
+	{
+		embed->priv->load_percent = percent;
+
+		g_object_notify (G_OBJECT (embed), "load-progress");
+	}
+}
+
+static void
+mozilla_embed_set_load_status (MozillaEmbed *embed, gboolean status)
+{
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+
+	status = status != FALSE;
+
+	embed->priv->is_loading = status;
+
+	g_object_notify (G_OBJECT (embed), "load-status");
+}
+
+static void
+ensure_page_info (MozillaEmbed *embed, const char *address)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	if ((priv->address == NULL || priv->address[0] == '\0') &&
+	    priv->address_expire == EPHY_EMBED_ADDRESS_EXPIRE_NOW)
+        {
+		mozilla_embed_set_address (embed, g_strdup (address));
+	}
+
+	/* FIXME huh?? */
+	if (embed->priv->title == NULL || embed->priv->title[0] == '\0')
+	{
+		mozilla_embed_set_title (embed, NULL);
+	}
+}
+
+static int
+build_load_percent (int requests_done, int requests_total)
+{
+	int percent= 0;
+
+	if (requests_total > 0)
+	{
+		percent = (requests_done * 100) / requests_total;
+
+		/* Mozilla sometimes report more done requests than
+		   total requests. Their progress widget clamp the value */
+		percent = CLAMP (percent, 0, 100);
+	}
+
+	return percent;
+}
+
+static void
+build_progress_from_requests (MozillaEmbed *embed, EphyEmbedNetState state)
+{
+	int load_percent;
+
+	if (state & EPHY_EMBED_STATE_IS_REQUEST)
+        {
+                if (state & EPHY_EMBED_STATE_START)
+                {
+			embed->priv->total_requests ++;
+		}
+		else if (state & EPHY_EMBED_STATE_STOP)
+		{
+			embed->priv->cur_requests ++;
+		}
+
+		load_percent = build_load_percent (embed->priv->cur_requests,
+						   embed->priv->total_requests);
+
+		mozilla_embed_set_load_percent (embed, load_percent);
+	}
+}
+
+static void
+mozilla_embed_net_state_all_cb (GtkMozEmbed *embed, const char *uri,
                                 gint state, guint status, 
 				MozillaEmbed *membed)
 {
 	EphyEmbedNetState estate = EPHY_EMBED_STATE_UNKNOWN;
+	MozillaEmbedPrivate *priv = membed->priv;
 	int i;
 
 	struct
@@ -954,7 +1997,53 @@ mozilla_embed_net_state_all_cb (GtkMozEm
 
 	update_load_state (membed, state);
 	
-	g_signal_emit_by_name (membed, "ge_net_state", aURI, /* FIXME: (gulong) */ estate);
+	// From here it's copied from EphyTab
+
+	update_net_state_message (membed, uri, state);
+
+	if (state & EPHY_EMBED_STATE_IS_NETWORK)
+	{
+		if (state & EPHY_EMBED_STATE_START)
+		{
+			GObject *object = G_OBJECT (membed);
+
+			g_object_freeze_notify (object);
+
+			priv->total_requests = 0;
+			priv->cur_requests = 0;
+
+			mozilla_embed_set_load_percent (membed, 0);
+			mozilla_embed_set_load_status (membed, TRUE);
+			mozilla_embed_update_navigation_flags (membed);
+
+			ensure_page_info (membed, uri);
+
+			g_object_notify (object, "title");
+
+			g_object_thaw_notify (object);
+		}
+		else if (state & EPHY_EMBED_STATE_STOP)
+		{
+			GObject *object = G_OBJECT (membed);
+
+			g_object_freeze_notify (object);
+
+			mozilla_embed_set_load_percent (membed, 100);
+			mozilla_embed_set_load_status (membed, FALSE);
+			mozilla_embed_update_navigation_flags (membed);
+
+			g_free (priv->loading_title);
+			priv->loading_title = NULL;
+
+			priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW;
+
+			g_object_notify (object, "title");
+
+			g_object_thaw_notify (object);
+		}
+	}
+
+	build_progress_from_requests (membed, state);
 }
 
 static gboolean
@@ -1073,6 +2162,31 @@ _mozilla_embed_translate_chrome (GtkMozE
 	return (EphyEmbedChrome) mask;
 }
 
+static gboolean
+popups_manager_remove_window (MozillaEmbed *embed,
+			      EphyWindow *window)
+{
+	embed->priv->shown_popups = g_slist_remove (embed->priv->shown_popups,
+						    window);
+
+	return FALSE;
+}
+
+static void
+popups_manager_add_window (MozillaEmbed *embed,
+			   EphyWindow *window)
+{
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+	g_return_if_fail (EPHY_IS_WINDOW (window));
+
+	embed->priv->shown_popups = g_slist_prepend
+		(embed->priv->shown_popups, window);
+
+	g_signal_connect_swapped (window, "destroy",
+				  G_CALLBACK (popups_manager_remove_window),
+				  embed);
+}
+
 static void
 mozilla_embed_new_window_cb (GtkMozEmbed *embed, 
 			     GtkMozEmbed **newEmbed,
@@ -1083,6 +2197,7 @@ mozilla_embed_new_window_cb (GtkMozEmbed
 	EphyEmbed *new_embed = NULL;
 	GObject *single;
 	EphyEmbedChrome mask;
+	EphyWindow *window;
 
 	if (chrome & GTK_MOZ_EMBED_FLAG_OPENASCHROME)
 	{
@@ -1100,9 +2215,24 @@ mozilla_embed_new_window_cb (GtkMozEmbed
 
 	gtk_moz_embed_set_chrome_mask (GTK_MOZ_EMBED (new_embed), chrome);
 
-	g_signal_emit_by_name (membed, "ge-new-window", new_embed);
+	// g_signal_emit_by_name (membed, "ge-new-window", new_embed);
 
 	*newEmbed = GTK_MOZ_EMBED (new_embed);
+
+	window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (new_embed)));
+	g_return_if_fail (window != NULL);
+
+	popups_manager_add_window (membed, window);
+}
+
+static void
+mozilla_embed_set_security_level (MozillaEmbed *embed, EphyEmbedSecurityLevel level)
+{
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+
+	embed->priv->security_level = level;
+
+	g_object_notify (G_OBJECT (embed), "security-level");
 }
 
 static void
@@ -1111,8 +2241,7 @@ mozilla_embed_security_change_cb (GtkMoz
 				  PRUint32 state,
 				  MozillaEmbed *membed)
 {
-	g_signal_emit_by_name (membed, "ge_security_change",
-			       mozilla_embed_security_level (state));
+	mozilla_embed_set_security_level (membed, mozilla_embed_security_level (state));
 }
 
 static EphyEmbedSecurityLevel
@@ -1266,3 +2395,342 @@ _mozilla_embed_new_xul_dialog (void)
 
 	return GTK_MOZ_EMBED (embed);
 }
+
+static void
+mozilla_embed_set_title (MozillaEmbed *embed,
+			 char *title)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	if (!priv->is_blank && (title == NULL || g_strstrip (title)[0] == '\0'))
+	{
+
+		g_free (title);
+		title = get_title_from_address (priv->address);
+
+		/* Fallback */
+		if (title == NULL || title[0] == '\0')
+		{
+			g_free (title);
+			title = NULL;
+			priv->is_blank = TRUE;
+		}
+	}
+	else if (priv->is_blank && title != NULL)
+	{
+		g_free (title);
+		title = NULL;
+	}
+
+	g_free (priv->title);
+	priv->title = ephy_string_shorten (title, MAX_TITLE_LENGTH);
+
+	g_object_notify (G_OBJECT (embed), "title");
+}
+
+/**
+ * ephy_tab_get_status_message:
+ * @tab: an #EphyTab
+ *
+ * Returns the message displayed in @tab's #EphyWindow's
+ * #EphyStatusbar. If the user is hovering the mouse over a hyperlink,
+ * this function will return the same value as
+ * ephy_tab_get_link_message(). Otherwise, it will return a network
+ * status message, or NULL.
+ *
+ * The message returned has a limited lifetime, and so should be copied with
+ * g_strdup() if it must be stored.
+ *
+ * Listen to "notify::message" to be notified when the message property changes.
+ *
+ * Return value: The current statusbar message
+ **/
+const char *
+mozilla_embed_get_status_message (MozillaEmbed *embed)
+{
+	g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+
+	if (embed->priv->link_message && embed->priv->link_message[0] != '\0')
+	{
+		return embed->priv->link_message;
+	}
+	else if (embed->priv->status_message)
+	{
+		return embed->priv->status_message;
+	}
+	else
+	{
+		return NULL;
+	}
+}
+
+/**
+ * ephy_tab_get_typed_address:
+ * @tab: an #EphyTab
+ *
+ * Returns the text that @tab's #EphyWindow will display in its location toolbar
+ * entry when @tab is selected.
+ *
+ * This is not guaranteed to be the same as @tab's #EphyEmbed's location,
+ * available through ephy_embed_get_location(). As the user types a new address
+ * into the location entry, ephy_tab_get_location()'s returned string will
+ * change.
+ *
+ * Return value: @tab's #EphyWindow's location entry when @tab is selected
+ **/
+
+const char *
+mozilla_embed_get_typed_address (MozillaEmbed *embed)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+
+	return priv->typed_address;
+}
+
+static guint
+popup_blocker_n_hidden (MozillaEmbed *embed)
+{
+	return g_slist_length (embed->priv->hidden_popups);
+}
+
+static gboolean
+mozilla_embed_get_popups_allowed (MozillaEmbed *embed)
+{
+	EphyPermissionManager *permission_manager;
+	EphyPermission response;
+	char *location;
+	gboolean allow;
+
+	g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
+
+	permission_manager = EPHY_PERMISSION_MANAGER
+		(ephy_embed_shell_get_embed_single (embed_shell));
+	g_return_val_if_fail (EPHY_IS_PERMISSION_MANAGER (permission_manager),
+			      FALSE);
+
+	location = ephy_embed_get_location (EPHY_EMBED (embed), TRUE);
+	if (location == NULL) return FALSE; /* FALSE, TRUE… same thing */
+
+	response = ephy_permission_manager_test_permission
+		(permission_manager, location, EPT_POPUP);
+
+	switch (response)
+	{
+		case EPHY_PERMISSION_ALLOWED:
+			allow = TRUE;
+			break;
+		case EPHY_PERMISSION_DENIED:
+			allow = FALSE;
+			break;
+		case EPHY_PERMISSION_DEFAULT:
+		default:
+			allow = eel_gconf_get_boolean
+				(CONF_SECURITY_ALLOW_POPUPS);
+			break;
+	}
+
+	g_free (location);
+
+	return allow;
+}
+
+/**
+ * ephy_tab_set_typed_address:
+ * @tab: an #EphyTab
+ * @address: the new typed address, or %NULL to clear it
+ * @expire: when to expire this address_expire
+ * 
+ * Sets the text that @tab's #EphyWindow will display in its location toolbar
+ * entry when @tab is selected.
+ **/
+void
+mozilla_embed_set_typed_address (MozillaEmbed *embed,
+				 const char *address,
+				 EphyEmbedAddressExpire expire)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+
+	g_free (priv->typed_address);
+	priv->typed_address = g_strdup (address);
+
+	if (expire == EPHY_EMBED_ADDRESS_EXPIRE_CURRENT &&
+	    !priv->is_loading)
+	{
+		priv->address_expire = EPHY_EMBED_ADDRESS_EXPIRE_NOW;
+	}
+	else
+	{
+		priv->address_expire = expire;
+	}
+
+	g_object_notify (G_OBJECT (embed), "typed-address");
+}
+
+static void
+popups_manager_free_info (PopupInfo *popup)
+{
+	g_free (popup->url);
+	g_free (popup->name);
+	g_free (popup->features);
+	g_free (popup);
+}
+
+static void
+popups_manager_add (MozillaEmbed *embed,
+		    const char *url,
+		    const char *name,
+		    const char *features)
+{
+	MozillaEmbedPrivate *priv = embed->priv;
+	PopupInfo *popup;
+
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+
+	popup = g_new0 (PopupInfo, 1);
+
+	popup->url = (url == NULL) ? NULL : g_strdup (url);
+	popup->name = g_strdup (name);
+	popup->features = g_strdup (features);
+
+	priv->hidden_popups = g_slist_prepend (priv->hidden_popups, popup);
+
+	if (popup_blocker_n_hidden (embed) > MAX_HIDDEN_POPUPS) /* bug #160863 */
+	{
+		/* Remove the oldest popup */
+		GSList *l = priv->hidden_popups;
+
+		while (l->next->next != NULL)
+		{
+			l = l->next;
+		}
+
+		popup = (PopupInfo *) l->next->data;
+		popups_manager_free_info (popup);
+
+		l->next = NULL;
+	}
+	else
+	{
+		g_object_notify (G_OBJECT (embed), "hidden-popup-count");
+	}
+}
+
+static char *
+popups_manager_new_window_info (EphyWindow *window)
+{
+	MozillaEmbed *embed;
+	EphyEmbedChrome chrome;
+	gboolean is_popup;
+	char *features;
+
+	g_object_get (window, "chrome", &chrome, "is-popup", &is_popup, NULL);
+	g_return_val_if_fail (is_popup, g_strdup (""));
+
+	embed = MOZILLA_EMBED (ephy_window_get_active_embed (window));
+	g_return_val_if_fail (embed != NULL, g_strdup (""));
+
+	features = g_strdup_printf
+		("width=%d,height=%d,menubar=%d,status=%d,toolbar=%d",
+		 embed->priv->width, embed->priv->height,
+		 (chrome & EPHY_EMBED_CHROME_MENUBAR) > 0,
+		 (chrome & EPHY_EMBED_CHROME_STATUSBAR) > 0,
+		 (chrome & EPHY_EMBED_CHROME_TOOLBAR) > 0);
+
+	return features;
+}
+
+static void
+popups_manager_hide (EphyWindow *window,
+		     MozillaEmbed *embed)
+{
+	char *location;
+	char *features;
+
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+
+	location = ephy_embed_get_location (EPHY_EMBED (embed), TRUE);
+	if (location == NULL) return;
+
+	features = popups_manager_new_window_info (window);
+
+	popups_manager_add (embed, location, "" /* FIXME? maybe _blank? */, features);
+
+	gtk_widget_destroy (GTK_WIDGET (window));
+
+	g_free (location);
+	g_free (features);
+}
+
+static void
+popups_manager_show (PopupInfo *popup,
+		     MozillaEmbed *embed)
+{
+	EphyEmbedSingle *single;
+
+	/* Only show popup with non NULL url */
+	if (popup->url != NULL)
+	{
+		single = EPHY_EMBED_SINGLE
+			(ephy_embed_shell_get_embed_single (embed_shell));
+
+		ephy_embed_single_open_window (single, EPHY_EMBED (embed), popup->url,
+				popup->name, popup->features);
+	}
+	popups_manager_free_info (popup);
+}
+
+static void
+popups_manager_hide_all (MozillaEmbed *embed)
+{
+	g_slist_foreach (embed->priv->shown_popups,
+			 (GFunc) popups_manager_hide, embed);
+	g_slist_free (embed->priv->shown_popups);
+	embed->priv->shown_popups = NULL;
+}
+
+static void
+popups_manager_show_all (MozillaEmbed *embed)
+{
+	g_slist_foreach (embed->priv->hidden_popups,
+			 (GFunc) popups_manager_show, embed);
+	g_slist_free (embed->priv->hidden_popups);
+	embed->priv->hidden_popups = NULL;
+
+	g_object_notify (G_OBJECT (embed), "hidden-popup-count");
+}
+
+static void
+mozilla_embed_set_popups_allowed (MozillaEmbed *embed,
+				  gboolean allowed)
+{
+	char *location;
+	EphyPermissionManager *manager;
+	EphyPermission permission;
+
+	g_return_if_fail (EPHY_IS_EMBED (embed));
+
+	location = ephy_embed_get_location (EPHY_EMBED (embed), TRUE);
+	g_return_if_fail (location != NULL);
+
+	manager = EPHY_PERMISSION_MANAGER
+		(ephy_embed_shell_get_embed_single (embed_shell));
+	g_return_if_fail (EPHY_IS_PERMISSION_MANAGER (manager));
+
+	permission = allowed ? EPHY_PERMISSION_ALLOWED
+			     : EPHY_PERMISSION_DENIED;
+
+	ephy_permission_manager_add_permission (manager, location, EPT_POPUP, permission);
+
+	if (allowed)
+	{
+		popups_manager_show_all (embed);
+	}
+	else
+	{
+		popups_manager_hide_all (embed);
+	}
+
+	g_free (location);
+}
Index: embed/mozilla/Makefile.am
===================================================================
--- embed/mozilla/Makefile.am	(revisione 7514)
+++ embed/mozilla/Makefile.am	(copia locale)
@@ -138,6 +138,8 @@ mozilla_include_subdirs = \
 libephymozillaembed_la_CPPFLAGS = \
 	-I$(top_srcdir)/lib	    		\
 	-I$(top_srcdir)/embed	    		\
+	-I$(top_srcdir)/src			\
+	-I$(top_srcdir)/src/bookmarks			\
 	-I$(top_srcdir)		    		\
 	$(addprefix -I$(GECKO_INCLUDE_ROOT)/,$(mozilla_include_subdirs))	\
 	-DSHARE_DIR=\"$(pkgdatadir)\"   	\
