aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/mozilla-embed-persist.cpp
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@src.gnome.org>2004-06-04 02:51:32 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-06-04 02:51:32 +0800
commitb774b547788b74884b9eb690c548a6016e714023 (patch)
tree72b9df09c0fc257169b3e9b9cbdc349e56a63101 /embed/mozilla/mozilla-embed-persist.cpp
parentb699b40d663955560655271f7645ae277e6076c8 (diff)
downloadgsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.tar
gsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.tar.gz
gsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.tar.bz2
gsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.tar.lz
gsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.tar.xz
gsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.tar.zst
gsoc2013-epiphany-b774b547788b74884b9eb690c548a6016e714023.zip
merge mozilla-embed-strings branch
Diffstat (limited to 'embed/mozilla/mozilla-embed-persist.cpp')
-rw-r--r--embed/mozilla/mozilla-embed-persist.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp
index 7b20ad197..b014fd97e 100644
--- a/embed/mozilla/mozilla-embed-persist.cpp
+++ b/embed/mozilla/mozilla-embed-persist.cpp
@@ -29,6 +29,7 @@
#include "EphyBrowser.h"
#include "EphyHeaderSniffer.h"
#include "MozDownload.h"
+#include "EphyUtils.h"
#include <stddef.h>
@@ -36,13 +37,9 @@
#include <nsCWebBrowserPersist.h>
#include <nsIHistoryEntry.h>
#include <nsISHEntry.h>
-
-#ifdef ALLOW_PRIVATE_STRINGS
-#include <nsString.h>
-#include <nsNetUtil.h>
-#include <nsIDocumentEncoder.h>
-#include <nsIDocument.h>
-#endif
+#include <nsIDOMSerializer.h>
+#include <nsIIOService.h>
+#include <nsNetCID.h>
static void
mozilla_embed_persist_class_init (MozillaEmbedPersistClass *klass);
@@ -176,12 +173,12 @@ impl_save (EphyEmbedPersist *persist)
if (tmp_filename == NULL) return FALSE;
nsCOMPtr<nsILocalFile> tmpFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID);
- tmpFile->InitWithNativePath (nsDependentCString (tmp_filename));
+ tmpFile->InitWithNativePath (nsEmbedCString (tmp_filename));
g_free (tmp_filename);
/* Get the uri to save to */
nsCOMPtr<nsIURI> inURI;
- nsCAutoString sURI;
+ nsEmbedCString sURI;
if (uri)
{
sURI.Assign (uri);
@@ -191,8 +188,9 @@ impl_save (EphyEmbedPersist *persist)
rv = browser->GetDocumentUrl (sURI);
NS_ENSURE_SUCCESS (rv, FALSE);
}
- NS_NewURI(getter_AddRefs(inURI), sURI);
- if (!inURI) return FALSE;
+
+ rv = EphyUtils::NewURI (getter_AddRefs(inURI), sURI);
+ NS_ENSURE_SUCCESS (rv, FALSE);
/* Get post data */
nsCOMPtr<nsIInputStream> postData;
@@ -262,7 +260,7 @@ impl_save (EphyEmbedPersist *persist)
{
/* Filename to save to */
nsCOMPtr<nsILocalFile> destFile;
- NS_NewNativeLocalFile (nsDependentCString(filename),
+ NS_NewNativeLocalFile (nsEmbedCString(filename),
PR_TRUE, getter_AddRefs(destFile));
NS_ENSURE_TRUE (destFile, FALSE);
@@ -309,19 +307,20 @@ impl_to_string (EphyEmbedPersist *persist)
}
if (NS_FAILED(rv) || !DOMDocument) return NULL;
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(DOMDocument);
- if(!doc) return NULL;
+ nsCOMPtr<nsIDOMNode> node = do_QueryInterface(DOMDocument);
+ if (!node) return NULL;
- nsCOMPtr<nsIDocumentEncoder> encoder = do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/html");
- NS_ENSURE_SUCCESS(rv, NULL);
+ nsCOMPtr<nsIDOMSerializer> serializer;
+ serializer = do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS (rv, FALSE);
- rv = encoder->Init(doc, NS_LITERAL_STRING("text/html"), nsIDocumentEncoder::OutputAbsoluteLinks);
- NS_ENSURE_SUCCESS(rv, NULL);
+ nsEmbedString outString;
+ serializer->SerializeToString(node, outString);
- nsAutoString aOutputString;
- encoder->EncodeToString(aOutputString);
+ nsEmbedCString cOutString;
+ NS_UTF16ToCString (outString, NS_CSTRING_ENCODING_UTF8, cOutString);
- return g_strdup (NS_ConvertUTF16toUTF8(aOutputString).get());
+ return g_strdup (cOutString.get());
}
static GObject *