From 1650ff31114cf38538a95296f717ac76bbcc8f3f Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 14 Mar 2007 14:19:31 +0100 Subject: [PATCH] Use nsIWebBrowser conditionally, so that people don't need to patch mozilla. --- configure.ac | 10 ++++++++++ lib/src/sugar-browser.cpp | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index ac02df8f..35e67f8e 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp index 49f6af9f..80efa683 100644 --- a/lib/src/sugar-browser.cpp +++ b/lib/src/sugar-browser.cpp @@ -512,6 +512,7 @@ sugar_browser_save_uri(SugarBrowser *browser, const char *uri, const char *filename) { +#ifdef HAVE_NS_WEB_BROWSER nsresult rv; nsCOMPtr sourceURI; @@ -523,21 +524,26 @@ sugar_browser_save_uri(SugarBrowser *browser, destFile->InitWithNativePath(nsCString(filename)); - nsCOMPtr webBrowser; - gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(browser), - getter_AddRefs(webBrowser)); - NS_ENSURE_TRUE(webBrowser, FALSE); + nsCOMPtr webBrowser; + gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(browser), + getter_AddRefs(webBrowser)); + NS_ENSURE_TRUE(webBrowser, FALSE); - nsCOMPtr webPersist = do_QueryInterface (webBrowser); - NS_ENSURE_TRUE(webPersist, FALSE); + nsCOMPtr 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