From 6ce8eb93c94733d27bcf1ef39803cd3427c49eb2 Mon Sep 17 00:00:00 2001 From: Michael Wu Date: Fri, 25 Jun 2010 13:29:43 -0700 Subject: [PATCH] Bug 574120 - Add support for IPC on Android to everything else, r=dougt --- configure.in | 2 +- content/base/src/nsFrameLoader.cpp | 4 ++++ dom/ipc/TabChild.cpp | 5 +++++ dom/ipc/TabTypes.h | 4 ++++ dom/plugins/PluginMessageUtils.h | 2 +- ipc/glue/GeckoChildProcessHost.cpp | 10 ++++++++++ toolkit/library/libxul-config.mk | 2 ++ toolkit/xre/nsAppRunner.cpp | 17 ++++++++++++++++- widget/src/android/nsWindow.cpp | 4 ++++ 9 files changed, 47 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 1b8d23c0a4f..b357752c20e 100644 --- a/configure.in +++ b/configure.in @@ -5703,7 +5703,7 @@ dnl ======================================================== dnl = Disable IPC support for tabs and plugins dnl ======================================================== case "${target}" in -*-wince*|*-android*) +*-wince*) MOZ_IPC= ;; esac diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index e69dc50747c..9f1295c5723 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -817,6 +817,10 @@ nsFrameLoader::ShowRemoteFrame(nsIFrameFrame* frame, nsIView* view) // Don't create any parent/child XEmbed, because we are painting with shared memory mChildProcess->SendcreateWidget(0); } +#elif defined(ANDROID) + // Painting with shared memory + + mChildProcess->SendcreateWidget(0); #elif defined(XP_MACOSX) # warning IMPLEMENT ME diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 2b898cd36e8..5999c30ced3 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -431,6 +431,11 @@ TabChild::RecvcreateWidget(const MagicWindowHandle& parentWidget) view->scene()->addItem(win); #elif defined(XP_WIN) HWND win = parentWidget; +#elif defined(ANDROID) + // Fake pointer to make baseWindow->InitWindow work + // The android widget code is mostly disabled in the child process + // so it won't choke on this + void *win = (void *)0x1234; #elif defined(XP_MACOSX) # warning IMPLEMENT ME #else diff --git a/dom/ipc/TabTypes.h b/dom/ipc/TabTypes.h index e3838b56d6c..4c64c4c806f 100644 --- a/dom/ipc/TabTypes.h +++ b/dom/ipc/TabTypes.h @@ -23,6 +23,10 @@ typedef unsigned long MagicWindowHandle; # warning This is a placeholder typedef long MagicWindowHandle; +#elif defined(ANDROID) +/* we don't really use this */ +typedef unsigned long MagicWindowHandle; + #else #error Not implemented, stooge #endif diff --git a/dom/plugins/PluginMessageUtils.h b/dom/plugins/PluginMessageUtils.h index d88ecafbdf9..81400ca26ee 100644 --- a/dom/plugins/PluginMessageUtils.h +++ b/dom/plugins/PluginMessageUtils.h @@ -124,7 +124,7 @@ struct NPRemoteWindow typedef HWND NativeWindowHandle; #elif defined(MOZ_X11) typedef XID NativeWindowHandle; -#elif defined(XP_MACOSX) +#elif defined(XP_MACOSX) || defined(ANDROID) typedef intptr_t NativeWindowHandle; // never actually used, will always be 0 #else #error Need NativeWindowHandle for this platform diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index c4bb4352766..3d5c0b5c6d4 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -53,8 +53,10 @@ #include "nsDirectoryServiceDefs.h" #include "nsIFile.h" +#include "nsILocalFile.h" #include "mozilla/ipc/BrowserProcessSubThread.h" +#include "mozilla/Omnijar.h" #include #ifdef XP_WIN @@ -202,6 +204,14 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector aExtraOpts) path += "/lib"; #endif newEnvVars["LD_LIBRARY_PATH"] = path.get(); +#endif +#ifdef MOZ_OMNIJAR + // Make sure the child process can find the omnijar + // See ScopedXPCOMStartup::Initialize in nsAppRunner.cpp + nsCAutoString omnijarPath; + if (mozilla::OmnijarPath()) + mozilla::OmnijarPath()->GetNativePath(omnijarPath); + newEnvVars["OMNIJAR_PATH"] = omnijarPath.get(); #endif } else { diff --git a/toolkit/library/libxul-config.mk b/toolkit/library/libxul-config.mk index 3feb375dfb4..b1ea021593a 100644 --- a/toolkit/library/libxul-config.mk +++ b/toolkit/library/libxul-config.mk @@ -107,8 +107,10 @@ STATIC_LIBS += ipdlunittest_s endif ifeq (Linux,$(OS_ARCH)) +ifneq (Android,$(OS_TARGET)) OS_LIBS += -lrt endif +endif ifeq (WINNT,$(OS_ARCH)) OS_LIBS += dbghelp.lib endif diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index ad79f4ae437..8a86cba276a 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1135,7 +1135,11 @@ ScopedXPCOMStartup::Initialize() nsresult rv; #ifdef MOZ_OMNIJAR nsCOMPtr lf; - rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf)); + char *omnijarPath = getenv("OMNIJAR_PATH"); + if (omnijarPath) + rv = NS_NewNativeLocalFile(nsDependentCString(omnijarPath), PR_TRUE, getter_AddRefs(lf)); + else + rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf)); if (NS_SUCCEEDED(rv)) mozilla::SetOmnijar(lf); #endif @@ -3756,6 +3760,17 @@ XRE_InitCommandLine(int aArgc, char* aArgv[]) #if defined(OS_WIN) CommandLine::Init(aArgc, aArgv); #else +#ifdef MOZ_OMNIJAR + nsCOMPtr lf; + char *omnijarPath = getenv("OMNIJAR_PATH"); + if (omnijarPath) + rv = NS_NewNativeLocalFile(nsDependentCString(omnijarPath), PR_TRUE, getter_AddRefs(lf)); + else + rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf)); + if (NS_SUCCEEDED(rv)) + mozilla::SetOmnijar(lf); +#endif + // these leak on error, but that's OK: we'll just exit() char** canonArgs = new char*[aArgc]; diff --git a/widget/src/android/nsWindow.cpp b/widget/src/android/nsWindow.cpp index bb505a2a224..44f70488cfe 100644 --- a/widget/src/android/nsWindow.cpp +++ b/widget/src/android/nsWindow.cpp @@ -162,6 +162,10 @@ nsWindow::Create(nsIWidget *aParent, ALOG("nsWindow[%p]::Create %p [%d %d %d %d]", (void*)this, (void*)aParent, aRect.x, aRect.y, aRect.width, aRect.height); nsWindow *parent = (nsWindow*) aParent; + if (!AndroidBridge::Bridge()) { + aNativeParent = nsnull; + } + if (aNativeParent) { if (parent) { ALOG("Ignoring native parent on Android window [%p], since parent was specified (%p %p)", (void*)this, (void*)aNativeParent, (void*)aParent);