2003-01-22 06:57:15 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2000-06-16 21:35:13 +00:00
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla browser.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
|
|
|
* Communications, Inc. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1999, Mozilla. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Scott MacGregor <mscott@netscape.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsExternalHelperAppService_h__
|
|
|
|
#define nsExternalHelperAppService_h__
|
|
|
|
|
2003-07-25 16:48:00 +00:00
|
|
|
#ifdef MOZ_LOGGING
|
|
|
|
#define FORCE_PR_LOG
|
|
|
|
#endif
|
|
|
|
#include "prlog.h"
|
2003-09-25 13:07:24 +00:00
|
|
|
#include "prtime.h"
|
2003-07-25 16:48:00 +00:00
|
|
|
|
2000-06-16 21:35:13 +00:00
|
|
|
#include "nsIExternalHelperAppService.h"
|
2000-06-18 22:07:54 +00:00
|
|
|
#include "nsIExternalProtocolService.h"
|
2000-10-04 06:54:47 +00:00
|
|
|
#include "nsIWebProgressListener.h"
|
2001-05-03 21:24:36 +00:00
|
|
|
#include "nsIHelperAppLauncherDialog.h"
|
2000-06-18 22:07:54 +00:00
|
|
|
|
2000-07-07 01:48:05 +00:00
|
|
|
#include "nsIMIMEInfo.h"
|
2004-01-28 14:48:22 +00:00
|
|
|
#include "nsMIMEInfoImpl.h"
|
2000-09-08 00:12:51 +00:00
|
|
|
#include "nsIMIMEService.h"
|
2000-06-16 21:35:13 +00:00
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsIFile.h"
|
2000-06-17 19:53:44 +00:00
|
|
|
#include "nsIFileStreams.h"
|
|
|
|
#include "nsIOutputStream.h"
|
2000-06-18 01:13:04 +00:00
|
|
|
#include "nsString.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-05 21:28:38 +00:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsILocalFile.h"
|
2003-01-18 02:15:14 +00:00
|
|
|
#include "nsIChannel.h"
|
2000-06-21 08:29:13 +00:00
|
|
|
|
|
|
|
#include "nsIRDFDataSource.h"
|
|
|
|
#include "nsIRDFResource.h"
|
2000-06-16 21:35:13 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-07-11 03:23:24 +00:00
|
|
|
#include "nsIObserver.h"
|
2003-07-02 00:29:26 +00:00
|
|
|
#include "nsCOMArray.h"
|
2003-01-22 06:57:15 +00:00
|
|
|
#include "nsWeakReference.h"
|
2000-06-16 21:35:13 +00:00
|
|
|
|
2000-06-17 00:06:26 +00:00
|
|
|
class nsExternalAppHandler;
|
2000-06-21 08:29:13 +00:00
|
|
|
class nsIMIMEInfo;
|
|
|
|
class nsIRDFService;
|
2002-06-03 20:52:27 +00:00
|
|
|
class nsIDownload;
|
2000-06-17 00:06:26 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* The helper app service. Responsible for handling content that Mozilla
|
|
|
|
* itself can not handle
|
|
|
|
*/
|
2003-01-22 06:57:15 +00:00
|
|
|
class nsExternalHelperAppService
|
|
|
|
: public nsIExternalHelperAppService,
|
|
|
|
public nsPIExternalAppLauncher,
|
|
|
|
public nsIExternalProtocolService,
|
|
|
|
public nsIMIMEService,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
2000-06-16 21:35:13 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIEXTERNALHELPERAPPSERVICE
|
2000-06-17 23:04:53 +00:00
|
|
|
NS_DECL_NSPIEXTERNALAPPLAUNCHER
|
2000-06-18 22:07:54 +00:00
|
|
|
NS_DECL_NSIEXTERNALPROTOCOLSERVICE
|
2000-09-08 00:12:51 +00:00
|
|
|
NS_DECL_NSIMIMESERVICE
|
2001-07-11 03:23:24 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2000-06-16 21:35:13 +00:00
|
|
|
|
|
|
|
nsExternalHelperAppService();
|
|
|
|
virtual ~nsExternalHelperAppService();
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Initializes the RDF datasource from the profile.
|
|
|
|
* @retval NS_OK Loading was successful
|
|
|
|
* @retval errorcode Loading failed
|
|
|
|
* @see mOverRideDataSource
|
|
|
|
*/
|
2000-09-08 00:12:51 +00:00
|
|
|
nsresult InitDataSource();
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Initializes internal state. Will be called automatically when
|
|
|
|
* this service is first instantiated.
|
|
|
|
*/
|
2003-01-22 06:57:15 +00:00
|
|
|
nsresult Init();
|
2000-06-16 21:35:13 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Create an external app handler and binds it with a mime info object which
|
|
|
|
* represents how we want to dispose of this content.
|
|
|
|
* CreateNewExternalHandler is implemented only by the base class.
|
2003-10-04 18:14:51 +00:00
|
|
|
* @param aMIMEInfo MIMEInfo object, representing the type of the
|
2003-09-26 19:49:23 +00:00
|
|
|
* content that should be handled
|
|
|
|
* @param aFileExtension The extension we need to append to our temp file,
|
|
|
|
* INCLUDING the ".". e.g. .mp3
|
2003-10-22 06:46:52 +00:00
|
|
|
* @param aFileName The filename to use
|
|
|
|
* @param aIsAttachment Whether the request has Content-Disposition: attachment
|
|
|
|
* set
|
2003-09-26 19:49:23 +00:00
|
|
|
* @param aWindowContext Window context, as passed to DoContent
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
nsExternalAppHandler * CreateNewExternalHandler(nsIMIMEInfo * aMIMEInfo,
|
|
|
|
const char * aFileExtension,
|
2003-10-22 06:46:52 +00:00
|
|
|
const nsAString& aFileName,
|
|
|
|
PRBool aIsAttachment,
|
2003-07-25 16:48:00 +00:00
|
|
|
nsISupports * aWindowContext);
|
2000-06-21 08:29:13 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Given a content type, look up the user override information to see if
|
|
|
|
* we have a mime info object representing this content type. The user
|
|
|
|
* over ride information is contained in a in memory data source.
|
2003-11-15 15:01:39 +00:00
|
|
|
* @param aMIMEInfo The mime info to fill with the information
|
2003-09-26 19:49:23 +00:00
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
nsresult GetMIMEInfoForMimeTypeFromDS(const char * aContentType,
|
2003-11-15 15:01:39 +00:00
|
|
|
nsIMIMEInfo * aMIMEInfo);
|
2001-11-30 04:37:21 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Given an extension, look up the user override information to see if we
|
|
|
|
* have a mime info object representing this extension. The user over ride
|
|
|
|
* information is contained in a in memory data source.
|
2003-11-15 15:01:39 +00:00
|
|
|
* @param aMIMEInfo The mime info to fill with the information
|
2003-09-26 19:49:23 +00:00
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
nsresult GetMIMEInfoForExtensionFromDS(const char * aFileExtension,
|
2003-11-15 15:01:39 +00:00
|
|
|
nsIMIMEInfo * aMIMEInfo);
|
2003-01-12 01:14:35 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Given a mimetype and an extension, looks up a mime info from the OS.
|
|
|
|
* The mime type is given preference. This function follows the same rules
|
|
|
|
* as nsIMIMEService::GetFromTypeAndExtension.
|
|
|
|
* This is supposed to be overridden by the platform-specific
|
|
|
|
* nsOSHelperAppService!
|
2003-11-15 15:01:39 +00:00
|
|
|
* @param [out] aFound
|
|
|
|
* Should be set to PR_TRUE if the os has a mapping, to
|
|
|
|
* PR_FALSE otherwise. Must not be null.
|
|
|
|
* @return A MIMEInfo. This function must return a MIMEInfo object if it
|
|
|
|
* can allocate one. The only justifiable reason for not
|
|
|
|
* returning one is an out-of-memory error.
|
|
|
|
* If null, the value of aFound is unspecified.
|
2003-09-26 19:49:23 +00:00
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
virtual already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const char * aMIMEType,
|
2003-11-15 15:01:39 +00:00
|
|
|
const char * aFileExt,
|
|
|
|
PRBool * aFound);
|
2003-01-12 01:14:35 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Given a string identifying an application, create an nsIFile representing
|
|
|
|
* it. This function should look in $PATH for the application.
|
|
|
|
* GetFileTokenForPath must be implemented by each platform.
|
|
|
|
* @param platformAppPath A platform specific path to an application that we
|
|
|
|
* got out of the rdf data source. This can be a mac
|
|
|
|
* file spec, a unix path or a windows path depending
|
|
|
|
* on the platform
|
|
|
|
* @param aFile [out] An nsIFile representation of that platform
|
|
|
|
* application path.
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
virtual nsresult GetFileTokenForPath(const PRUnichar * platformAppPath,
|
|
|
|
nsIFile ** aFile) = 0;
|
2003-01-12 01:14:35 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Helper routine used to test whether a given mime type is in our
|
|
|
|
* mimeTypes.rdf data source
|
|
|
|
*/
|
2003-01-12 01:14:35 +00:00
|
|
|
PRBool MIMETypeIsInDataSource(const char * aContentType);
|
|
|
|
|
2000-06-16 21:35:13 +00:00
|
|
|
protected:
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Pointer to the datasource that contains the user override information.
|
|
|
|
* @see InitDataSource
|
|
|
|
*/
|
2000-06-21 08:29:13 +00:00
|
|
|
nsCOMPtr<nsIRDFDataSource> mOverRideDataSource;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_Description;
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_Value;
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_FileExtensions;
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_Path;
|
2003-01-12 01:14:35 +00:00
|
|
|
nsCOMPtr<nsIRDFResource> kNC_UseSystemDefault;
|
2000-06-21 08:29:13 +00:00
|
|
|
nsCOMPtr<nsIRDFResource> kNC_SaveToDisk;
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_AlwaysAsk;
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_HandleInternal;
|
|
|
|
nsCOMPtr<nsIRDFResource> kNC_PrettyName;
|
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Whether mOverRideDataSource is initialized
|
|
|
|
*/
|
2000-09-08 00:12:51 +00:00
|
|
|
PRBool mDataSourceInitialized;
|
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Helper routines for digesting the data source and filling in a mime info
|
|
|
|
* object for a given content type inside that data source.
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
nsresult FillTopLevelProperties(const char * aContentType,
|
|
|
|
nsIRDFResource * aContentTypeNodeResource,
|
|
|
|
nsIRDFService * aRDFService,
|
|
|
|
nsIMIMEInfo * aMIMEInfo);
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* @see FillTopLevelProperties
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
nsresult FillContentHandlerProperties(const char * aContentType,
|
|
|
|
nsIRDFResource * aContentTypeNodeResource,
|
|
|
|
nsIRDFService * aRDFService,
|
|
|
|
nsIMIMEInfo * aMIMEInfo);
|
2000-06-21 08:29:13 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* A small helper function which gets the target for a given source and
|
|
|
|
* property. QIs to a literal and returns a CONST ptr to the string value
|
|
|
|
* of that target
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
nsresult FillLiteralValueFromTarget(nsIRDFResource * aSource,
|
|
|
|
nsIRDFResource * aProperty,
|
|
|
|
const PRUnichar ** aLiteralValue);
|
2000-06-16 21:35:13 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Searches the "extra" array of MIMEInfo objects for an object
|
2003-11-15 15:01:39 +00:00
|
|
|
* with a specific type. If found, it will modify the passed-in
|
|
|
|
* MIMEInfo. Otherwise, it will return an error and the MIMEInfo
|
|
|
|
* will be untouched.
|
2003-09-26 19:49:23 +00:00
|
|
|
* @param aContentType The type to search for.
|
2003-11-15 15:01:39 +00:00
|
|
|
* @param aMIMEInfo [inout] The mime info, if found
|
2003-09-26 19:49:23 +00:00
|
|
|
*/
|
2003-11-15 15:01:39 +00:00
|
|
|
nsresult GetMIMEInfoForMimeTypeFromExtras(const char * aContentType,
|
|
|
|
nsIMIMEInfo * aMIMEInfo);
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Searches the "extra" array of MIMEInfo objects for an object
|
|
|
|
* with a specific extension.
|
|
|
|
* @see GetMIMEInfoForMimeTypeFromExtras
|
|
|
|
*/
|
2003-11-15 15:01:39 +00:00
|
|
|
nsresult GetMIMEInfoForExtensionFromExtras(const char * aExtension,
|
|
|
|
nsIMIMEInfo * aMIMEInfo);
|
2000-09-15 06:07:58 +00:00
|
|
|
|
2003-07-25 16:48:00 +00:00
|
|
|
#ifdef PR_LOGGING
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* NSPR Logging Module. Usage: set NSPR_LOG_MODULES=HelperAppService:level,
|
|
|
|
* where level should be 2 for errors, 3 for debug messages from the cross-
|
|
|
|
* platform nsExternalHelperAppService, and 4 for os-specific debug messages.
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
static PRLogModuleInfo* mLog;
|
2003-09-23 19:27:07 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
// friend, so that it can access the nspr log module
|
2003-09-23 19:27:07 +00:00
|
|
|
friend class nsExternalAppHandler;
|
2003-07-25 16:48:00 +00:00
|
|
|
#endif
|
2004-02-23 22:49:28 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Functions related to the tempory file cleanup service provided by
|
|
|
|
* nsExternalHelperAppService
|
|
|
|
*/
|
2001-07-11 03:23:24 +00:00
|
|
|
nsresult ExpungeTemporaryFiles();
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Array for the files that should be deleted
|
|
|
|
*/
|
2003-07-02 00:29:26 +00:00
|
|
|
nsCOMArray<nsILocalFile> mTemporaryFilesList;
|
2000-09-15 06:07:58 +00:00
|
|
|
};
|
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* We need to read the data out of the incoming stream into a buffer which we
|
|
|
|
* can then use to write the data into the output stream representing the
|
|
|
|
* temp file.
|
|
|
|
*/
|
2000-06-17 19:53:44 +00:00
|
|
|
#define DATA_BUFFER_SIZE (4096*2)
|
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* An external app handler is just a small little class that presents itself as
|
|
|
|
* a nsIStreamListener. It saves the incoming data into a temp file. The handler
|
|
|
|
* is bound to an application when it is created. When it receives an
|
|
|
|
* OnStopRequest it launches the application using the temp file it has
|
|
|
|
* stored the data into. We create a handler every time we have to process
|
|
|
|
* data using a helper app.
|
|
|
|
*/
|
2003-07-25 16:48:00 +00:00
|
|
|
class nsExternalAppHandler : public nsIStreamListener,
|
|
|
|
public nsIHelperAppLauncher,
|
|
|
|
public nsIObserver
|
2000-06-16 21:35:13 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
2001-04-10 06:01:08 +00:00
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
2000-07-07 01:48:05 +00:00
|
|
|
NS_DECL_NSIHELPERAPPLAUNCHER
|
2002-02-20 08:00:29 +00:00
|
|
|
NS_DECL_NSIOBSERVER
|
2000-06-16 21:35:13 +00:00
|
|
|
|
|
|
|
nsExternalAppHandler();
|
2004-01-16 18:22:55 +00:00
|
|
|
~nsExternalAppHandler();
|
2000-06-16 21:35:13 +00:00
|
|
|
|
2004-01-16 18:22:55 +00:00
|
|
|
nsresult Init(nsIMIMEInfo * aMIMEInfo, const char * aFileExtension,
|
|
|
|
nsISupports * aWindowContext,
|
|
|
|
const nsAString& aFilename,
|
|
|
|
PRBool aIsAttachment,
|
|
|
|
nsExternalHelperAppService *aHelperAppService);
|
2000-06-17 02:34:44 +00:00
|
|
|
|
2000-06-16 21:35:13 +00:00
|
|
|
protected:
|
|
|
|
nsCOMPtr<nsIFile> mTempFile;
|
2003-06-30 22:33:36 +00:00
|
|
|
nsCOMPtr<nsIURI> mSourceUrl;
|
2002-05-07 23:07:19 +00:00
|
|
|
nsString mTempFileExtension;
|
2000-07-07 01:48:05 +00:00
|
|
|
nsCOMPtr<nsIMIMEInfo> mMimeInfo;
|
2003-09-26 19:49:23 +00:00
|
|
|
nsCOMPtr<nsIOutputStream> mOutStream; /**< output stream to the temp file */
|
2000-07-10 21:21:10 +00:00
|
|
|
nsCOMPtr<nsISupports> mWindowContext;
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* The following field is set if we were processing an http channel that had
|
|
|
|
* a content disposition header which specified the SUGGESTED file name we
|
|
|
|
* should present to the user in the save to disk dialog.
|
|
|
|
*/
|
2002-05-07 23:07:19 +00:00
|
|
|
nsString mSuggestedFileName;
|
2000-06-16 21:35:13 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* The canceled flag is set if the user canceled the launching of this
|
|
|
|
* application before we finished saving the data to a temp file.
|
|
|
|
*/
|
2002-06-03 20:52:27 +00:00
|
|
|
PRPackedBool mCanceled;
|
2000-07-07 01:48:05 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* have we received information from the user about how they want to
|
|
|
|
* dispose of this content
|
|
|
|
*/
|
2002-06-06 22:12:18 +00:00
|
|
|
PRPackedBool mReceivedDispositionInfo;
|
2002-06-03 20:52:27 +00:00
|
|
|
PRPackedBool mStopRequestIssued;
|
|
|
|
PRPackedBool mProgressListenerInitialized;
|
2003-09-26 19:49:23 +00:00
|
|
|
/// This is set when handling something with "Content-Disposition: attachment"
|
2002-09-03 22:00:22 +00:00
|
|
|
PRPackedBool mHandlingAttachment;
|
2003-09-25 13:07:24 +00:00
|
|
|
PRTime mTimeDownloadStarted;
|
2002-02-20 08:00:29 +00:00
|
|
|
PRInt32 mContentLength;
|
2003-09-26 19:49:23 +00:00
|
|
|
PRInt32 mProgress; /**< Number of bytes received (for sending progress notifications). */
|
2000-07-07 01:48:05 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* When we are told to save the temp file to disk (in a more permament
|
|
|
|
* location) before we are done writing the content to a temp file, then
|
|
|
|
* we need to remember the final destination until we are ready to use it.
|
|
|
|
*/
|
2000-07-07 01:48:05 +00:00
|
|
|
nsCOMPtr<nsIFile> mFinalFileDestination;
|
|
|
|
|
2003-12-19 15:18:59 +00:00
|
|
|
char mDataBuffer[DATA_BUFFER_SIZE];
|
2000-07-07 01:48:05 +00:00
|
|
|
|
|
|
|
nsresult SetUpTempFile(nsIChannel * aChannel);
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* When we download a helper app, we are going to retarget all load
|
|
|
|
* notifications into our own docloader and load group instead of
|
|
|
|
* using the window which initiated the load....RetargetLoadNotifications
|
|
|
|
* contains that information...
|
|
|
|
*/
|
2004-02-07 19:52:16 +00:00
|
|
|
void RetargetLoadNotifications(nsIRequest *request);
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* If the user tells us how they want to dispose of the content and
|
|
|
|
* we still haven't finished downloading while they were deciding,
|
|
|
|
* then create a progress listener of some kind so they know
|
|
|
|
* what's going on...
|
|
|
|
*/
|
2002-06-03 20:52:27 +00:00
|
|
|
nsresult CreateProgressListener();
|
2003-07-25 16:48:00 +00:00
|
|
|
nsresult PromptForSaveToFile(nsILocalFile ** aNewFile,
|
|
|
|
const nsAFlatString &aDefaultFile,
|
|
|
|
const nsAFlatString &aDefaultFileExt);
|
2003-10-22 06:46:52 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* After we're done prompting the user for any information, if the original
|
|
|
|
* channel had a refresh url associated with it (which might point to a
|
|
|
|
* "thank you for downloading" kind of page, then process that....It is safe
|
|
|
|
* to invoke this method multiple times. We'll clear mOriginalChannel after
|
|
|
|
* it's called and this ensures we won't call it again....
|
|
|
|
*/
|
2000-11-01 08:06:19 +00:00
|
|
|
void ProcessAnyRefreshTags();
|
2001-01-25 06:48:16 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* An internal method used to actually move the temp file to the final
|
|
|
|
* destination once we done receiving data AND have showed the progress dialog
|
|
|
|
*/
|
2001-01-25 06:48:16 +00:00
|
|
|
nsresult MoveFile(nsIFile * aNewFileLocation);
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* An internal method used to actually launch a helper app given the temp file
|
|
|
|
* once we are done receiving data AND have showed the progress dialog.
|
2004-02-23 22:49:28 +00:00
|
|
|
* Uses the application specified in the mime info.
|
2003-09-26 19:49:23 +00:00
|
|
|
*/
|
2004-02-23 22:49:28 +00:00
|
|
|
nsresult OpenWithApplication();
|
2002-06-03 20:52:27 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Helper routine which peaks at the mime action specified by mMimeInfo
|
|
|
|
* and calls either MoveFile or OpenWithApplication
|
|
|
|
*/
|
2001-01-25 06:48:16 +00:00
|
|
|
nsresult ExecuteDesiredAction();
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Helper routine that searches a pref string for a given mime type
|
|
|
|
*/
|
2003-01-12 01:14:35 +00:00
|
|
|
PRBool GetNeverAskFlagFromPref(const char * prefName, const char * aContentType);
|
2002-06-03 20:52:27 +00:00
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Initialize an nsIDownload object for use as a progress object
|
|
|
|
*/
|
2002-06-03 20:52:27 +00:00
|
|
|
nsresult InitializeDownload(nsIDownload*);
|
|
|
|
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Helper routine to ensure mSuggestedFileName is "correct";
|
2004-01-16 18:22:55 +00:00
|
|
|
* this ensures that mTempFileExtension only contains an extension when it
|
|
|
|
* is different from mSuggestedFileName's extension.
|
2003-09-26 19:49:23 +00:00
|
|
|
*/
|
2004-01-16 18:22:55 +00:00
|
|
|
void EnsureSuggestedFileName();
|
2003-09-26 19:49:23 +00:00
|
|
|
|
2002-05-17 00:31:53 +00:00
|
|
|
typedef enum { kReadError, kWriteError, kLaunchError } ErrorType;
|
2003-09-26 19:49:23 +00:00
|
|
|
/**
|
|
|
|
* Utility function to send proper error notification to web progress listener
|
|
|
|
*/
|
2002-05-17 00:31:53 +00:00
|
|
|
void SendStatusChange(ErrorType type, nsresult aStatus, nsIRequest *aRequest, const nsAFlatString &path);
|
2000-10-04 06:54:47 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
|
2003-09-26 19:49:23 +00:00
|
|
|
nsCOMPtr<nsIChannel> mOriginalChannel; /**< in the case of a redirect, this will be the pre-redirect channel. */
|
2001-05-03 21:24:36 +00:00
|
|
|
nsCOMPtr<nsIHelperAppLauncherDialog> mDialog;
|
2003-01-12 01:14:35 +00:00
|
|
|
nsExternalHelperAppService *mHelperAppService;
|
2004-01-28 22:05:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The request that's being loaded. Not used after OnStopRequest, so a weak
|
|
|
|
* reference suffices. Initialized in OnStartRequest.
|
|
|
|
*/
|
|
|
|
nsIRequest* mRequest;
|
2000-06-16 21:35:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // nsExternalHelperAppService_h__
|