Use nsIWebBrowser conditionally, so that people don't need to patch mozilla.

This commit is contained in:
Marco Pesenti Gritti 2007-03-14 14:19:31 +01:00
parent 8b4ccf3eb1
commit 1650ff3111
2 changed files with 26 additions and 6 deletions

View File

@ -16,6 +16,16 @@ AM_MAINTAINER_MODE
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_ARG_ENABLE(ns-web-browser,
AC_HELP_STRING([--enable-ns-web-browser],
[Enable features which requires access to nsIWebBrowser]),
[have_ns_web_browser=yes],
[have_ns_web_browser=no])
if test "x$have_ns_web_browser" != "xno"; then
AC_DEFINE([HAVE_NS_WEB_BROWSER], [1], ["Have nsIWebBrowser"])
fi
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
AM_PATH_PYTHON

View File

@ -512,6 +512,7 @@ sugar_browser_save_uri(SugarBrowser *browser,
const char *uri,
const char *filename)
{
#ifdef HAVE_NS_WEB_BROWSER
nsresult rv;
nsCOMPtr<nsIURI> sourceURI;
@ -523,21 +524,26 @@ sugar_browser_save_uri(SugarBrowser *browser,
destFile->InitWithNativePath(nsCString(filename));
nsCOMPtr<nsIWebBrowser> webBrowser;
gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(browser),
getter_AddRefs(webBrowser));
NS_ENSURE_TRUE(webBrowser, FALSE);
nsCOMPtr<nsIWebBrowser> webBrowser;
gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(browser),
getter_AddRefs(webBrowser));
NS_ENSURE_TRUE(webBrowser, FALSE);
nsCOMPtr<nsIWebBrowserPersist> webPersist = do_QueryInterface (webBrowser);
NS_ENSURE_TRUE(webPersist, FALSE);
nsCOMPtr<nsIWebBrowserPersist> webPersist = do_QueryInterface (webBrowser);
NS_ENSURE_TRUE(webPersist, FALSE);
rv = webPersist->SaveURI(sourceURI, nsnull, nsnull, nsnull, nsnull, destFile);
NS_ENSURE_SUCCESS(rv, FALSE);
#else
return FALSE;
#endif
}
gboolean
sugar_browser_save_document(SugarBrowser *browser,
const char *filename)
{
#ifdef HAVE_NS_WEB_BROWSER
nsresult rv;
nsCString cFile(filename);
@ -577,6 +583,10 @@ sugar_browser_save_document(SugarBrowser *browser,
NS_ENSURE_TRUE(webPersist, FALSE);
rv = webPersist->SaveDocument(DOMDocument, destFile, filesFolder, nsnull, 0, 0);
NS_ENSURE_SUCCESS(rv, FALSE);
#else
return FALSE;
#endif
}
GType