bug 692196 - Make 'navigator.plugins' have correct content on Android r=blassey
authorJames Willcox <jwillcox@mozilla.com>
Wed, 05 Oct 2011 14:34:19 -0400
changeset 78709 13342c7d1fc390ad45e64217c1511b9e4f114b9a
parent 78708 f005ff7b0e2a1cca63bc0ca6cd45e3b19db74d5e
child 78710 dcc28a7cfa318ff0dde12e0c0bd7cd5cd9e8341a
push id21326
push userbmo@edmorley.co.uk
push dateFri, 14 Oct 2011 10:00:06 +0000
treeherdermozilla-central@ca73f057dab7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs692196
milestone10.0a1
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 692196 - Make 'navigator.plugins' have correct content on Android r=blassey From 14c74360d7af6101a2b9193ed8b8a6f4bcd6c42b Mon Sep 17 00:00:00 2001 https://bugzilla.mozilla.org/show_bug.cgi?id=692196
content/base/src/nsObjectLoadingContent.cpp
dom/plugins/base/PluginPRLibrary.cpp
dom/plugins/base/PluginPRLibrary.h
dom/plugins/base/nsPluginHost.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -707,16 +707,30 @@ nsObjectLoadingContent::OnStartRequest(n
         // Do nothing in this case: This is probably due to a display:none
         // frame. If we ever get a frame, HasNewFrame will do the right thing.
         // Abort the load though, we have no use for the data.
         mInstantiating = PR_FALSE;
         return NS_BINDING_ABORTED;
       }
 
       {
+        PluginSupportState pluginState = GetPluginSupportState(thisContent,
+                                                               mContentType);
+        // Do nothing, but fire the plugin not found event if needed
+        if (pluginState != ePluginOtherState) {
+          Fallback(PR_FALSE);
+
+          mFallbackReason = pluginState;
+          FirePluginError(thisContent, pluginState);
+          return NS_BINDING_ABORTED;
+        }
+      }
+
+
+      {
         nsIFrame *nsiframe = do_QueryFrame(frame);
 
         nsWeakFrame weakFrame(nsiframe);
 
         rv = frame->Instantiate(chan, getter_AddRefs(mFinalListener));
 
         mInstantiating = PR_FALSE;
 
@@ -1924,16 +1938,22 @@ nsObjectLoadingContent::Instantiate(nsIO
 
   return rv;
 }
 
 /* static */ PluginSupportState
 nsObjectLoadingContent::GetPluginSupportState(nsIContent* aContent,
                                               const nsCString& aContentType)
 {
+#ifdef ANDROID
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    return ePluginClickToPlay;
+  }
+#endif
+
   if (!aContent->IsHTML()) {
     return ePluginOtherState;
   }
 
   if (aContent->Tag() == nsGkAtoms::embed ||
       aContent->Tag() == nsGkAtoms::applet) {
     return GetPluginDisabledState(aContentType);
   }
@@ -1958,18 +1978,19 @@ nsObjectLoadingContent::GetPluginSupport
   return hasAlternateContent ? ePluginOtherState :
     GetPluginDisabledState(aContentType);
 }
 
 /* static */ PluginSupportState
 nsObjectLoadingContent::GetPluginDisabledState(const nsCString& aContentType)
 {
 #ifdef ANDROID
-      if (XRE_GetProcessType() == GeckoProcessType_Content)
-        return ePluginClickToPlay;
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    return ePluginClickToPlay;
+  }
 #endif
   nsCOMPtr<nsIPluginHost> pluginHostCOM(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID));
   nsPluginHost *pluginHost = static_cast<nsPluginHost*>(pluginHostCOM.get());
   if (!pluginHost) {
     return ePluginUnsupported;
   }
 
   nsresult rv = pluginHost->IsPluginEnabledForType(aContentType.get());
--- a/dom/plugins/base/PluginPRLibrary.cpp
+++ b/dom/plugins/base/PluginPRLibrary.cpp
@@ -50,25 +50,32 @@ static int gNotOptimized;
 #else
 #define CALLING_CONVENTION_HACK
 #endif
 
 #ifdef ANDROID
 #include "AndroidBridge.h"
 #include "android_npapi.h"
 #include <android/log.h>
+#include "nsXULAppAPI.h"
+#include "nsIXULRuntime.h"
 #define ALOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoJavaEnv", ## args)
 #endif
 
 namespace mozilla {
 #ifdef ANDROID
 nsresult
 PluginPRLibrary::NP_Initialize(NPNetscapeFuncs* bFuncs,
 			       NPPluginFuncs* pFuncs, NPError* error)
 {
+  // We need the JNI environment, which is only in the
+  // chrome process (since it is started by Android)
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    return NS_ERROR_FAILURE;
+  }
   if (mNP_Initialize) {
     *error = mNP_Initialize(bFuncs, pFuncs, GetJNIForThread());
   } else {
     NP_InitializeFunc pfNP_Initialize = (NP_InitializeFunc)
       PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
     if (!pfNP_Initialize)
       return NS_ERROR_FAILURE;
     *error = pfNP_Initialize(bFuncs, pFuncs, GetJNIForThread());
--- a/dom/plugins/base/PluginPRLibrary.h
+++ b/dom/plugins/base/PluginPRLibrary.h
@@ -37,16 +37,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef PluginPRLibrary_h
 #define PluginPRLibrary_h 1
 
 #include "mozilla/PluginLibrary.h"
 #include "nsNPAPIPlugin.h"
 #include "npfunctions.h"
+#include "nsIXULRuntime.h"
 
 namespace mozilla {
 
 class PluginPRLibrary : public PluginLibrary
 {
 public:
     PluginPRLibrary(const char* aFilePath, PRLibrary* aLibrary) :
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -2247,21 +2247,16 @@ nsresult nsPluginHost::ScanPluginsDirect
       if (!aCreatePluginList && *aPluginsChanged)
         break;
     }
     return NS_OK;
 }
 
 nsresult nsPluginHost::LoadPlugins()
 {
-#ifdef ANDROID
-  if (XRE_GetProcessType() == GeckoProcessType_Content) {
-    return NS_OK;
-  }
-#endif
   // do not do anything if it is already done
   // use ReloadPlugins() to enforce loading
   if (mPluginsLoaded)
     return NS_OK;
 
   if (mPluginsDisabled)
     return NS_OK;