Bug 567267 - move management of ExternalHelperApp protocols to PContent, r=dwitte, blocking-fennec2.0b1=mfinkle
authorBrian Crowder <crowderbt@gmail.com>
Wed, 15 Sep 2010 15:55:08 -0700
changeset 53991 a43db79e3dc1fb3a39f412b7f4fb720dc3f79bc1
parent 53990 d2fab7a7cc4f7dab101c76cd15d9b863d5ba8265
child 53992 10257eea753356217a6107f1a43b38ffd89f795e
push id15762
push userbcrowder@mozilla.com
push dateWed, 15 Sep 2010 22:53:01 +0000
treeherdermozilla-central@10257eea7533 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwitte
bugs567267
milestone2.0b7pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 567267 - move management of ExternalHelperApp protocols to PContent, r=dwitte, blocking-fennec2.0b1=mfinkle
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PBrowser.ipdl
dom/ipc/PContent.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
testing/xpcshell/head.js
uriloader/exthandler/ExternalHelperAppParent.cpp
uriloader/exthandler/ExternalHelperAppParent.h
uriloader/exthandler/PExternalHelperApp.ipdl
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -39,16 +39,17 @@
 
 #include "ContentChild.h"
 #include "TabChild.h"
 
 #include "mozilla/ipc/TestShellChild.h"
 #include "mozilla/net/NeckoChild.h"
 #include "mozilla/ipc/XPCShellEnvironment.h"
 #include "mozilla/jsipc/PContextWrapperChild.h"
+#include "mozilla/dom/ExternalHelperAppChild.h"
 
 #include "nsIObserverService.h"
 #include "nsTObserverArray.h"
 #include "nsIObserver.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsServiceManagerUtils.h"
 #include "nsXULAppAPI.h"
@@ -279,16 +280,36 @@ ContentChild::AllocPNecko()
 
 bool 
 ContentChild::DeallocPNecko(PNeckoChild* necko)
 {
     delete necko;
     return true;
 }
 
+PExternalHelperAppChild*
+ContentChild::AllocPExternalHelperApp(const IPC::URI& uri,
+                                      const nsCString& aMimeContentType,
+                                      const nsCString& aContentDisposition,
+                                      const bool& aForceSave,
+                                      const PRInt64& aContentLength)
+{
+    ExternalHelperAppChild *child = new ExternalHelperAppChild();
+    child->AddRef();
+    return child;
+}
+
+bool
+ContentChild::DeallocPExternalHelperApp(PExternalHelperAppChild* aService)
+{
+    ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
+    child->Release();
+    return true;
+}
+
 bool
 ContentChild::RecvRegisterChrome(const nsTArray<ChromePackage>& packages,
                                  const nsTArray<ResourceMapping>& resources,
                                  const nsTArray<OverrideMapping>& overrides)
 {
     nsCOMPtr<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
     nsChromeRegistryContent* chromeRegistry =
         static_cast<nsChromeRegistryContent*>(registrySvc.get());
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -78,16 +78,24 @@ public:
 
     virtual PTestShellChild* AllocPTestShell();
     virtual bool DeallocPTestShell(PTestShellChild*);
     virtual bool RecvPTestShellConstructor(PTestShellChild*);
 
     virtual PNeckoChild* AllocPNecko();
     virtual bool DeallocPNecko(PNeckoChild*);
 
+    virtual PExternalHelperAppChild *AllocPExternalHelperApp(
+            const IPC::URI& uri,
+            const nsCString& aMimeContentType,
+            const nsCString& aContentDisposition,
+            const bool& aForceSave,
+            const PRInt64& aContentLength);
+    virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService);
+
     virtual bool RecvRegisterChrome(const nsTArray<ChromePackage>& packages,
                                     const nsTArray<ResourceMapping>& resources,
                                     const nsTArray<OverrideMapping>& overrides);
 
     virtual bool RecvSetOffline(const PRBool& offline);
 
     virtual bool RecvNotifyVisited(const IPC::URI& aURI);
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -54,16 +54,18 @@
 #include "nsThreadUtils.h"
 #include "nsChromeRegistryChrome.h"
 #include "nsExternalHelperAppService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsFrameMessageManager.h"
 #include "nsIAlertsService.h"
 #include "nsToolkitCompsCID.h"
 
+#include "mozilla/dom/ExternalHelperAppParent.h"
+
 #ifdef ANDROID
 #include "AndroidBridge.h"
 using namespace mozilla;
 #endif
 
 using namespace mozilla::ipc;
 using namespace mozilla::net;
 using namespace mozilla::places;
@@ -418,16 +420,37 @@ ContentParent::AllocPNecko()
 
 bool 
 ContentParent::DeallocPNecko(PNeckoParent* necko)
 {
     delete necko;
     return true;
 }
 
+PExternalHelperAppParent*
+ContentParent::AllocPExternalHelperApp(const IPC::URI& uri,
+                                       const nsCString& aMimeContentType,
+                                       const nsCString& aContentDisposition,
+                                       const bool& aForceSave,
+                                       const PRInt64& aContentLength)
+{
+    ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
+    parent->AddRef();
+    parent->Init(this, aMimeContentType, aContentDisposition, aForceSave);
+    return parent;
+}
+
+bool
+ContentParent::DeallocPExternalHelperApp(PExternalHelperAppParent* aService)
+{
+    ExternalHelperAppParent *parent = static_cast<ExternalHelperAppParent *>(aService);
+    parent->Release();
+    return true;
+}
+
 void
 ContentParent::ReportChildAlreadyBlocked()
 {
     if (!mRunToCompletionDepth) {
 #ifdef DEBUG
         printf("Running to completion...\n");
 #endif
         mRunToCompletionDepth = 1;
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -109,16 +109,24 @@ private:
     virtual bool DeallocPBrowser(PBrowserParent* frame);
 
     virtual PTestShellParent* AllocPTestShell();
     virtual bool DeallocPTestShell(PTestShellParent* shell);
 
     virtual PNeckoParent* AllocPNecko();
     virtual bool DeallocPNecko(PNeckoParent* necko);
 
+    virtual PExternalHelperAppParent* AllocPExternalHelperApp(
+            const IPC::URI& uri,
+            const nsCString& aMimeContentType,
+            const nsCString& aContentDisposition,
+            const bool& aForceSave,
+            const PRInt64& aContentLength);
+    virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);
+
     virtual bool RecvGetPrefType(const nsCString& prefName,
             PRInt32* retValue, nsresult* rv);
 
     virtual bool RecvGetBoolPref(const nsCString& prefName,
             PRBool* retValue, nsresult* rv);
 
     virtual bool RecvGetIntPref(const nsCString& prefName,
             PRInt32* retValue, nsresult* rv);
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -38,17 +38,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PContent;
 include protocol PContentDialog;
 include protocol PDocumentRenderer;
 include protocol PDocumentRendererShmem;
 include protocol PDocumentRendererNativeID;
 include protocol PContentPermissionRequest;
-include protocol PExternalHelperApp;
 
 include "mozilla/TabTypes.h";
 include "TabMessageUtils.h";
 include "gfxMatrix.h";
 include "mozilla/net/NeckoMessageUtils.h";
 include "IPC/nsGUIEventIPC.h";
 
 using IPC::URI;
@@ -67,17 +66,16 @@ rpc protocol PBrowser
 {
     manager PContent;
 
     manages PContentDialog;
     manages PDocumentRenderer;
     manages PDocumentRendererShmem;
     manages PDocumentRendererNativeID;
     manages PContentPermissionRequest;
-    manages PExternalHelperApp;
 
 both:
     AsyncMessage(nsString aMessage, nsString aJSON);
 
 parent:
     /**
      * When child sends this message, parent should move focus to
      * the next or previous focusable element.
@@ -116,20 +114,16 @@ parent:
 
     PContentPermissionRequest(nsCString aType, URI uri);
 
     PContentDialog(PRUint32 aType, nsCString aName, nsCString aFeatures,
                    PRInt32[] aIntParams, nsString[] aStringParams);
 
     __delete__();
 
-    PExternalHelperApp(URI uri, nsCString aMimeContentType,
-                       nsCString aContentDisposition, bool aForceSave,
-                       PRInt64 aContentLength);
-
 child:
     CreateWidget(MagicWindowHandle parentWidget);
 
     LoadURL(nsCString uri);
 
     Move(PRUint32 x,
          PRUint32 y,
          PRUint32 width,
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -34,16 +34,17 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PBrowser;
 include protocol PTestShell;
 include protocol PNecko;
+include protocol PExternalHelperApp;
 
 include "mozilla/TabTypes.h";
 include "mozilla/chrome/RegistryMessageUtils.h";
 include "mozilla/net/NeckoMessageUtils.h";
 
 using ChromePackage;
 using ResourceMapping;
 using OverrideMapping;
@@ -52,16 +53,17 @@ using IPC::URI;
 namespace mozilla {
 namespace dom {
 
 rpc protocol PContent
 {
     manages PBrowser;
     manages PTestShell;
     manages PNecko;
+    manages PExternalHelperApp;
 
 child:
     PBrowser(PRUint32 chromeFlags);
 
     PTestShell();
 
     RegisterChrome(ChromePackage[] packages, ResourceMapping[] resources,
                    OverrideMapping[] overrides);
@@ -106,15 +108,19 @@ parent:
 
     ShowAlertNotification(nsString imageUrl, 
                           nsString title, 
                           nsString text, 
                           PRBool textClickable,
                           nsString cookie,
                           nsString name);
 
+    PExternalHelperApp(URI uri, nsCString aMimeContentType,
+                       nsCString aContentDisposition, bool aForceSave,
+                       PRInt64 aContentLength);
+
 both:
      AsyncMessage(nsString aMessage, nsString aJSON);
 
 };
 
 }
 }
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -49,17 +49,16 @@
 #include "nsIWebProgress.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsThreadUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "mozilla/ipc/DocumentRendererChild.h"
 #include "mozilla/ipc/DocumentRendererShmemChild.h"
 #include "mozilla/ipc/DocumentRendererNativeIDChild.h"
-#include "mozilla/dom/ExternalHelperAppChild.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsISupportsImpl.h"
 #include "nsIURI.h"
 #include "nsIWebBrowserFocus.h"
 #include "nsIDOMEvent.h"
 #include "nsIPrivateDOMEvent.h"
@@ -1233,29 +1232,8 @@ TabChildGlobal::GetJSContextForEventHand
 nsIPrincipal* 
 TabChildGlobal::GetPrincipal()
 {
   if (!mTabChild)
     return nsnull;
   return mTabChild->GetPrincipal();
 }
 
-PExternalHelperAppChild*
-TabChild::AllocPExternalHelperApp(const IPC::URI& uri,
-                                  const nsCString& aMimeContentType,
-                                  const nsCString& aContentDisposition,
-                                  const bool& aForceSave,
-                                  const PRInt64& aContentLength)
-{
-  ExternalHelperAppChild *child = new ExternalHelperAppChild();
-  child->AddRef();
-  return child;
-}
-
-bool
-TabChild::DeallocPExternalHelperApp(PExternalHelperAppChild* aService)
-{
-  ExternalHelperAppChild *child = static_cast<ExternalHelperAppChild*>(aService);
-  child->Release();
-  return true;
-}
-
-
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -219,23 +219,16 @@ public:
             const PRUint32& flags,
             const bool& flush);
     virtual PContentDialogChild* AllocPContentDialog(const PRUint32&,
                                                      const nsCString&,
                                                      const nsCString&,
                                                      const nsTArray<int>&,
                                                      const nsTArray<nsString>&);
     virtual bool DeallocPContentDialog(PContentDialogChild* aDialog);
-    virtual PExternalHelperAppChild *AllocPExternalHelperApp(
-            const IPC::URI& uri,
-            const nsCString& aMimeContentType,
-            const nsCString& aContentDisposition,
-            const bool& aForceSave,
-            const PRInt64& aContentLength);
-    virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService);
     static void ParamsToArrays(nsIDialogParamBlock* aParams,
                                nsTArray<int>& aIntParams,
                                nsTArray<nsString>& aStringParams);
     static void ArraysToParams(const nsTArray<int>& aIntParams,
                                const nsTArray<nsString>& aStringParams,
                                nsIDialogParamBlock* aParams);
 
     virtual PDocumentRendererShmemChild* AllocPDocumentRendererShmem(
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -31,17 +31,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "mozilla/dom/ExternalHelperAppParent.h"
 #include "TabParent.h"
 
 #include "mozilla/ipc/DocumentRendererParent.h"
 #include "mozilla/ipc/DocumentRendererShmemParent.h"
 #include "mozilla/ipc/DocumentRendererNativeIDParent.h"
 #include "mozilla/dom/ContentParent.h"
 
 #include "nsIURI.h"
@@ -803,31 +802,10 @@ TabParent::ShouldDelayDialogs()
 
 already_AddRefed<nsFrameLoader>
 TabParent::GetFrameLoader() const
 {
   nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(mFrameElement);
   return frameLoaderOwner ? frameLoaderOwner->GetFrameLoader() : nsnull;
 }
 
-PExternalHelperAppParent*
-TabParent::AllocPExternalHelperApp(const IPC::URI& uri,
-                                   const nsCString& aMimeContentType,
-                                   const nsCString& aContentDisposition,
-                                   const bool& aForceSave,
-                                   const PRInt64& aContentLength)
-{
-  ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
-  parent->AddRef();
-  parent->Init(this, aMimeContentType, aContentDisposition, aForceSave);
-  return parent;
-}
-
-bool
-TabParent::DeallocPExternalHelperApp(PExternalHelperAppParent* aService)
-{
-  ExternalHelperAppParent *parent = static_cast<ExternalHelperAppParent *>(aService);
-  parent->Release();
-  return true;
-}
-
 } // namespace tabs
 } // namespace mozilla
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -37,17 +37,16 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_tabs_TabParent_h
 #define mozilla_tabs_TabParent_h
 
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/PContentDialogParent.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
-#include "mozilla/dom/PExternalHelperApp.h"
 
 #include "jsapi.h"
 #include "nsCOMPtr.h"
 #include "nsITabParent.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIWebProgress.h"
 #include "nsIWebProgressListener.h"
 #include "nsWeakReference.h"
@@ -142,24 +141,16 @@ public:
                                                       const nsTArray<int>& aIntParams,
                                                       const nsTArray<nsString>& aStringParams);
     virtual bool DeallocPContentDialog(PContentDialogParent* aDialog)
     {
       delete aDialog;
       return true;
     }
 
-    virtual PExternalHelperAppParent* AllocPExternalHelperApp(
-            const IPC::URI& uri,
-            const nsCString& aMimeContentType,
-            const nsCString& aContentDisposition,
-            const bool& aForceSave,
-            const PRInt64& aContentLength);
-    virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);
-
     void LoadURL(nsIURI* aURI);
     void Move(PRUint32 x, PRUint32 y, PRUint32 width, PRUint32 height);
     void Activate();
     void SendMouseEvent(const nsAString& aType, float aX, float aY,
                         PRInt32 aButton, PRInt32 aClickCount,
                         PRInt32 aModifiers, PRBool aIgnoreRootScrollFrame);
     void SendKeyEvent(const nsAString& aType, PRInt32 aKeyCode,
                       PRInt32 aCharCode, PRInt32 aModifiers,
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -511,17 +511,18 @@ function do_get_profile() {
                        .createInstance(Components.interfaces.nsILocalFile);
   file.initWithPath(profd);
 
   let dirSvc = Components.classes["@mozilla.org/file/directory_service;1"]
                          .getService(Components.interfaces.nsIProperties);
   let provider = {
     getFile: function(prop, persistent) {
       persistent.value = true;
-      if (prop == "ProfD" || prop == "ProfLD" || prop == "ProfDS") {
+      if (prop == "ProfD" || prop == "ProfLD" || prop == "ProfDS" ||
+          prop == "ProfLDS" || prop == "TmpD") {
         return file.clone();
       }
       throw Components.results.NS_ERROR_FAILURE;
     },
     QueryInterface: function(iid) {
       if (iid.equals(Components.interfaces.nsIDirectoryServiceProvider) ||
           iid.equals(Components.interfaces.nsISupports)) {
         return this;
--- a/uriloader/exthandler/ExternalHelperAppParent.cpp
+++ b/uriloader/exthandler/ExternalHelperAppParent.cpp
@@ -36,17 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "ExternalHelperAppParent.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIExternalHelperAppService.h"
-#include "mozilla/dom/TabParent.h"
+#include "mozilla/dom/ContentParent.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsStringStream.h"
 
 #include "mozilla/unused.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -64,35 +64,30 @@ ExternalHelperAppParent::ExternalHelperA
   , mPending(PR_FALSE)
   , mLoadFlags(0)
   , mStatus(NS_OK)
   , mContentLength(aContentLength)
 {
 }
 
 void
-ExternalHelperAppParent::Init(TabParent *parent,
+ExternalHelperAppParent::Init(ContentParent *parent,
                               const nsCString& aMimeContentType,
                               const nsCString& aContentDisposition,
                               const PRBool& aForceSave)
 {
   nsHashPropertyBag::Init();
 
-  NS_ASSERTION(parent, "must have a non-null TabParent");
-  nsCOMPtr<nsIContent> frame = do_QueryInterface(parent->GetOwnerElement());
-  nsCOMPtr<nsISupports> container = frame->GetOwnerDoc()->GetContainer();
-  nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(container);
-
   nsCOMPtr<nsIExternalHelperAppService> helperAppService =
     do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
   NS_ASSERTION(helperAppService, "No Helper App Service!");
 
   SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH, mContentLength);
   SetContentDisposition(aContentDisposition);
-  helperAppService->DoContent(aMimeContentType, this, ir,
+  helperAppService->DoContent(aMimeContentType, this, nsnull,
                               aForceSave, getter_AddRefs(mListener));
 }
 
 bool
 ExternalHelperAppParent::RecvOnStartRequest(const nsCString& entityID)
 {
   mEntityID = entityID;
   mPending = PR_TRUE;
--- a/uriloader/exthandler/ExternalHelperAppParent.h
+++ b/uriloader/exthandler/ExternalHelperAppParent.h
@@ -44,17 +44,17 @@
 
 namespace IPC {
 class URI;
 }
 
 namespace mozilla {
 namespace dom {
 
-class TabParent;
+class ContentParent;
 
 class ExternalHelperAppParent : public PExternalHelperAppParent
                               , public nsHashPropertyBag
                               , public nsIChannel
                               , public nsIMultiPartChannel
                               , public nsIResumableChannel
 {
 public:
@@ -64,17 +64,17 @@ public:
     NS_DECL_NSIMULTIPARTCHANNEL
     NS_DECL_NSIRESUMABLECHANNEL
 
     bool RecvOnStartRequest(const nsCString& entityID);
     bool RecvOnDataAvailable(const nsCString& data, const PRUint32& offset, const PRUint32& count);
     bool RecvOnStopRequest(const nsresult& code);
     
     ExternalHelperAppParent(const IPC::URI& uri, const PRInt64& contentLength);
-    void Init(TabParent *parent,
+    void Init(ContentParent *parent,
               const nsCString& aMimeContentType,
               const nsCString& aContentDisposition,
               const PRBool& aForceSave);
     virtual ~ExternalHelperAppParent();
 
 private:
   nsCOMPtr<nsIStreamListener> mListener;
   nsCOMPtr<nsIURI> mURI;
--- a/uriloader/exthandler/PExternalHelperApp.ipdl
+++ b/uriloader/exthandler/PExternalHelperApp.ipdl
@@ -30,24 +30,24 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-include protocol PBrowser;
+include protocol PContent;
 
 namespace mozilla {
 namespace dom {
 
 protocol PExternalHelperApp
 {
-  manager PBrowser;
+  manager PContent;
 
 parent:
   OnStartRequest(nsCString entityID);
   OnDataAvailable(nsCString data, PRUint32 offset, PRUint32 count);
   OnStopRequest(nsresult code);
 
 child:
   Cancel(nsresult aStatus);
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -135,17 +135,17 @@
 
 #include "nsIRandomGenerator.h"
 #include "plbase64.h"
 #include "prmem.h"
 
 #include "nsIPrivateBrowsingService.h"
 
 #ifdef MOZ_IPC
-#include "TabChild.h"
+#include "ContentChild.h"
 #include "nsXULAppAPI.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocShellTreeItem.h"
 #include "ExternalHelperAppChild.h"
 #endif
 
 // Buffer file writes in 32kb chunks
@@ -679,42 +679,35 @@ NS_IMETHODIMP nsExternalHelperAppService
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
   nsCOMPtr<nsIURI> uri;
   if (channel)
     channel->GetURI(getter_AddRefs(uri));
 
 #ifdef MOZ_IPC
   PRInt64 contentLength = GetContentLengthAsInt64(aRequest);
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    // We need to get a hold of a TabChild so that we can begin forwarding
+    // 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
     // the Right Fix will eventually be to short-circuit those channels on the
     // parent side based on some sort of subscription concept.
-    nsCOMPtr<nsIDocShell> docshell(do_GetInterface(aWindowContext));
-    nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(docshell);
-    nsCOMPtr<nsIDocShellTreeOwner> owner;
-    item->GetTreeOwner(getter_AddRefs(owner));
-    NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE);
-
-    nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
-    if (!tabchild)
+    using mozilla::dom::ContentChild;
+    using mozilla::dom::ExternalHelperAppChild;
+    ContentChild *child = ContentChild::GetSingleton();
+    if (!child)
       return NS_ERROR_FAILURE;
 
     nsCString disp;
     if (channel)
       ExtractDisposition(channel, disp);
 
     // Now we build a protocol for forwarding our data to the parent.  The
     // protocol will act as a listener on the child-side and create a "real"
     // helperAppService listener on the parent-side, via another call to
     // DoContent.
-    using mozilla::dom::TabChild;
-    using mozilla::dom::ExternalHelperAppChild;
-    TabChild *child = static_cast<TabChild*>(tabchild.get());
     mozilla::dom::PExternalHelperAppChild *pc;
     pc = child->SendPExternalHelperAppConstructor(IPC::URI(uri),
                                                   nsCString(aMimeContentType),
                                                   disp,
                                                   aForceSave, contentLength);
     ExternalHelperAppChild *childListener = static_cast<ExternalHelperAppChild *>(pc);
 
     NS_ADDREF(*aStreamListener = childListener);