diff --git a/mobile/android/components/geckoview/GeckoViewExternalAppService.cpp b/mobile/android/components/geckoview/GeckoViewExternalAppService.cpp index 30dedc9251ca..ffabd6ef2a19 100644 --- a/mobile/android/components/geckoview/GeckoViewExternalAppService.cpp +++ b/mobile/android/components/geckoview/GeckoViewExternalAppService.cpp @@ -53,7 +53,7 @@ GeckoViewExternalAppService::GeckoViewExternalAppService() {} NS_IMPL_ISUPPORTS(GeckoViewExternalAppService, nsIExternalHelperAppService); NS_IMETHODIMP GeckoViewExternalAppService::DoContent( - const nsACString& aMimeContentType, nsIRequest* aRequest, + const nsACString& aMimeContentType, nsIChannel* aChannel, nsIInterfaceRequestor* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener) { @@ -61,17 +61,14 @@ NS_IMETHODIMP GeckoViewExternalAppService::DoContent( } NS_IMETHODIMP GeckoViewExternalAppService::CreateListener( - const nsACString& aMimeContentType, nsIRequest* aRequest, + const nsACString& aMimeContentType, nsIChannel* aChannel, mozilla::dom::BrowsingContext* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener) { using namespace mozilla; using namespace mozilla::dom; MOZ_ASSERT(XRE_IsParentProcess()); - - nsresult rv; - nsCOMPtr channel(do_QueryInterface(aRequest, &rv)); - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_ARG_POINTER(aChannel); nsCOMPtr widget = aContentContext->Canonical()->GetParentProcessWidgetContaining(); @@ -84,7 +81,8 @@ NS_IMETHODIMP GeckoViewExternalAppService::CreateListener( RefPtr listener = new StreamListener(window); - rv = channel->SetNotificationCallbacks(listener); + nsresult rv; + rv = aChannel->SetNotificationCallbacks(listener); NS_ENSURE_SUCCESS(rv, rv); listener.forget(aStreamListener); diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 1a4782616250..0c483b3c6e51 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -636,10 +636,12 @@ nsresult nsExternalHelperAppService::Init() { nsExternalHelperAppService::~nsExternalHelperAppService() {} nsresult nsExternalHelperAppService::DoContentContentProcessHelper( - const nsACString& aMimeContentType, nsIRequest* aRequest, + const nsACString& aMimeContentType, nsIChannel* aChannel, BrowsingContext* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener) { + NS_ENSURE_ARG_POINTER(aChannel); + // We need to get a hold of a ContentChild so that we can begin forwarding // this data to the parent. In the HTTP case, this is unfortunate, since // we're actually passing data from parent->child->parent wastefully, but @@ -660,26 +662,23 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper( nsAutoString fileName; nsCOMPtr loadInfo; - nsCOMPtr channel = do_QueryInterface(aRequest); - if (channel) { - channel->GetURI(getter_AddRefs(uri)); - channel->GetContentLength(&contentLength); - channel->GetContentDisposition(&contentDisposition); - channel->GetContentDispositionFilename(fileName); - channel->GetContentDispositionHeader(disp); - loadInfo = channel->LoadInfo(); + aChannel->GetURI(getter_AddRefs(uri)); + aChannel->GetContentLength(&contentLength); + aChannel->GetContentDisposition(&contentDisposition); + aChannel->GetContentDispositionFilename(fileName); + aChannel->GetContentDispositionHeader(disp); + loadInfo = aChannel->LoadInfo(); - nsCOMPtr fileChan(do_QueryInterface(aRequest)); - wasFileChannel = fileChan != nullptr; - } + nsCOMPtr fileChan(do_QueryInterface(aChannel)); + wasFileChannel = fileChan != nullptr; nsCOMPtr referrer; - NS_GetReferrerFromChannel(channel, getter_AddRefs(referrer)); + NS_GetReferrerFromChannel(aChannel, getter_AddRefs(referrer)); mozilla::net::LoadInfoArgs loadInfoArgs; MOZ_ALWAYS_SUCCEEDS(LoadInfoToLoadInfoArgs(loadInfo, &loadInfoArgs)); - nsCOMPtr props(do_QueryInterface(aRequest)); + nsCOMPtr props(do_QueryInterface(aChannel)); // Determine whether a new window was opened specifically for this request bool shouldCloseWindow = false; if (props) { @@ -715,23 +714,21 @@ nsresult nsExternalHelperAppService::DoContentContentProcessHelper( } NS_IMETHODIMP nsExternalHelperAppService::CreateListener( - const nsACString& aMimeContentType, nsIRequest* aRequest, + const nsACString& aMimeContentType, nsIChannel* aChannel, BrowsingContext* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener) { MOZ_ASSERT(!XRE_IsContentProcess()); + NS_ENSURE_ARG_POINTER(aChannel); nsAutoString fileName; nsAutoCString fileExtension; uint32_t reason = nsIHelperAppLauncherDialog::REASON_CANTHANDLE; - nsCOMPtr channel = do_QueryInterface(aRequest); - if (channel) { - uint32_t contentDisposition = -1; - channel->GetContentDisposition(&contentDisposition); - if (contentDisposition == nsIChannel::DISPOSITION_ATTACHMENT) { - reason = nsIHelperAppLauncherDialog::REASON_SERVERREQUEST; - } + uint32_t contentDisposition = -1; + aChannel->GetContentDisposition(&contentDisposition); + if (contentDisposition == nsIChannel::DISPOSITION_ATTACHMENT) { + reason = nsIHelperAppLauncherDialog::REASON_SERVERREQUEST; } *aStreamListener = nullptr; @@ -739,7 +736,7 @@ NS_IMETHODIMP nsExternalHelperAppService::CreateListener( // Get the file extension and name that we will need later nsCOMPtr uri; bool allowURLExtension = - GetFileNameFromChannel(channel, fileName, getter_AddRefs(uri)); + GetFileNameFromChannel(aChannel, fileName, getter_AddRefs(uri)); uint32_t flags = VALIDATE_ALLOW_EMPTY; if (aMimeContentType.Equals(APPLICATION_GUESS_FROM_EXT, @@ -758,12 +755,10 @@ NS_IMETHODIMP nsExternalHelperAppService::CreateListener( } if (flags & VALIDATE_GUESS_FROM_EXTENSION) { - if (channel) { - // Replace the content type with what was guessed. - nsAutoCString mimeType; - mimeInfo->GetMIMEType(mimeType); - channel->SetContentType(mimeType); - } + // Replace the content type with what was guessed. + nsAutoCString mimeType; + mimeInfo->GetMIMEType(mimeType); + aChannel->SetContentType(mimeType); if (reason == nsIHelperAppLauncherDialog::REASON_CANTHANDLE) { reason = nsIHelperAppLauncherDialog::REASON_TYPESNIFFED; @@ -790,7 +785,7 @@ NS_IMETHODIMP nsExternalHelperAppService::CreateListener( } NS_IMETHODIMP nsExternalHelperAppService::DoContent( - const nsACString& aMimeContentType, nsIRequest* aRequest, + const nsACString& aMimeContentType, nsIChannel* aChannel, nsIInterfaceRequestor* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener) { @@ -809,12 +804,12 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent( } if (XRE_IsContentProcess()) { - return DoContentContentProcessHelper(aMimeContentType, aRequest, bc, + return DoContentContentProcessHelper(aMimeContentType, aChannel, bc, aForceSave, aWindowContext, aStreamListener); } - nsresult rv = CreateListener(aMimeContentType, aRequest, bc, aForceSave, + nsresult rv = CreateListener(aMimeContentType, aChannel, bc, aForceSave, aWindowContext, aStreamListener); return rv; } diff --git a/uriloader/exthandler/nsExternalHelperAppService.h b/uriloader/exthandler/nsExternalHelperAppService.h index 6c8cbc5871d3..bc532573c3bd 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.h +++ b/uriloader/exthandler/nsExternalHelperAppService.h @@ -253,7 +253,7 @@ class nsExternalHelperAppService : public nsIExternalHelperAppService, private: nsresult DoContentContentProcessHelper( - const nsACString& aMimeContentType, nsIRequest* aRequest, + const nsACString& aMimeContentType, nsIChannel* aChannel, mozilla::dom::BrowsingContext* aContentContext, bool aForceSave, nsIInterfaceRequestor* aWindowContext, nsIStreamListener** aStreamListener); diff --git a/uriloader/exthandler/nsIExternalHelperAppService.idl b/uriloader/exthandler/nsIExternalHelperAppService.idl index 307e6196a89d..4a399acb72d4 100644 --- a/uriloader/exthandler/nsIExternalHelperAppService.idl +++ b/uriloader/exthandler/nsIExternalHelperAppService.idl @@ -7,7 +7,7 @@ #include "nsICancelable.idl" interface nsIURI; -interface nsIRequest; +interface nsIChannel; interface nsIStreamListener; interface nsIFile; interface nsIMIMEInfo; @@ -28,7 +28,7 @@ interface nsIExternalHelperAppService : nsISupports * 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 aChannel The channel corresponding to the incoming data * @param aContentContext Used in processing content document refresh * headers after target content is downloaded. * @param aForceSave True to always save this content to disk, regardless of @@ -39,7 +39,7 @@ interface nsIExternalHelperAppService : nsISupports * @return A nsIStreamListener which the caller should pump the data into. */ nsIStreamListener doContent (in ACString aMimeContentType, - in nsIRequest aRequest, + in nsIChannel aChannel, in nsIInterfaceRequestor aContentContext, in boolean aForceSave, [optional] in nsIInterfaceRequestor aWindowContext); @@ -52,8 +52,8 @@ interface nsIExternalHelperAppService : nsISupports * Replaces doContent for native code, and uses BrowsingContext. * * @param aMimeContentType The content type of the incoming data - * @param aRequest The request corresponding to the incoming data - * @param aContentContext The BrowsingContext that the request was initiated + * @param aChannel The channel corresponding to the incoming data + * @param aContentContext The BrowsingContext that the channel was initiated * by. Used for closing the window if we opened one specifically for this download. * @param aForceSave True to always save this content to disk, regardless of * nsIMIMEInfo and other such influences. @@ -63,7 +63,7 @@ interface nsIExternalHelperAppService : nsISupports * @return A nsIStreamListener which the caller should pump the data into. */ nsIStreamListener createListener (in ACString aMimeContentType, - in nsIRequest aRequest, + in nsIChannel aChannel, in BrowsingContext aContentContext, in boolean aForceSave, [optional] in nsIInterfaceRequestor aWindowContext);