5ce4636e3d40efa92e241f5e8605dcd046b4c12f
diff --git a/embed/ephy-base-embed.c b/embed/ephy-base-embed.c
index 650843a..9230cd0 100644
--- a/embed/ephy-base-embed.c
+++ b/embed/ephy-base-embed.c
@@ -61,6 +61,7 @@ struct _EphyBaseEmbedPrivate {
   guint is_blank : 1;
   guint is_loading : 1;
   guint is_setting_zoom : 1;
+  guint visibility : 1;
 
   gint8 load_percent;
   char *address;
@@ -104,6 +105,7 @@ enum {
   PROP_SECURITY,
   PROP_STATUS_MESSAGE,
   PROP_TITLE,
+  PROP_VISIBLE,
   PROP_TYPED_ADDRESS,
   PROP_ZOOM
 };
@@ -271,6 +273,12 @@ impl_get_link_message (EphyEmbed *embed)
   return EPHY_BASE_EMBED (embed)->priv->link_message;
 }
 
+static gboolean
+impl_get_visibility (EphyEmbed *embed)
+{
+  return EPHY_BASE_EMBED (embed)->priv->visibility;
+}
+
 static void
 popups_manager_free_info (PopupInfo *popup)
 {
@@ -470,6 +478,7 @@ ephy_base_embed_set_property (GObject *object,
     case PROP_NAVIGATION:
     case PROP_SECURITY:
     case PROP_STATUS_MESSAGE:
+    case PROP_VISIBLE:
     case PROP_ZOOM:
       /* read only */
       break;
@@ -571,6 +580,9 @@ ephy_base_embed_get_property (GObject *object,
     case PROP_TYPED_ADDRESS:
       g_value_set_string (value, priv->typed_address);
       break;
+    case PROP_VISIBLE:
+      g_value_set_boolean (value, priv->visibility);
+      break;
     case PROP_ZOOM:
       g_value_set_float (value, priv->zoom);
       break;
@@ -711,6 +723,14 @@ ephy_base_embed_class_init (EphyBaseEmbedClass *klass)
                                                          FALSE,
                                                          G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
 
+  g_object_class_install_property (gobject_class,
+                                   PROP_VISIBLE,
+                                   g_param_spec_boolean ("visibility",
+                                                         "Visibility",
+                                                         "The embed's visibility",
+                                                         FALSE,
+                                                         G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
+
   g_type_class_add_private (gobject_class, sizeof (EphyBaseEmbedPrivate));
 }
 
@@ -950,6 +970,7 @@ ephy_embed_iface_init (EphyEmbedIface *iface)
   iface->get_navigation_flags = impl_get_navigation_flags;
   iface->get_link_message = impl_get_link_message;
   iface->get_status_message = impl_get_status_message;
+  iface->get_visibility = impl_get_visibility;
 }
 
 void
@@ -1550,3 +1571,15 @@ ephy_base_embed_restore_zoom_level (EphyBaseEmbed *membed,
   }
 }
 
+void
+ephy_base_embed_set_visibility (EphyBaseEmbed *embed,
+                                gboolean visibility)
+{
+  EphyBaseEmbedPrivate *priv = embed->priv;
+
+  if (priv->visibility != visibility) {
+    priv->visibility = visibility;
+
+    g_object_notify (G_OBJECT (embed), "visibility");
+  }
+}
diff --git a/embed/ephy-base-embed.h b/embed/ephy-base-embed.h
index 9790446..9120916 100644
--- a/embed/ephy-base-embed.h
+++ b/embed/ephy-base-embed.h
@@ -76,6 +76,8 @@ void  ephy_base_embed_update_from_net_state (EphyBaseEmbed *embed,
                                              EphyEmbedNetState state);
 void  ephy_base_embed_set_load_percent (EphyBaseEmbed *embed, int percent);
 void  ephy_base_embed_popups_manager_reset (EphyBaseEmbed *embed);
+void  ephy_base_embed_set_visibility (EphyBaseEmbed *embed,
+                                      gboolean visibility);
 
 G_END_DECLS
 
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index af8329b..042e323 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -1130,3 +1130,19 @@ ephy_embed_get_loading_title (EphyEmbed *embed)
 	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
 	return iface->get_loading_title (embed);
 }
+
+/**
+ * ephy_embed_get_visibility:
+ * @embed: an #EphyEmbed
+ *
+ * Returns whether the @embed's toplevel is visible or not. Used
+ * mostly for popup visibility management.
+ *
+ * Return value; %TRUE if @embed's "visibility" property is set
+ **/
+gboolean
+ephy_embed_get_visibility (EphyEmbed *embed)
+{
+	EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed);
+	return iface->get_visibility (embed);
+}
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index d60c733..cb6f9e3 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -233,6 +233,7 @@ struct _EphyEmbedIface
 	const char *	   (* get_icon_address)		(EphyEmbed *embed);
 	gboolean	   (* get_is_blank)		(EphyEmbed *embed);
 	const char *	   (* get_loading_title)	(EphyEmbed *embed);
+	gboolean *	   (* get_visibility)		(EphyEmbed *embed);
 };
 
 GType		  ephy_embed_net_state_get_type		(void);
@@ -358,6 +359,7 @@ gboolean	  ephy_embed_get_is_blank		(EphyEmbed *embed);
 
 const char *	 ephy_embed_get_loading_title		(EphyEmbed *embed);
 
+gboolean	 ephy_embed_get_visibility		(EphyEmbed *embed);
 /* Encoding */
 char		 *ephy_embed_get_encoding		(EphyEmbed *embed);
 
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index cca08a7..b96049a 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -82,6 +82,9 @@ static void mozilla_embed_title_change_cb	(GtkMozEmbed *embed,
 						 MozillaEmbed *membed);
 static void mozilla_embed_link_message_cb	(GtkMozEmbed *embed,
 						 MozillaEmbed *membed);
+static void mozilla_embed_visibility_cb		(GtkMozEmbed *embed,
+						 gboolean visibility,
+						 MozillaEmbed *membed);
 static gboolean mozilla_embed_open_uri_cb	(GtkMozEmbed *embed,
 						 const char *uri,
 						 MozillaEmbed *membed);
@@ -280,6 +283,9 @@ mozilla_embed_init (MozillaEmbed *membed)
 	g_signal_connect_object (embed, "open_uri",
 				 G_CALLBACK (mozilla_embed_open_uri_cb),
 				 membed,(GConnectFlags) 0);
+	g_signal_connect_object (embed, "visibility",
+				 G_CALLBACK (mozilla_embed_visibility_cb),
+				 membed, (GConnectFlags) 0);
 }
 
 gpointer
@@ -1169,6 +1175,14 @@ mozilla_embed_open_uri_cb (GtkMozEmbed *embed,
 	return FALSE;
 }
 
+static void
+mozilla_embed_visibility_cb (GtkMozEmbed *embed,
+			     gboolean visibility,
+			     MozillaEmbed *membed)
+{
+  ephy_base_embed_set_visibility (EPHY_BASE_EMBED (membed), visibility);
+}
+
 static EphyEmbedSecurityLevel
 mozilla_embed_security_level (PRUint32 state)
 {
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 1f2390e..1dd6a56 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2420,6 +2420,19 @@ ephy_window_dom_mouse_click_cb (EphyEmbed *embed,
 }
 
 static void
+ephy_window_visibility_cb (EphyEmbed *embed, GParamSpec *pspec, EphyWindow *window)
+{
+	gboolean visibility;
+
+	visibility = ephy_embed_get_visibility (embed);
+
+	if (visibility)
+		gtk_widget_show (GTK_WIDGET (window));
+	else
+		gtk_widget_hide (GTK_WIDGET (window));
+}
+
+static void
 ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
 {
 	EphyEmbed *old_embed;
@@ -2472,6 +2485,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
 		g_signal_handlers_disconnect_by_func (embed,
 						      G_CALLBACK (sync_tab_message),
 						      window);
+		g_signal_handlers_disconnect_by_func (embed,
+						      G_CALLBACK (ephy_window_visibility_cb),
+						      window);
 
 		g_signal_handlers_disconnect_by_func
 			(embed, G_CALLBACK (tab_context_menu_cb), window);
@@ -2546,6 +2562,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
 		g_signal_connect_object (embed, "ge_dom_mouse_click",
 					 G_CALLBACK (ephy_window_dom_mouse_click_cb),
 					 window, 0);
+		g_signal_connect_object (embed, "notify::visibility",
+					 G_CALLBACK (ephy_window_visibility_cb),
+					 window, 0);
 
 		g_object_notify (G_OBJECT (window), "active-child");
 	}
