diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-10-24 18:56:53 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-10-24 18:56:53 +0800 |
commit | 2a93fb20b6618d44c05589bb636fe77b7b04e075 (patch) | |
tree | 8291a66e4f65ea6c17c050dc1a066bd7c9a5582c /embed/mozilla/mozilla-embed-persist.cpp | |
parent | 5767e9aeb78133de615e08087cd96c4beb89f1d7 (diff) | |
download | gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.tar gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.tar.gz gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.tar.bz2 gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.tar.lz gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.tar.xz gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.tar.zst gsoc2013-epiphany-2a93fb20b6618d44c05589bb636fe77b7b04e075.zip |
Add an helper to initialize downloads.
2003-10-24 Marco Pesenti Gritti <marco@gnome.org>
* embed/mozilla/MozDownload.cpp:
* embed/mozilla/MozDownload.h:
Add an helper to initialize downloads.
* embed/ephy-embed-persist.h:
Add a flag to ask destination.
* embed/mozilla/EphyHeaderSniffer.cpp:
* embed/mozilla/EphyHeaderSniffer.h:
Use the helper. Add code to determine a good
filename.
* embed/mozilla/mozilla-embed-persist.cpp:
Use a MozDownload directly if there is a dest set,
it doesnt make sense to use sniffer for favicons.
Diffstat (limited to 'embed/mozilla/mozilla-embed-persist.cpp')
-rw-r--r-- | embed/mozilla/mozilla-embed-persist.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/embed/mozilla/mozilla-embed-persist.cpp b/embed/mozilla/mozilla-embed-persist.cpp index 846b63c8d..8ba3596e8 100644 --- a/embed/mozilla/mozilla-embed-persist.cpp +++ b/embed/mozilla/mozilla-embed-persist.cpp @@ -20,6 +20,7 @@ #include "EphyWrapper.h" #include "EphyHeaderSniffer.h" +#include "MozDownload.h" #include "mozilla-embed.h" #include "mozilla-embed-persist.h" @@ -206,10 +207,6 @@ impl_save (EphyEmbedPersist *persist) rv = NS_NewURI(getter_AddRefs(inURI), sURI); if (NS_FAILED(rv) || !inURI) return G_FAILED; - /* Filename to save to */ - nsAutoString inFilename; - inFilename.AssignWithConversion (filename); - /* Get post data */ nsCOMPtr<nsIInputStream> postData; if (wrapper) @@ -244,20 +241,37 @@ impl_save (EphyEmbedPersist *persist) if (NS_FAILED(rv) || !DOMDocument) return G_FAILED; } - /* Create an header sniffer and do the save */ - nsCOMPtr<nsIWebBrowserPersist> webPersist = - MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; - if (!webPersist) return G_FAILED; - - EphyHeaderSniffer* sniffer = new EphyHeaderSniffer - (webPersist, MOZILLA_EMBED_PERSIST (persist), - tmpFile, inURI, DOMDocument, postData, - inFilename, flags & EMBED_PERSIST_BYPASSCACHE); - if (!sniffer) return G_FAILED; + if (filename == NULL) + { + /* Create an header sniffer and do the save */ + nsCOMPtr<nsIWebBrowserPersist> webPersist = + MOZILLA_EMBED_PERSIST (persist)->priv->mPersist; + if (!webPersist) return G_FAILED; + + EphyHeaderSniffer* sniffer = new EphyHeaderSniffer + (webPersist, MOZILLA_EMBED_PERSIST (persist), + tmpFile, inURI, DOMDocument, postData, + flags & EMBED_PERSIST_BYPASSCACHE); + if (!sniffer) return G_FAILED; - webPersist->SetProgressListener(sniffer); - rv = webPersist->SaveURI(inURI, nsnull, nsnull, nsnull, nsnull, tmpFile); - if (NS_FAILED (rv)) return G_FAILED; + webPersist->SetProgressListener(sniffer); + rv = webPersist->SaveURI(inURI, nsnull, nsnull, nsnull, nsnull, tmpFile); + if (NS_FAILED (rv)) return G_FAILED; + } + else + { + /* Filename to save to */ + nsCOMPtr<nsILocalFile> destFile; + rv = NS_NewNativeLocalFile (nsDependentCString(filename), + PR_TRUE, getter_AddRefs(destFile)); + if (NS_FAILED(rv) || !destFile) return G_FAILED; + + rv = InitiateMozillaDownload (DOMDocument, inURI, destFile, + nsnull, inURI, MOZILLA_EMBED_PERSIST (persist), + flags & EMBED_PERSIST_BYPASSCACHE, + postData); + if (NS_FAILED (rv)) return G_FAILED; + } return G_OK; } |