Bug 910436 - Electrolysis: Pass PBrowser to the PExternalHelperAppParent so that we can get a window for the download box. r=jdm

This commit is contained in:
Tom Schuster 2013-09-12 15:24:10 -04:00
Родитель f29d9f5c20
Коммит 5de50e9d38
8 изменённых файлов: 29 добавлений и 10 удалений

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

@ -868,7 +868,8 @@ ContentChild::AllocPExternalHelperAppChild(const OptionalURIParams& uri,
const nsCString& aContentDisposition,
const bool& aForceSave,
const int64_t& aContentLength,
const OptionalURIParams& aReferrer)
const OptionalURIParams& aReferrer,
PBrowserChild* aBrowser)
{
ExternalHelperAppChild *child = new ExternalHelperAppChild();
child->AddRef();

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

@ -146,7 +146,8 @@ public:
const nsCString& aContentDisposition,
const bool& aForceSave,
const int64_t& aContentLength,
const OptionalURIParams& aReferrer);
const OptionalURIParams& aReferrer,
PBrowserChild* aBrowser);
virtual bool DeallocPExternalHelperAppChild(PExternalHelperAppChild *aService);
virtual PSmsChild* AllocPSmsChild();

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

@ -2235,11 +2235,12 @@ ContentParent::AllocPExternalHelperAppParent(const OptionalURIParams& uri,
const nsCString& aContentDisposition,
const bool& aForceSave,
const int64_t& aContentLength,
const OptionalURIParams& aReferrer)
const OptionalURIParams& aReferrer,
PBrowserParent* aBrowser)
{
ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
parent->AddRef();
parent->Init(this, aMimeContentType, aContentDisposition, aForceSave, aReferrer);
parent->Init(this, aMimeContentType, aContentDisposition, aForceSave, aReferrer, aBrowser);
return parent;
}

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

@ -316,7 +316,8 @@ private:
const nsCString& aContentDisposition,
const bool& aForceSave,
const int64_t& aContentLength,
const OptionalURIParams& aReferrer);
const OptionalURIParams& aReferrer,
PBrowserParent* aBrowser);
virtual bool DeallocPExternalHelperAppParent(PExternalHelperAppParent* aService);
virtual PSmsParent* AllocPSmsParent();

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

@ -397,7 +397,8 @@ parent:
PExternalHelperApp(OptionalURIParams uri, nsCString aMimeContentType,
nsCString aContentDisposition, bool aForceSave,
int64_t aContentLength, OptionalURIParams aReferrer);
int64_t aContentLength, OptionalURIParams aReferrer,
nullable PBrowser aBrowser);
AddGeolocationListener(Principal principal, bool highAccuracy);
RemoveGeolocationListener();

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

@ -11,6 +11,8 @@
#include "nsCExternalHandlerService.h"
#include "nsIExternalHelperAppService.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TabParent.h"
#include "nsIBrowserDOMWindow.h"
#include "nsStringStream.h"
#include "mozilla/ipc/URIUtils.h"
@ -45,7 +47,8 @@ ExternalHelperAppParent::Init(ContentParent *parent,
const nsCString& aMimeContentType,
const nsCString& aContentDispositionHeader,
const bool& aForceSave,
const OptionalURIParams& aReferrer)
const OptionalURIParams& aReferrer,
PBrowserParent* aBrowser)
{
nsCOMPtr<nsIExternalHelperAppService> helperAppService =
do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
@ -58,7 +61,15 @@ ExternalHelperAppParent::Init(ContentParent *parent,
mContentDispositionHeader = aContentDispositionHeader;
NS_GetFilenameFromDisposition(mContentDispositionFilename, mContentDispositionHeader, mURI);
mContentDisposition = NS_GetContentDispositionFromHeader(mContentDispositionHeader, this);
helperAppService->DoContent(aMimeContentType, this, nullptr,
nsCOMPtr<nsIInterfaceRequestor> window;
if (aBrowser) {
TabParent* tabParent = static_cast<TabParent*>(aBrowser);
if (tabParent->GetOwnerElement())
window = do_QueryInterface(tabParent->GetOwnerElement()->OwnerDoc()->GetWindow());
}
helperAppService->DoContent(aMimeContentType, this, window,
aForceSave, getter_AddRefs(mListener));
}

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

@ -23,6 +23,7 @@ class OptionalURIParams;
namespace dom {
class ContentParent;
class PBrowserParent;
class ExternalHelperAppParent : public PExternalHelperAppParent
, public nsHashPropertyBag
@ -48,7 +49,8 @@ public:
const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const bool& aForceSave,
const OptionalURIParams& aReferrer);
const OptionalURIParams& aReferrer,
PBrowserParent* aBrowser);
virtual ~ExternalHelperAppParent();
private:

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

@ -613,7 +613,8 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
child->SendPExternalHelperAppConstructor(uriParams,
nsCString(aMimeContentType),
disp, aForceSave, contentLength,
referrerParams);
referrerParams,
mozilla::dom::TabChild::GetFrom(window));
ExternalHelperAppChild *childListener = static_cast<ExternalHelperAppChild *>(pc);
NS_ADDREF(*aStreamListener = childListener);