Index: m4/gecko.m4
===================================================================
--- m4/gecko.m4	(revision 7834)
+++ m4/gecko.m4	(working copy)
@@ -32,6 +32,7 @@
 # VARIABLE: Which gecko was found (e.g. "xulrunnner", "seamonkey", ...)
 # VARIABLE_FLAVOUR: The flavour of the gecko that was found
 # VARIABLE_HOME:
+# VARIABLE_NSPR: set if nspr is provided by gecko flags
 # VARIABLE_PREFIX:
 # VARIABLE_INCLUDE_ROOT:
 # VARIABLE_VERSION: The version of the gecko that was found
@@ -51,7 +52,7 @@
 AC_MSG_CHECKING([which gecko to use])
 
 AC_ARG_WITH([gecko],
-	AS_HELP_STRING([--with-gecko@<:@=mozilla|firefox|seamonkey|xulrunner@:>@],
+	AS_HELP_STRING([--with-gecko@<:@=mozilla|firefox|seamonkey|xulrunner|libxul-embedding|libxul@:>@],
 		       [Which gecko engine to use (autodetected by default)]))
 
 # Backward compat
@@ -60,12 +61,15 @@
 gecko_cv_gecko=$with_gecko
 
 # Autodetect gecko
-_geckos="xulrunner firefox mozilla-firefox seamonkey mozilla"
+_geckos="xulrunner firefox mozilla-firefox seamonkey mozilla libxul-embedding libxul"
 if test -z "$gecko_cv_gecko"; then
 	for lizard in $_geckos; do
 		if $PKG_CONFIG --exists $lizard-xpcom; then
 			gecko_cv_gecko=$lizard
 			break;
+		elif $PKG_CONFIG --exist $lizard; then
+			gecko_cv_gecko=$lizard
+			break;
 		fi
 	done
 fi
@@ -82,6 +86,14 @@
 	gecko_cv_have_gecko=yes
 fi
 
+AC_MSG_CHECKING([manual gecko home set])
+
+AC_ARG_WITH([gecko-home],
+	AS_HELP_STRING([--with-gecko-home@<:@=[path]@:>@],
+		       [Manually set MOZILLA_FIVE_HOME]))
+
+gecko_cv_gecko_home=$with_gecko_home
+
 # ****************
 # Define variables
 # ****************
@@ -93,13 +105,24 @@
 seamonkey) gecko_cv_gecko_flavour=mozilla ;;
 *firefox) gecko_cv_gecko_flavour=toolkit ;;
 xulrunner) gecko_cv_gecko_flavour=toolkit ;;
+libxul*) gecko_cv_gecko_flavour=toolkit ;;
 esac
 
-_GECKO_INCLUDE_ROOT="`$PKG_CONFIG --variable=includedir ${gecko_cv_gecko}-xpcom`"
-_GECKO_LIBDIR="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`"
-_GECKO_HOME="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`"
-_GECKO_PREFIX="`$PKG_CONFIG --variable=prefix ${gecko_cv_gecko}-xpcom`"
-
+if $PKG_CONFIG --exists  ${gecko_cv_gecko}-xpcom; then
+	_GECKO_INCLUDE_ROOT="`$PKG_CONFIG --variable=includedir ${gecko_cv_gecko}-xpcom`"
+	_GECKO_CFLAGS="-I$_GECKO_INCLUDE_ROOT"
+	_GECKO_LIBDIR="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`"
+	_GECKO_HOME="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`"
+	_GECKO_PREFIX="`$PKG_CONFIG --variable=prefix ${gecko_cv_gecko}-xpcom`"
+	_GECKO_NSPR=no # XXX asac: this is currently a blind guess and should be a AC test
+else
+	_GECKO_INCLUDE_ROOT="`$PKG_CONFIG --variable=includedir ${gecko_cv_gecko}`/unstable"
+	_GECKO_CFLAGS="`$PKG_CONFIG --cflags ${gecko_cv_gecko}` `$PKG_CONFIG --define-variable=includetype=unstable --cflags ${gecko_cv_gecko}`"
+	_GECKO_LIBDIR="`$PKG_CONFIG --variable=sdkdir ${gecko_cv_gecko}`/bin"
+	_GECKO_HOME=$with_gecko_home
+	_GECKO_PREFIX="`$PKG_CONFIG --variable=prefix ${gecko_cv_gecko}`"
+	_GECKO_NSPR=no # XXX asac: this is currently a blind guess and should be a AC test
+fi
 fi # if gecko_cv_have_gecko
 
 if test "$gecko_cv_gecko_flavour" = "toolkit"; then
@@ -109,9 +132,11 @@
 $1[]=$gecko_cv_gecko
 $1[]_FLAVOUR=$gecko_cv_gecko_flavour
 $1[]_INCLUDE_ROOT=$_GECKO_INCLUDE_ROOT
+$1[]_CFLAGS=$_GECKO_CFLAGS
 $1[]_LIBDIR=$_GECKO_LIBDIR
 $1[]_HOME=$_GECKO_HOME
 $1[]_PREFIX=$_GECKO_PREFIX
+$1[]_NSPR=$_GECKO_NSPR
 
 # **************************************************************
 # This is really gcc-only
@@ -182,7 +207,7 @@
 AC_LANG_PUSH([C++])
 
 _SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS -I$_GECKO_INCLUDE_ROOT"
+CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS $_GECKO_CFLAGS"
 
 AC_MSG_CHECKING([[whether we have a gtk 2 gecko build]])
 AC_RUN_IFELSE(
@@ -215,6 +240,18 @@
 	[gecko_cv_have_debug=no])
 AC_MSG_RESULT([$gecko_cv_have_debug])
 
+AC_MSG_CHECKING([[whether we have a xpcom glue]])
+AC_COMPILE_IFELSE(
+	[AC_LANG_SOURCE(
+		[[
+		  #ifndef XPCOM_GLUE
+		  #error "no xpcom glue found"
+		  #endif]]
+	)],
+	[gecko_cv_have_xpcom_glue=yes],
+	[gecko_cv_have_xpcom_glue=no])
+AC_MSG_RESULT([$gecko_cv_have_xpcom_glue])
+
 CPPFLAGS="$_SAVE_CPPFLAGS"
 
 AC_LANG_POP([C++])
@@ -226,8 +263,14 @@
 	AC_DEFINE([HAVE_GECKO_DEBUG],[1],[Define if gecko is a debug build])
 fi
 
+if test "$gecko_cv_have_xpcom_glue" = "yes"; then
+	AC_DEFINE([HAVE_GECKO_XPCOM_GLUE],[1],[Define if xpcom glue is used])
+fi
+
 fi # if gecko_cv_have_gecko
 
+AM_CONDITIONAL([HAVE_GECKO_DEBUG],[test "$gecko_cv_have_debug" = "yes"])
+AM_CONDITIONAL([HAVE_GECKO_XPCOM_GLUE],[test "$gecko_cv_have_xpcom_glue" = "yes"])
 
 # ***********************
 # Check for gecko version
@@ -238,7 +281,7 @@
 AC_LANG_PUSH([C++])
 
 _SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I$_GECKO_INCLUDE_ROOT"
+CPPFLAGS="$CPPFLAGS $_GECKO_CFLAGS"
 
 AC_CACHE_CHECK([for gecko version],
 	[gecko_cv_gecko_version],
@@ -320,8 +363,11 @@
 gecko_cv_extra_pkg_dependencies=
 
 if test "$gecko_cv_gecko_version_int" -ge "1009000"; then
-	gecko_cv_extra_libs="-L$_GECKO_LIBDIR -lxul"
-	gecko_cv_glue_libs="-L$_GECKO_LIBDIR -lxpcomglue_s"
+	if ! test "$gecko_cv_have_xpcom_glue" = "yes"; then
+		gecko_cv_extra_libs="-L$_GECKO_LIBDIR -lxul"
+	else
+		gecko_cv_glue_libs="-L$_GECKO_LIBDIR -lxpcomglue"
+	fi
 else
 	gecko_cv_extra_pkg_dependencies="${gecko_cv_gecko}-gtkmozembed"
 fi
@@ -350,6 +396,7 @@
 AM_CONDITIONAL([HAVE_GECKO_1_8],[test "$gecko_cv_have_gecko" = "yes" -a "$gecko_cv_gecko_version_int" -ge "1008000"])
 AM_CONDITIONAL([HAVE_GECKO_1_8_1],[test "$gecko_cv_have_gecko" = "yes" -a "$gecko_cv_gecko_version_int" -ge "1008001"])
 AM_CONDITIONAL([HAVE_GECKO_1_9],[test "$gecko_cv_have_gecko" = "yes" -a "$gecko_cv_gecko_version_int" -ge "1009000"])
+AM_CONDITIONAL([HAVE_GECKO_HOME],[test "x$_GECKO_HOME" != "x"])
 ])
 
 # ***************************************************************************
@@ -371,10 +418,20 @@
 _SAVE_CXXFLAGS="$CXXFLAGS"
 _SAVE_LDFLAGS="$LDFLAGS"
 _SAVE_LIBS="$LIBS"
-CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS -I$_GECKO_INCLUDE_ROOT $($PKG_CONFIG --cflags-only-I ${gecko_cv_gecko}-xpcom)"
-CXXFLAGS="$CXXFLAGS $_GECKO_EXTRA_CXXFLAGS $($PKG_CONFIG --cflags-only-other ${gecko_cv_gecko}-xpcom)"
-LDFLAGS="$LDFLAGS $_GECKO_EXTRA_LDFLAGS -Wl,--rpath=$_GECKO_HOME"
-LIBS="$LIBS $($PKG_CONFIG --libs ${gecko_cv_gecko}-xpcom)"
+if test "${gecko_cv_gecko}" = "libxul-embedding" -o "${gecko_cv_gecko}" = "libxul"; then
+	CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS $_GECKO_CFLAGS $($PKG_CONFIG --define-variable=includetype=unstable --cflags-only-I ${gecko_cv_gecko})"
+	CXXFLAGS="$CXXFLAGS $_GECKO_EXTRA_CXXFLAGS $_GECKO_CFLAGS $($PKG_CONFIG --define-variable=includetype=unstable --cflags-only-other ${gecko_cv_gecko})"
+	LIBS="$LIBS $($PKG_CONFIG --libs ${gecko_cv_gecko}) -ldl"
+else
+	CPPFLAGS="$CPPFLAGS $_GECKO_EXTRA_CPPFLAGS $_GECKO_CFLAGS $($PKG_CONFIG --cflags-only-I ${gecko_cv_gecko}-xpcom)"
+	CXXFLAGS="$CXXFLAGS $_GECKO_EXTRA_CXXFLAGS $_GECKO_CFLAGS $($PKG_CONFIG --cflags-only-other ${gecko_cv_gecko}-xpcom)"
+	LIBS="$LIBS $($PKG_CONFIG --libs ${gecko_cv_gecko}-xpcom)"
+fi
+if test -n "$_GECKO_HOME"; then
+	LDFLAGS="$LDFLAGS $_GECKO_EXTRA_LDFLAGS -Wl,--rpath=$_GECKO_HOME"
+else
+	LDFLAGS="$LDFLAGS $_GECKO_EXTRA_LDFLAGS"
+fi
 
 _GECKO_DISPATCH_INCLUDEDIRS="$2"
 
@@ -383,9 +440,11 @@
 # Mind you, it's useful to be able to test against uninstalled mozilla builds...
 _GECKO_DISPATCH_INCLUDEDIRS="$_GECKO_DISPATCH_INCLUDEDIRS dom necko pref"
 
-# Now add them to CPPFLAGS
+# Now add them to CPPFLAGS - asac: well ... not anymore since 1.9 -> test whether they exist before adding.
 for i in $_GECKO_DISPATCH_INCLUDEDIRS; do
-	CPPFLAGS="$CPPFLAGS -I$_GECKO_INCLUDE_ROOT/$i"
+	if test -d "$_GECKO_INCLUDE_ROOT/$i"; then
+		CPPFLAGS="$CPPFLAGS -I$_GECKO_INCLUDE_ROOT/$i"
+	fi
 done
 
 m4_indir([$1],m4_shiftn(2,$@))
@@ -438,11 +497,17 @@
 #include <mozilla-config.h>
 #include <stdlib.h>
 #include <stdio.h>
+
+#ifdef XPCOM_GLUE
+#include <nsXPCOMGlue.h>
+#else
 #include <nsXPCOM.h>
+#endif // XPCOM_GLUE
+
 #include <nsCOMPtr.h>
 #include <nsILocalFile.h>
 #include <nsIServiceManager.h>
-#ifdef HAVE_GECKO_1_8
+#if defined(HAVE_GECKO_1_8) || defined(HAVE_GECKO_1_9)
 #include <nsStringAPI.h>
 #else
 #include <nsString.h>
@@ -450,16 +515,37 @@
 ]]
 [$1],
 [[
+
+nsresult rv;
+#ifdef XPCOM_GLUE
+    static const GREVersionRange greVersion = {
+    "1.8", PR_TRUE,
+    "1.9.*", PR_TRUE
+    };
+    char xpcomLocation[4096];
+    rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0, xpcomLocation, 4096);
+    if (NS_FAILED(rv)) {
+        exit(123);
+    }
+
+    // Startup the XPCOM Glue that links us up with XPCOM.
+    XPCOMGlueStartup(xpcomLocation);
+    if (NS_FAILED(rv)) {
+        exit(124);
+    }
+#endif // XPCOM_GLUE
+
 // redirect unwanted mozilla debug output to the bit bucket
 freopen ("/dev/null", "w", stdout);
 
-nsresult rv;
-nsCOMPtr<nsILocalFile> directory;
+nsCOMPtr<nsILocalFile> directory = nsnull;
+#ifndef XPCOM_GLUE
 rv = NS_NewNativeLocalFile (NS_LITERAL_CSTRING("$_GECKO_HOME"), PR_FALSE,
 			    getter_AddRefs (directory));
 if (NS_FAILED (rv) || !directory) {
 	exit (126);
 }
+#endif
 
 rv = NS_InitXPCOM2 (nsnull, directory, nsnull);
 if (NS_FAILED (rv)) {
@@ -607,21 +693,22 @@
 AC_DEFUN([GECKO_XPIDL],
 [AC_REQUIRE([GECKO_INIT])dnl
 
-_GECKO_LIBDIR="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`"
+if test ${gecko_cv_gecko} = "libxul-embedding" -o ${gecko_cv_gecko} = "libxul"; then
+	_GECKO_LIBDIR="`$PKG_CONFIG pkg-config --variable=sdkdir ${gecko_cv_gecko}`/bin"
+else
+	_GECKO_LIBDIR="`$PKG_CONFIG --variable=libdir ${gecko_cv_gecko}-xpcom`"
+fi
 
 AC_PATH_PROG([XPIDL],[xpidl],[no],[$_GECKO_LIBDIR:$PATH])
 
+if test ${gecko_cv_gecko} = "libxul-embedding" -o ${gecko_cv_gecko} = "libxul"; then
+XPIDL_IDLDIR="`$PKG_CONFIG --variable=idldir ${gecko_cv_gecko}`"
+else
 XPIDL_IDLDIR="`$PKG_CONFIG --variable=idldir ${gecko_cv_gecko}-xpcom`"
-
-# Older geckos don't have this variable, see
-# https://bugzilla.mozilla.org/show_bug.cgi?id=240473
-
 if test -z "$XPIDL_IDLDIR" -o ! -f "$XPIDL_IDLDIR/nsISupports.idl"; then
 	XPIDL_IDLDIR="`echo $_GECKO_LIBDIR | sed -e s!lib!share/idl!`"
 fi
-
 # Some distributions (Gentoo) have it in unusual places
-
 if test -z "$XPIDL_IDLDIR" -o ! -f "$XPIDL_IDLDIR/nsISupports.idl"; then
 	XPIDL_IDLDIR="$_GECKO_INCLUDE_ROOT/idl"
 fi
Index: plugins/desktop-file/Makefile.am
===================================================================
--- plugins/desktop-file/Makefile.am	(revision 7834)
+++ plugins/desktop-file/Makefile.am	(working copy)
@@ -25,8 +25,13 @@
 libdesktopfileplugin_la_LDFLAGS = \
 	-module -avoid-version \
 	-export-symbols $(srcdir)/plugin.symbols \
-	-R$(GECKO_HOME) \
 	$(AM_LDFLAGS)
 
+if !HAVE_GECKO_XPCOM_GLUE
+	libdesktopfileplugin_la_LDFLAGS += \
+		-R$(GECKO_HOME) \
+		$(NULL)
+endif
+
 EXTRA_DIST = \
 	plugin.symbols
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 7834)
+++ src/Makefile.am	(working copy)
@@ -187,6 +187,16 @@
 	$(PYGTK_LIBS)
 endif
 
+
+# we do this to force c++ linkage if we are using the glue and 
+# are running gecko 1.9 because standalone glue embedders that use
+# gtk_moz_embed_* need to #include <gtkmozembed_glue.cpp>
+if HAVE_GECKO_1_9
+if HAVE_GECKO_XPCOM_GLUE
+nodist_EXTRA_epiphany_SOURCES = dummy.cpp
+endif
+endif
+
 epiphany_SOURCES = ephy-main.c
 
 epiphany_CPPFLAGS = \
@@ -201,6 +211,7 @@
 
 epiphany_CFLAGS = \
 	$(DEPENDENCIES_CFLAGS) 	\
+	$(GECKO_CFLAGS) \
 	$(DBUS_CFLAGS)		\
 	$(AM_CFLAGS)
 
@@ -221,6 +232,7 @@
 
 if WITH_GECKO_ENGINE
 epiphany_LDADD += \
+	$(GECKO_LIBS) \
 	$(top_builddir)/embed/mozilla/libephymozillaembed.la
 endif
 
@@ -241,7 +253,9 @@
 endif
 
 if WITH_GECKO_ENGINE
+if !HAVE_GECKO_XPCOM_GLUE
 epiphany_LDFLAGS += -R$(GECKO_HOME)
+endif
 
 epiphany_LDADD += \
 	$(GECKO_LIBS) \
@@ -255,6 +269,7 @@
 endif
 
 epiphany_LDADD += \
+	$(GECKO_LIBS) \
 	$(DEPENDENCIES_LIBS) \
 	$(DBUS_LIBS) \
 	$(LIBINTL)
Index: configure.ac
===================================================================
--- configure.ac	(revision 7834)
+++ configure.ac	(working copy)
@@ -1,4 +1,3 @@
-
 # Copyright © 2000-2004 Marco Pesenti Gritti
 # Copyright © 2003, 2004, 2005, 2006, 2007 Christian Persch
 #
@@ -236,12 +235,44 @@
 
 case "$gecko_cv_gecko" in
 xulrunner) min_version=1.8 ;;
+libxul*) min_version=1.9 ;;
 *firefox) min_version=1.5 ;;
 *) AC_MSG_ERROR([Unsupported gecko "$gecko_cv_gecko"]) ;;
 esac
 
 # Added $gecko_cv_gecko-js for debian xulrunner brokenness
-PKG_CHECK_MODULES([GECKO],[${gecko_cv_gecko}-xpcom >= $min_version ${gecko_cv_gecko}-js $gecko_cv_extra_pkg_dependencies])
+if test $gecko_cv_gecko != "libxul-embedding" -a $gecko_cv_gecko != "libxul"; then
+	PKG_CHECK_MODULES([GECKO],[ ${gecko_cv_gecko}-xpcom >= $min_version ${gecko_cv_gecko}-js $gecko_cv_extra_pkg_dependencies])
+else
+	GECKO_CFLAGS="$GECKO_CFLAGS -UDEBUG"
+	GECKO_LIBS="$GECKO_LIBS `pkg-config --libs ${gecko_cv_gecko}`"
+fi
+
+AC_MSG_CHECKING(nspr in gecko)
+if test "$GECKO_NSPR" != yes; then
+	AC_MSG_RESULT(no)
+	AC_MSG_CHECKING(nspr in system)
+	gecko_nspr=
+	if $PKG_CONFIG --exists mozilla-nspr; then
+		gecko_nspr=mozilla-nspr
+	elif $PKG_CONFIG --exists ${gecko_cv_gecko}-nspr; then
+		gecko_nspr=${gecko_cv_gecko}-nspr
+	fi
+	if $PKG_CONFIG --exists nspr; then
+		gecko_nspr=nspr
+	fi
+	if test -z "$gecko_nspr"; then
+		AC_MSG_ERROR([no nspr available])
+	fi
+
+	GECKO_CFLAGS="$GECKO_CFLAGS `$PKG_CONFIG --cflags ${gecko_nspr}`"
+	GECKO_LIBS="$GECKO_LIBS `$PKG_CONFIG --libs ${gecko_nspr}`"
+	_GECKO_CFLAGS="$GECKO_CFLAGS"
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(yes)
+fi
+
 AC_SUBST([GECKO_CFLAGS])
 AC_SUBST([GECKO_LIBS])
 
@@ -565,7 +596,11 @@
 AC_MSG_RESULT([$enable_desktop_file_plugin])
 
 if test "$enable_desktop_file_plugin" = "yes"; then
-	PKG_CHECK_MODULES([DESKTOP_FILE_PLUGIN_DEP],[${gecko_cv_gecko}-xpcom ${gecko_cv_gecko}-plugin gtk+-2.0 >= 2.6.0])
+	if test "${gecko_cv_gecko}" = "libxul-embedding" -o "${gecko_cv_gecko}" = "libxul"; then
+		PKG_CHECK_MODULES([DESKTOP_FILE_PLUGIN_DEP],[${gecko_cv_gecko} mozilla-plugin gtk+-2.0 >= 2.6.0])
+	else
+		PKG_CHECK_MODULES([DESKTOP_FILE_PLUGIN_DEP],[${gecko_cv_gecko}-xpcom ${gecko_cv_gecko}-plugin gtk+-2.0 >= 2.6.0])
+	fi
 	AC_SUBST([DESKTOP_FILE_PLUGIN_DEP_CFLAGS])
 	AC_SUBST([DESKTOP_FILE_PLUGIN_DEP_LIBS])
 fi
Index: doc/reference/Makefile.am
===================================================================
--- doc/reference/Makefile.am	(revision 7834)
+++ doc/reference/Makefile.am	(working copy)
@@ -206,10 +206,10 @@
 
 if GTK_DOC_USE_LIBTOOL
 GTKDOC_CC = $(LIBTOOL) --mode=compile $(CC) $(INCLUDES) $(AM_CFLAGS) $(CFLAGS)
-GTKDOC_LD = $(LIBTOOL) --mode=link $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS)
+GTKDOC_LD = $(LIBTOOL) --mode=link $(CXX) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS)
 else
 GTKDOC_CC = $(CC) $(INCLUDES) $(AM_CFLAGS) $(CFLAGS)
-GTKDOC_LD = $(CC) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS)
+GTKDOC_LD = $(CXX) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS)
 endif
 
 # We set GPATH here; this gives us semantics for GNU make
Index: embed/mozilla/GtkNSSDialogs.cpp
===================================================================
--- embed/mozilla/GtkNSSDialogs.cpp	(revision 7834)
+++ embed/mozilla/GtkNSSDialogs.cpp	(working copy)
@@ -391,7 +391,7 @@
 
 	return NS_OK;
 }
-  
+ 
 #ifdef HAVE_GECKO_1_9
 NS_IMETHODIMP
 GtkNSSDialogs::NotifyCertProblem (nsIInterfaceRequestor *socketInfo,
@@ -1569,6 +1569,23 @@
   gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_ACCEPT, active >= 0);
 }
 
+
+#ifdef HAVE_GECKO_1_9  
+/**                                                                                                               
+ * displayProtectedAuth - displays notification dialog to the user                                               
+ * that he is expected to authenticate to the token using its                                                    
+ * "protected authentication path" feature                                                                       
+ */
+/* void displayProtectedAuth (in nsIInterfaceRequestor ctx, in nsIProtectedAuthThread runnable); */
+NS_IMETHODIMP
+GtkNSSDialogs::DisplayProtectedAuth (nsIInterfaceRequestor *ctx,
+				     nsIProtectedAuthThread *runnable)
+{
+  return NS_OK;
+}
+#endif
+
+
 /* void ChooseToken (in nsIInterfaceRequestor ctx,
 		     [array, size_is (count)] in wstring tokenNameList,
 		     in unsigned long count,
Index: embed/mozilla/mozilla-embed-single.cpp
===================================================================
--- embed/mozilla/mozilla-embed-single.cpp	(revision 7834)
+++ embed/mozilla/mozilla-embed-single.cpp	(working copy)
@@ -33,6 +33,11 @@
 
 #include <nsStringAPI.h>
 
+#ifdef XPCOM_GLUE
+#include <nsXPCOMGlue.h>
+#include <gtkmozembed_glue.cpp>
+#endif
+
 #include <gtkmozembed.h>
 #include <gtkmozembed_internal.h>
 #include <nsComponentManagerUtils.h>
@@ -353,6 +358,7 @@
 	profile_path = g_build_filename (ephy_dot_dir (), 
 					 MOZILLA_PROFILE_DIR,
 					 (char *) NULL);
+        gtk_moz_embed_set_comp_path (profile_path);
         gtk_moz_embed_set_profile_path (profile_path, MOZILLA_PROFILE_NAME);
         g_free (profile_path);
 }
@@ -591,6 +597,50 @@
 	NS_LogInit ();
 #endif
 
+	nsresult rv;
+#ifdef XPCOM_GLUE
+	static const GREVersionRange greVersion = {
+	  "1.9a", PR_TRUE,
+	  "2", PR_TRUE
+	};
+	char xpcomLocation[4096];
+	rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0, xpcomLocation, 4096);
+	if (NS_FAILED (rv))
+	{
+	  g_warning ("Could not determine locale!\n");
+	  return FALSE;
+	}
+
+	// Startup the XPCOM Glue that links us up with XPCOM.
+	rv = XPCOMGlueStartup(xpcomLocation);
+	if (NS_FAILED (rv))
+	{
+	  g_warning ("Could not determine locale!\n");
+	  return FALSE;
+	}
+
+	rv = GTKEmbedGlueStartup();
+	if (NS_FAILED (rv))
+	{
+	  g_warning ("Could not determine locale!\n");
+	  return FALSE;
+	}
+
+	char *lastSlash = strrchr(xpcomLocation, '/');
+	if (lastSlash)
+	  *lastSlash = '\0';
+
+	gtk_moz_embed_set_path(xpcomLocation);
+#else
+#ifdef HAVE_GECKO_1_9
+        gtk_moz_embed_set_path (MOZILLA_HOME);
+#else
+        gtk_moz_embed_set_comp_path (MOZILLA_HOME);
+#endif
+#endif // XPCOM_GLUE
+	/* Fire up the beast */
+	gtk_moz_embed_push_startup ();
+
 	/* Pre initialization */
 	mozilla_init_plugin_path ();
 
@@ -607,8 +657,6 @@
 
 	gtk_moz_embed_set_directory_service_provider (dp);
 
-	/* Fire up the beast */
-	gtk_moz_embed_push_startup ();
 	/* FIXME check that it succeeded! */
 
 	mozilla_register_components ();
Index: embed/mozilla/EphyAboutModule.cpp
===================================================================
--- embed/mozilla/EphyAboutModule.cpp	(revision 7834)
+++ embed/mozilla/EphyAboutModule.cpp	(working copy)
@@ -499,7 +499,7 @@
 	if (error.IsEmpty () || rawurl.IsEmpty () || url.IsEmpty()) return NS_ERROR_FAILURE;
 
 	nsCOMPtr<nsIURI> uri;
-	rv = NS_NewURI (getter_AddRefs (uri), url, charset.get());
+	rv = NS_NewURI (getter_AddRefs (uri), nsCString(spec), charset.get());
 	/* FIXME can uri be NULL if the original url was invalid? */
 	NS_ENSURE_SUCCESS (rv, rv);
 
Index: embed/mozilla/EphyBrowser.cpp
===================================================================
--- embed/mozilla/EphyBrowser.cpp	(revision 7834)
+++ embed/mozilla/EphyBrowser.cpp	(working copy)
@@ -1,3 +1,4 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  *  Copyright © 2000-2004 Marco Pesenti Gritti
  *  Copyright © 2003, 2004, 2005 Christian Persch
@@ -484,7 +485,6 @@
 
 	MozillaEmbedEvent *info;
 	info = mozilla_embed_event_new (static_cast<gpointer>(aDOMEvent));
-
 	nsresult rv;
 	EventContext context;
 	context.Init (mOwner);
@@ -574,6 +574,7 @@
 
 	gtk_moz_embed_get_nsIWebBrowser (GTK_MOZ_EMBED (gtk_bin_get_child (GTK_BIN (embed))),
 					 getter_AddRefs(mWebBrowser));
+
 	NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
 
 	mWebBrowserFocus = do_QueryInterface (mWebBrowser);
@@ -613,9 +614,10 @@
 	NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
 
 #ifdef HAVE_MOZILLA_PSM
-	nsCOMPtr<nsIDocShell> docShell (do_GetInterface (mWebBrowser, &rv));
-	NS_ENSURE_SUCCESS (rv, rv);
 
+	nsCOMPtr<nsIDocShell> docShell = do_GetInterface (mWebBrowser);
+	NS_ENSURE_TRUE (docShell, NS_ERROR_FAILURE);
+
 	rv = docShell->GetSecurityUI (getter_AddRefs (mSecurityInfo));
 	if (!mSecurityInfo)
 	{
@@ -894,23 +896,26 @@
 
 nsresult EphyBrowser::SetZoom (float aZoom)
 {
-	NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
-
-	nsCOMPtr<nsIContentViewer> contentViewer;	
+	nsCOMPtr<nsIContentViewer> contentViewer;
 	GetContentViewer (getter_AddRefs(contentViewer));
 	NS_ENSURE_TRUE (contentViewer, NS_ERROR_FAILURE);
 
 	nsCOMPtr<nsIMarkupDocumentViewer> mdv = do_QueryInterface(contentViewer);
 	NS_ENSURE_TRUE (mdv, NS_ERROR_FAILURE);
 
+#ifdef HAVE_GECKO_1_9 
+	return mdv->SetFullZoom (aZoom);
+#else
 	return mdv->SetTextZoom (aZoom);
+#endif
 }
 
 nsresult EphyBrowser::GetContentViewer (nsIContentViewer **aViewer)
 {
+	nsresult rv;
 	NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
 
-	nsCOMPtr<nsIDocShell> ourDocShell(do_GetInterface(mWebBrowser));
+	nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface (mWebBrowser);
 	NS_ENSURE_TRUE (ourDocShell, NS_ERROR_FAILURE);
 
 	return ourDocShell->GetContentViewer(aViewer);
@@ -918,16 +923,18 @@
 
 nsresult EphyBrowser::GetZoom (float *aZoom)
 {
-	NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
-
-	nsCOMPtr<nsIContentViewer> contentViewer;	
+	nsCOMPtr<nsIContentViewer> contentViewer;
 	GetContentViewer (getter_AddRefs(contentViewer));
 	NS_ENSURE_TRUE (contentViewer, NS_ERROR_FAILURE);
 
 	nsCOMPtr<nsIMarkupDocumentViewer> mdv = do_QueryInterface(contentViewer);
 	NS_ENSURE_TRUE (mdv, NS_ERROR_FAILURE);
 
+#ifdef HAVE_GECKO_1_9
+	return mdv->GetFullZoom (aZoom);
+#else
 	return mdv->GetTextZoom (aZoom);
+#endif
 }
 
 nsresult
@@ -1070,9 +1077,11 @@
 
 nsresult EphyBrowser::GetPageDescriptor(nsISupports **aPageDescriptor)
 {
+	nsresult rv;
 	NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
 
 	nsCOMPtr<nsIDocShell> ds = do_GetInterface (mWebBrowser);
+	NS_ENSURE_TRUE (ds, NS_ERROR_FAILURE);
 
 	nsCOMPtr<nsIWebPageDescriptor> wpd = do_QueryInterface (ds);
 	NS_ENSURE_TRUE (wpd, NS_ERROR_FAILURE);
@@ -1423,6 +1432,7 @@
 
 nsresult EphyBrowser::GetHasModifiedForms (PRBool *modified)
 {
+	nsresult rv;
 	*modified = PR_FALSE;
 
 	NS_ENSURE_TRUE (mWebBrowser, NS_ERROR_FAILURE);
Index: embed/mozilla/EphyPromptService.cpp
===================================================================
Index: embed/mozilla/Makefile.am
===================================================================
--- embed/mozilla/Makefile.am	(revision 7834)
+++ embed/mozilla/Makefile.am	(working copy)
@@ -157,6 +157,13 @@
 	-DALLOW_PRIVATE_API			\
 	$(AM_CPPFLAGS)
 
+if HAVE_GECKO_XPCOM_GLUE
+if HAVE_GECKO_1_9
+libephymozillaembed_la_CPPFLAGS += \
+ 	-DXPCOM_GLUE_USE_NSPR
+endif
+endif
+
 libephymozillaembed_la_CXXFLAGS = \
 	$(GECKO_CFLAGS)		\
 	$(DEPENDENCIES_CFLAGS) 	\
Index: embed/mozilla/EphyPromptService.h
===================================================================
Index: embed/Makefile.am
===================================================================
--- embed/Makefile.am	(revision 7834)
+++ embed/Makefile.am	(working copy)
@@ -117,6 +117,7 @@
 endif
 
 libephyembedfactory_la_CFLAGS = \
+	$(GECKO_CFLAGS) \
 	$(DEPENDENCIES_CFLAGS) 	\
 	$(AM_CFLAGS)
 
