aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2007-08-28 04:26:33 +0800
committerChristian Persch <chpe@src.gnome.org>2007-08-28 04:26:33 +0800
commit528612649e4fc47122f8fd34923f898e56427713 (patch)
tree45913e9f654787b05a04c0013e7ace8187cf6a1f
parent437e1b0d173f8c09ab7e5d0db9f6f3889fc5aacc (diff)
downloadgsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.tar
gsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.tar.gz
gsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.tar.bz2
gsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.tar.lz
gsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.tar.xz
gsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.tar.zst
gsoc2013-epiphany-528612649e4fc47122f8fd34923f898e56427713.zip
Merged from embed/mozilla
svn path=/trunk/; revision=7306
-rw-r--r--embed/xulrunner/embed/MozDownload.cpp36
-rw-r--r--embed/xulrunner/embed/MozDownload.h1
2 files changed, 32 insertions, 5 deletions
diff --git a/embed/xulrunner/embed/MozDownload.cpp b/embed/xulrunner/embed/MozDownload.cpp
index eed7adcd9..cb7f32a2f 100644
--- a/embed/xulrunner/embed/MozDownload.cpp
+++ b/embed/xulrunner/embed/MozDownload.cpp
@@ -58,6 +58,7 @@
#include <nsIIOService.h>
#include <nsILocalFile.h>
#include <nsIMIMEInfo.h>
+#include <nsIMIMEService.h>
#include <nsIObserver.h>
#include <nsIRequest.h>
#include <nsIURI.h>
@@ -88,6 +89,7 @@ MozDownload::MozDownload() :
mTotalProgress(-1),
mCurrentProgress(0),
mMaxSize(-1),
+ mAddToRecent(PR_TRUE),
mStatus(NS_OK),
mEmbedPersist(nsnull),
mDownloadState(EPHY_DOWNLOAD_INITIALISING)
@@ -149,6 +151,7 @@ MozDownload::Init (nsIURI *aSource,
mInterval = PROGRESS_RATE;
mLastUpdate = mStartTime;
mMIMEInfo = aMIMEInfo;
+ mAddToRecent = addToView;
/* This will create a refcount cycle, which needs to be broken in ::OnStateChange */
mCancelable = aCancelable;
@@ -309,6 +312,22 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
/* break refcount cycle */
mCancelable = nsnull;
+
+ nsCString destSpec;
+ nsCString mimeType;
+
+ mDestination->GetSpec (destSpec);
+
+ if (NS_SUCCEEDED (aStatus) && mMIMEInfo)
+ {
+ rv = mMIMEInfo->GetMIMEType (mimeType);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ }
+
+ if (mAddToRecent)
+ {
+ ephy_file_add_recent_item (destSpec.get(), mimeType.get());
+ }
if (mEmbedPersist)
{
@@ -328,9 +347,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
return NS_OK;
#else
GnomeVFSMimeApplication *helperApp;
- nsCString mimeType;
- rv = mMIMEInfo->GetMIMEType (mimeType);
- NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ NS_ENSURE_TRUE (mMIMEInfo, NS_ERROR_FAILURE);
nsString description;
mMIMEInfo->GetApplicationDescription (description);
@@ -356,7 +373,7 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
rv = mDestination->GetSpec (aDest);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
- ephy_file_launch_application (helperApp, aDest.get (), user_time);
+ ephy_file_launch_application (helperApp, destSpec.get (), user_time);
gnome_vfs_mime_application_free (helperApp);
g_strfreev (str);
@@ -563,6 +580,15 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
ephy_embed_persist_set_dest (EPHY_EMBED_PERSIST (embedPersist),
cPath.get());
}
+
+ nsCOMPtr<nsIMIMEService> mimeService (do_GetService ("@mozilla.org/mime;1"));
+ nsCOMPtr<nsIMIMEInfo> mimeInfo;
+ if (mimeService)
+ {
+ mimeService->GetFromTypeAndExtension (nsCString(contentType),
+ nsCString(),
+ getter_AddRefs (mimeInfo));
+ }
PRBool isHTML = (contentType &&
(strcmp (contentType, "text/html") == 0 ||
@@ -588,7 +614,7 @@ nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceURI
/* dlListener attaches to its progress dialog here, which gains ownership */
/* FIXME is that still true? */
rv = downloader->InitForEmbed (inOriginalURI, destURI, fileDisplayName,
- nsnull, timeNow, nsnull, webPersist, embedPersist, aMaxSize);
+ mimeInfo, timeNow, nsnull, webPersist, embedPersist, aMaxSize);
NS_ENSURE_SUCCESS (rv, rv);
rv = webPersist->SetProgressListener (downloader);
diff --git a/embed/xulrunner/embed/MozDownload.h b/embed/xulrunner/embed/MozDownload.h
index bf7f11e1b..27fef41c7 100644
--- a/embed/xulrunner/embed/MozDownload.h
+++ b/embed/xulrunner/embed/MozDownload.h
@@ -138,6 +138,7 @@ protected:
PRInt64 mTotalProgress;
PRInt64 mCurrentProgress;
PRInt64 mMaxSize;
+ PRBool mAddToRecent;
nsresult mStatus;