Bug 591081 - Keep using nsExternalAppHandler in the child process after forwarding download request, r=dwitte, a=blocking-fennec2.0b1

This commit is contained in:
Brian Crowder 2010-09-13 11:37:00 -07:00
Родитель bec0f06b6f
Коммит f0be8f4dd4
2 изменённых файлов: 32 добавлений и 31 удалений

Просмотреть файл

@ -89,8 +89,9 @@ ExternalHelperAppChild::OnDataAvailable(nsIRequest *request,
NS_IMETHODIMP
ExternalHelperAppChild::OnStartRequest(nsIRequest *request, nsISupports *ctx)
{
// FIXME: Eventually we should implement this:
// mHandler->OnStartRequest(request, ctx);
nsresult rv = mHandler->OnStartRequest(request, ctx);
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
nsCString entityID;
nsCOMPtr<nsIResumableChannel> resumable(do_QueryInterface(request));
if (resumable)
@ -105,9 +106,10 @@ ExternalHelperAppChild::OnStopRequest(nsIRequest *request,
nsISupports *ctx,
nsresult status)
{
// FIXME: Eventually we should implement this:
// mHandler->OnStopRequest(request, ctx, status);
nsresult rv = mHandler->OnStopRequest(request, ctx, status);
SendOnStopRequest(status);
NS_ENSURE_SUCCESS(rv, NS_ERROR_UNEXPECTED);
return NS_OK;
}

Просмотреть файл

@ -719,18 +719,13 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
NS_ADDREF(*aStreamListener = childListener);
// FIXME: Eventually we'll use this original listener to finish up client-side
// work, such as closing a no-longer-needed window. (Bug 588255)
// nsExternalAppHandler * handler = new nsExternalAppHandler(nsnull,
// EmptyCString(),
// aWindowContext,
// fileName,
// reason,
// aForceSave);
// if (!handler)
// return NS_ERROR_OUT_OF_MEMORY;
//
// childListener->SetHandler(handler);
nsRefPtr<nsExternalAppHandler> handler =
new nsExternalAppHandler(nsnull, EmptyCString(), aWindowContext, fileName,
reason, aForceSave);
if (!handler)
return NS_ERROR_OUT_OF_MEMORY;
childListener->SetHandler(handler);
return NS_OK;
}
@ -1578,21 +1573,6 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
aChannel->GetURI(getter_AddRefs(mSourceUrl));
}
rv = SetUpTempFile(aChannel);
if (NS_FAILED(rv)) {
mCanceled = PR_TRUE;
request->Cancel(rv);
nsAutoString path;
if (mTempFile)
mTempFile->GetPath(path);
SendStatusChange(kWriteError, rv, request, path);
return NS_OK;
}
// Extract mime type for later use below.
nsCAutoString MIMEType;
mMimeInfo->GetMIMEType(MIMEType);
// retarget all load notifications to our docloader instead of the original window's docloader...
RetargetLoadNotifications(request);
@ -1613,6 +1593,22 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
// and it was opened specifically for the download
MaybeCloseWindow();
// At this point, the child process has done everything it can usefully do
// for OnStartRequest.
if (XRE_GetProcessType() == GeckoProcessType_Content)
return NS_OK;
rv = SetUpTempFile(aChannel);
if (NS_FAILED(rv)) {
mCanceled = PR_TRUE;
request->Cancel(rv);
nsAutoString path;
if (mTempFile)
mTempFile->GetPath(path);
SendStatusChange(kWriteError, rv, request, path);
return NS_OK;
}
nsCOMPtr<nsIEncodedChannel> encChannel = do_QueryInterface( aChannel );
if (encChannel)
{
@ -1687,6 +1683,9 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
handlerSvc->Exists(mMimeInfo, &mimeTypeIsInDatastore);
if (!handlerSvc || !mimeTypeIsInDatastore)
{
nsCAutoString MIMEType;
mMimeInfo->GetMIMEType(MIMEType);
if (!GetNeverAskFlagFromPref(NEVER_ASK_FOR_SAVE_TO_DISK_PREF, MIMEType.get()))
{
// Don't need to ask after all.