Bug 1780741 - Add init checks to ExternalHelperAppParent. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D152633
This commit is contained in:
Christian Holler 2022-07-29 13:47:22 +00:00
Родитель c737ca4ccc
Коммит caf94dc5d4
3 изменённых файлов: 17 добавлений и 6 удалений

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

@ -4426,9 +4426,11 @@ mozilla::ipc::IPCResult ContentParent::RecvPExternalHelperAppConstructor(
nsIURI* aReferrer, const MaybeDiscarded<BrowsingContext>& aContext,
const bool& aShouldCloseWindow) {
BrowsingContext* context = aContext.IsDiscarded() ? nullptr : aContext.get();
static_cast<ExternalHelperAppParent*>(actor)->Init(
loadInfoArgs, aMimeContentType, aForceSave, aReferrer, context,
aShouldCloseWindow);
if (!static_cast<ExternalHelperAppParent*>(actor)->Init(
loadInfoArgs, aMimeContentType, aForceSave, aReferrer, context,
aShouldCloseWindow)) {
return IPC_FAIL(this, "Init failed.");
}
return IPC_OK();
}

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

@ -58,13 +58,16 @@ ExternalHelperAppParent::ExternalHelperAppParent(
}
}
void ExternalHelperAppParent::Init(
bool ExternalHelperAppParent::Init(
const Maybe<mozilla::net::LoadInfoArgs>& aLoadInfoArgs,
const nsACString& aMimeContentType, const bool& aForceSave,
nsIURI* aReferrer, BrowsingContext* aContext,
const bool& aShouldCloseWindow) {
mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs,
nsresult rv = mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs,
getter_AddRefs(mLoadInfo));
if (NS_FAILED(rv)) {
return false;
}
nsCOMPtr<nsIExternalHelperAppService> helperAppService =
do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
@ -90,12 +93,18 @@ void ExternalHelperAppParent::Init(
helperAppService->CreateListener(aMimeContentType, this, aContext, aForceSave,
nullptr, getter_AddRefs(mListener));
if (!mListener) {
return false;
}
if (aShouldCloseWindow) {
RefPtr<nsExternalAppHandler> handler = do_QueryObject(mListener);
if (handler) {
handler->SetShouldCloseWindow();
}
}
return true;
}
void ExternalHelperAppParent::ActorDestroy(ActorDestroyReason why) {

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

@ -85,7 +85,7 @@ class ExternalHelperAppParent
const nsACString& aContentDispositionHeader,
const uint32_t& aContentDispositionHint,
const nsAString& aContentDispositionFilename);
void Init(const Maybe<mozilla::net::LoadInfoArgs>& aLoadInfoArgs,
bool Init(const Maybe<mozilla::net::LoadInfoArgs>& aLoadInfoArgs,
const nsACString& aMimeContentType, const bool& aForceSave,
nsIURI* aReferrer, BrowsingContext* aContext,
const bool& aShouldCloseWindow);