Bug 583542 - [e10s] nsExternalHelperAppService fails when called from content process [r=bsmedberg]
☠☠ backed out by 92ab40761955 ☠ ☠
authorBrad Lassey <blassey@mozilla.com>
Sun, 01 Aug 2010 02:38:56 -0400
changeset 48961 af956e9c02e373ec9b5a11b7459819e18a6d919f
parent 48960 aeaac11e5c73944bc8359b8cf7fa723423c3e592
child 48962 86b0c51d199ca5ca268772e4114b854200a2b3c7
child 48967 92ab4076195541fe76e782566aa28bae427d6fa9
push id14877
push usermbrubeck@mozilla.com
push dateThu, 05 Aug 2010 22:54:53 +0000
treeherdermozilla-central@af956e9c02e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs583542
milestone2.0b4pre
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 583542 - [e10s] nsExternalHelperAppService fails when called from content process [r=bsmedberg]
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/Makefile.in
dom/ipc/PContent.ipdl
uriloader/exthandler/Makefile.in
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -48,16 +48,18 @@
 #include "nsIPrefLocalizedString.h"
 #include "nsIObserverService.h"
 #include "nsContentUtils.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsChromeRegistryChrome.h"
+#include "nsExternalHelperAppService.h"
+#include "nsCExternalHandlerService.h"
 
 #ifdef ANDROID
 #include "AndroidBridge.h"
 using namespace mozilla;
 #endif
 
 using namespace mozilla::ipc;
 using namespace mozilla::net;
@@ -465,16 +467,26 @@ ContentParent::RecvSetURITitle(const IPC
                                       const nsString& title)
 {
     nsCOMPtr<nsIURI> ourURI(uri);
     IHistory *history = nsContentUtils::GetHistory(); 
     history->SetURITitle(ourURI, title);
     return true;
 }
 
+bool
+ContentParent::RecvLoadURIExteneral(const URI& uri)
+{
+    nsCOMPtr<nsIExternalProtocolService> extProtService (do_GetService(NS_EXTERNALPROTOCOLSERVICE_CONTRACTID));
+    nsCOMPtr<nsIURI> ourURI = uri;
+    extProtService->LoadURI(ourURI, nsnull);
+    return true;
+}
+
+
 /* void onDispatchedEvent (in nsIThreadInternal thread); */
 NS_IMETHODIMP
 ContentParent::OnDispatchedEvent(nsIThreadInternal *thread)
 {
     if (mOldObserver)
         return mOldObserver->OnDispatchedEvent(thread);
 
     return NS_OK;
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -149,16 +149,18 @@ private:
     virtual bool RecvStartVisitedQuery(const IPC::URI& uri);
 
     virtual bool RecvVisitURI(const IPC::URI& uri,
                               const IPC::URI& referrer,
                               const PRUint32& flags);
 
     virtual bool RecvSetURITitle(const IPC::URI& uri,
                                  const nsString& title);
+
+    virtual bool RecvLoadURIExteneral(const URI& uri);
     
     virtual bool RecvNotifyIME(const int&, const int&);
 
     virtual bool RecvNotifyIMEChange(const nsString&, const PRUint32&, const int&, 
                                const int&, const int&)
 ;
 
 
--- a/dom/ipc/Makefile.in
+++ b/dom/ipc/Makefile.in
@@ -77,13 +77,14 @@ include $(topsrcdir)/ipc/chromium/chromi
 include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES += \
 		-I$(srcdir)/../../content/base/src \
 		-I$(srcdir)/../../content/events/src \
 		-I$(srcdir)/../../toolkit/components/places/src \
 		-I$(srcdir)/../src/geolocation \
 		-I$(topsrcdir)/chrome/src \
+		-I$(topsrcdir)/uriloader/exthandler \
 		$(NULL)
 
 CXXFLAGS += $(TK_CFLAGS)
 
 DEFINES += -DBIN_SUFFIX='"$(BIN_SUFFIX)"'
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -76,16 +76,18 @@ parent:
     PNecko();
 
     // Services remoting
 
     async StartVisitedQuery(URI uri);
     async VisitURI(URI uri, URI referrer, PRUint32 flags);
     async SetURITitle(URI uri, nsString title);
 
+    async LoadURIExteneral(URI uri);
+
     // PrefService messages
     sync GetPrefType(nsCString prefName) returns (PRInt32 retValue, nsresult rv);
     sync GetBoolPref(nsCString prefName) returns (PRBool retValue, nsresult rv);
     sync GetIntPref(nsCString prefName)  returns (PRInt32 retValue, nsresult rv);
     sync GetCharPref(nsCString prefName) returns (nsCString retValue, nsresult rv);
     sync GetPrefLocalizedString(nsCString prefName) returns (nsString retValue, nsresult rv);
     sync PrefHasUserValue(nsCString prefName) returns (PRBool retValue, nsresult rv);
     sync PrefIsLocked(nsCString prefName) returns (PRBool retValue, nsresult rv);
--- a/uriloader/exthandler/Makefile.in
+++ b/uriloader/exthandler/Makefile.in
@@ -170,16 +170,18 @@ EXTRA_COMPONENTS = \
   nsHandlerService.manifest \
   nsWebHandlerApp.js \
   nsWebHandlerApp.manifest \
   $(NULL)
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 FORCE_STATIC_LIB = 1
 SRCS_IN_OBJDIR	= 1
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 ifneq (,$(filter qt gtk2, $(MOZ_WIDGET_TOOLKIT)))
 CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
 endif
 
 # the use of multiple VPATH dirs is broken in cygwin make
 ifeq ($(OS_ARCH),WINNT WINCE)
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -37,16 +37,21 @@
  * 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 ***** */
 
+#ifdef MOZ_IPC
+#include "mozilla/dom/ContentChild.h"
+#include "nsXULAppAPI.h"
+#endif
+
 #include "nsExternalHelperAppService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIURI.h"
 #include "nsIURL.h"
 #include "nsIFile.h"
 #include "nsIFileURL.h"
 #include "nsIChannel.h"
 #include "nsIDirectoryService.h"
@@ -856,16 +861,23 @@ static const char kExternalProtocolPrefP
 static const char kExternalProtocolDefaultPref[] = "network.protocol-handler.external-default";
 
 NS_IMETHODIMP 
 nsExternalHelperAppService::LoadURI(nsIURI *aURI,
                                     nsIInterfaceRequestor *aWindowContext)
 {
   NS_ENSURE_ARG_POINTER(aURI);
 
+#ifdef MOZ_IPC
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    mozilla::dom::ContentChild::GetSingleton()->SendLoadURIExteneral(aURI);
+    return NS_OK;
+  }
+#endif
+
   nsCAutoString spec;
   aURI->GetSpec(spec);
 
   if (spec.Find("%00") != -1)
     return NS_ERROR_MALFORMED_URI;
 
   spec.ReplaceSubstring("\"", "%22");
   spec.ReplaceSubstring("`", "%60");