зеркало из https://github.com/mozilla/gecko-dev.git
bug 218817. replace GetDownloadInfo with attributes on nsIExternalHelperAppService -
this means 2 new attributes: readonly attribute nsIFile targetFile; readonly attribute PRTime timeDownloadStarted; (no caller of GetDownloadInfo needed all three pieces of information that it provided) r=bzbarsky sr=darin
This commit is contained in:
Родитель
8f369f59f4
Коммит
b5206035a9
|
@ -146,9 +146,9 @@ EmbedProgress::OnStateChange(nsIWebProgress *aWebProgress,
|
|||
if( moz->EmbedRef->app_launcher )
|
||||
{
|
||||
nsCOMPtr<nsIURI> aSourceUrl;
|
||||
PRInt64 dummy;
|
||||
nsCOMPtr<nsIFile> tempFile;
|
||||
moz->EmbedRef->app_launcher->GetDownloadInfo( getter_AddRefs(aSourceUrl), &dummy, getter_AddRefs( tempFile ) );
|
||||
moz->EmbedRef->app_launcher->GetSource( getter_AddRefs(aSourceUrl) );
|
||||
moz->EmbedRef->app_launcher->GetTargetFile( getter_AddRefs( tempFile ) );
|
||||
|
||||
if( tempFile )
|
||||
{
|
||||
|
|
|
@ -86,9 +86,9 @@ NS_IMETHODIMP nsUnknownContentTypeHandler::Show( nsIHelperAppLauncher *aLauncher
|
|||
mimeInfo->GetMIMEType( &mimeType );
|
||||
|
||||
nsCOMPtr<nsIURI> aSourceUrl;
|
||||
PRInt64 dummy;
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
aLauncher->GetDownloadInfo( getter_AddRefs(aSourceUrl), &dummy, getter_AddRefs(aFile) );
|
||||
aLauncher->GetSource( getter_AddRefs(aSourceUrl) );
|
||||
aLauncher->GetTargetFile( getter_AddRefs(aFile) );
|
||||
|
||||
char *url;
|
||||
nsCAutoString specString;
|
||||
|
|
|
@ -364,9 +364,7 @@ nsHelperAppDialog.prototype = {
|
|||
// in that case).
|
||||
|
||||
// Need to get temporary file and check for executable-ness.
|
||||
var ignore1 = new Object;
|
||||
var ignore2 = new Object;
|
||||
var tmpFile = this.mLauncher.getDownloadInfo( ignore1, ignore2 );
|
||||
var tmpFile = this.mLauncher.targetFile;
|
||||
|
||||
// Default is Ok if the file isn't executable (and vice-versa).
|
||||
result = !tmpFile.isExecutable();
|
||||
|
|
|
@ -963,23 +963,20 @@ NS_IMETHODIMP nsExternalAppHandler::SetWebProgressListener(nsIWebProgressListene
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsExternalAppHandler::GetDownloadInfo(nsIURI ** aSourceUrl, PRInt64 * aTimeDownloadStarted, nsIFile ** aTarget)
|
||||
NS_IMETHODIMP nsExternalAppHandler::GetTargetFile(nsIFile** aTarget)
|
||||
{
|
||||
|
||||
*aTimeDownloadStarted = mTimeDownloadStarted;
|
||||
|
||||
if (mFinalFileDestination)
|
||||
{
|
||||
*aTarget = mFinalFileDestination;
|
||||
}
|
||||
else
|
||||
*aTarget = mTempFile;
|
||||
|
||||
NS_IF_ADDREF(*aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aSourceUrl = mSourceUrl;
|
||||
NS_IF_ADDREF(*aSourceUrl);
|
||||
|
||||
NS_IMETHODIMP nsExternalAppHandler::GetTimeDownloadStarted(PRTime* aTime)
|
||||
{
|
||||
*aTime = mTimeDownloadStarted;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1366,10 +1363,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
|
|||
* happening if we decide to execute
|
||||
*/
|
||||
nsCOMPtr<nsIFile> fileToTest;
|
||||
nsCOMPtr<nsIURI> garbageURI;
|
||||
PRInt64 garbageTimestamp;
|
||||
GetDownloadInfo(getter_AddRefs(garbageURI), &garbageTimestamp,
|
||||
getter_AddRefs(fileToTest));
|
||||
GetTargetFile(getter_AddRefs(fileToTest));
|
||||
if (fileToTest) {
|
||||
PRBool isExecutable;
|
||||
rv = fileToTest->IsExecutable(&isExecutable);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define FORCE_PR_LOG
|
||||
#endif
|
||||
#include "prlog.h"
|
||||
#include "prtime.h"
|
||||
|
||||
#include "nsIExternalHelperAppService.h"
|
||||
#include "nsIExternalProtocolService.h"
|
||||
|
@ -229,7 +230,7 @@ protected:
|
|||
PRPackedBool mProgressListenerInitialized;
|
||||
// This is set when handling something with "Content-Disposition: attachment"
|
||||
PRPackedBool mHandlingAttachment;
|
||||
PRInt64 mTimeDownloadStarted;
|
||||
PRTime mTimeDownloadStarted;
|
||||
PRInt32 mContentLength;
|
||||
PRInt32 mProgress; // Number of bytes received (for sending progress notifications).
|
||||
|
||||
|
|
|
@ -20,10 +20,6 @@
|
|||
* Scott MacGregor <mscott@netscape.com>
|
||||
*/
|
||||
|
||||
/* The external helper app service is used for finding and launching
|
||||
platform specific external applications for a given mime content type.
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
|
@ -33,83 +29,121 @@ interface nsIFile;
|
|||
interface nsIMIMEInfo;
|
||||
interface nsIWebProgressListener;
|
||||
|
||||
|
||||
/**
|
||||
* The external helper app service is used for finding and launching
|
||||
* platform specific external applications for a given mime content type.
|
||||
*/
|
||||
[scriptable, uuid(663CC0AA-42EA-11d4-98D0-001083010E9B)]
|
||||
interface nsIExternalHelperAppService : nsISupports
|
||||
{
|
||||
// doContent: binds an external helper application to a stream listener. The caller should pump data
|
||||
// into the returned stream listener. When the OnStopRequest is issued, the stream listener implementation
|
||||
// will launch the helper app with this data.
|
||||
// aMimeContentType --> the content type of the incoming data
|
||||
// aRequest --> the request corresponding to the incoming data
|
||||
// aWindowContext --> use GetInterface to retrieve properties like the dom window or parent window...
|
||||
// the service might need this in order to bring up dialogs.
|
||||
// returns a nsIStreamListener which the caller should pump the data into.
|
||||
/**
|
||||
* Binds an external helper application to a stream listener. The caller
|
||||
* should pump data into the returned stream listener. When the OnStopRequest
|
||||
* is issued, the stream listener implementation will launch the helper app
|
||||
* with this data.
|
||||
* @param aMimeContentType The content type of the incoming data
|
||||
* @param aRequest The request corresponding to the incoming data
|
||||
* @param aWindowContext Use GetInterface to retrieve properties like the
|
||||
* dom window or parent window...
|
||||
* The service might need this in order to bring up dialogs.
|
||||
* @return A nsIStreamListener which the caller should pump the data into.
|
||||
*/
|
||||
nsIStreamListener doContent (in string aMimeContentType, in nsIRequest aRequest,
|
||||
in nsISupports aWindowContext);
|
||||
|
||||
// applyDecodingForType: returns true if this type is to be decoded
|
||||
// prior to saving or passing off to helper apps,
|
||||
// false otherwise
|
||||
/**
|
||||
* Returns true if this type is to be decoded prior to saving or passing
|
||||
* off to helper apps, false otherwise
|
||||
*/
|
||||
boolean applyDecodingForType (in string aMimeContentType);
|
||||
|
||||
// applyDecodingForExtension: returns false if files with this extension
|
||||
// are not to be decoded prior to saving or
|
||||
// passing off to helper apps, false otherwise
|
||||
/**
|
||||
* Returns false if files with this extension are not to be decoded prior
|
||||
* to saving or passing off to helper apps, false otherwise
|
||||
*/
|
||||
boolean applyDecodingForExtension(in string aExtension);
|
||||
};
|
||||
|
||||
// this is a private interface shared between external app handlers and the platform specific
|
||||
// external helper app service
|
||||
/**
|
||||
* This is a private interface shared between external app handlers and the platform specific
|
||||
* external helper app service
|
||||
*/
|
||||
[scriptable, uuid(491D04D5-449C-11d4-98D0-001083010E9B)]
|
||||
interface nsPIExternalAppLauncher : nsISupports
|
||||
{
|
||||
// launchAppWithTempFile --> used by the handler to actually launch the helper application
|
||||
// aTempFile --> the file which contains the data we want the helper app to use when it is launched
|
||||
/**
|
||||
* Used by the handler to actually launch the helper application.
|
||||
* @param aTempFile The file which contains the data we want the helper app
|
||||
* to use when it is launched
|
||||
*/
|
||||
void launchAppWithTempFile(in nsIMIMEInfo aMIMEInfo, in nsIFile aTempFile);
|
||||
|
||||
// mscott --> eventually I should move this into a new service so other consumers can add temporary files
|
||||
// they want deleted on exit.
|
||||
// aTemporaryFile --> a temporary file we should delete on exit.
|
||||
|
||||
/**
|
||||
* mscott --> eventually I should move this into a new service so other
|
||||
* consumers can add temporary files they want deleted on exit.
|
||||
* @param aTemporaryFile A temporary file we should delete on exit.
|
||||
*/
|
||||
void deleteTemporaryFileOnExit(in nsIFile aTemporaryFile);
|
||||
};
|
||||
|
||||
// a helper app launcher is a small object created to handle the launching of an external application.
|
||||
|
||||
/**
|
||||
* A helper app launcher is a small object created to handle the launching
|
||||
* of an external application.
|
||||
*/
|
||||
[scriptable, uuid(9503D0FE-4C9D-11d4-98D0-001083010E9B)]
|
||||
interface nsIHelperAppLauncher : nsISupports
|
||||
{
|
||||
// the mime info object associated with the content type this helper app launcher is currently
|
||||
// attempting to load
|
||||
/**
|
||||
* The mime info object associated with the content type this helper app
|
||||
* launcher is currently attempting to load
|
||||
*/
|
||||
readonly attribute nsIMIMEInfo MIMEInfo;
|
||||
|
||||
// the source url
|
||||
/**
|
||||
* The source uri
|
||||
*/
|
||||
readonly attribute nsIURI source;
|
||||
|
||||
/**
|
||||
* The suggested name for this file
|
||||
*/
|
||||
readonly attribute wstring suggestedFileName;
|
||||
|
||||
// saveToDisk: called when we want to just save the content to a particular file
|
||||
// aNewFileLocation --> location where the content should be saved
|
||||
/**
|
||||
* Called when we want to just save the content to a particular file
|
||||
* @param aNewFileLocation Location where the content should be saved
|
||||
*/
|
||||
void saveToDisk(in nsIFile aNewFileLocation, in boolean aRememberThisPreference);
|
||||
|
||||
// launchWithApplication: use aApplication to launch with this content
|
||||
// aApplication --> nsIFile corresponding to the location of the application to use
|
||||
// aRememberThisPreference --> TRUE if we should remember this choice.
|
||||
/**
|
||||
* Use aApplication to launch with this content.
|
||||
* @param aApplication nsIFile corresponding to the location of the application to use.
|
||||
* @param aRememberThisPreference TRUE if we should remember this choice.
|
||||
*/
|
||||
void launchWithApplication(in nsIFile aApplication, in boolean aRememberThisPreference);
|
||||
|
||||
// called if the user decides to cancel the handling of this content type
|
||||
/**
|
||||
* Called if the user decides to cancel the handling of this content type
|
||||
*/
|
||||
void Cancel();
|
||||
|
||||
// the following methods are used by the progress dialog to get or set information
|
||||
// on the current helper app launcher download
|
||||
/**
|
||||
* the following methods are used by the progress dialog to get or set
|
||||
* information on the current helper app launcher download.
|
||||
*/
|
||||
void setWebProgressListener(in nsIWebProgressListener aWebProgressListener);
|
||||
// when the stand along progress window actually closes, it calls this method
|
||||
// so we can release any local state...
|
||||
/**
|
||||
* when the stand along progress window actually closes, it calls this method
|
||||
* so we can release any local state...
|
||||
*/
|
||||
void closeProgressWindow();
|
||||
|
||||
// aSourceUrl--> the url we are downloading....and the file we are saving too
|
||||
// aTimeDownloadStarted --> time in ms that the download actually began
|
||||
nsIFile getDownloadInfo(out nsIURI aSourceUrl, out long long aTimeDownloadStarted);
|
||||
|
||||
/**
|
||||
* The file we are saving to
|
||||
*/
|
||||
readonly attribute nsIFile targetFile;
|
||||
/**
|
||||
* Time when the download started
|
||||
*/
|
||||
readonly attribute PRTime timeDownloadStarted;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче