diff --git a/uriloader/exthandler/ExternalHelperAppChild.cpp b/uriloader/exthandler/ExternalHelperAppChild.cpp index 47670c034e5..10f7e2006bd 100644 --- a/uriloader/exthandler/ExternalHelperAppChild.cpp +++ b/uriloader/exthandler/ExternalHelperAppChild.cpp @@ -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 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; } diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 156b3d11adb..12d1b0ad093 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -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 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 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.