Bug 1467452 - Back out f5f49315fec2 to restore getJavaEnv/getJavaPeer NPAPIs to fix Flash crash. r?jimm draft
authorChris Peterson <cpeterson@mozilla.com>
Thu, 14 Jun 2018 00:26:19 -0700
changeset 807617 d6a3059b74d9c28aa35d9effd77a6781499471c7
parent 807260 c7a7df27ff38e2e75caebc44cb9ebf958b40b21e
push id113178
push userbmo:cpeterson@mozilla.com
push dateFri, 15 Jun 2018 07:50:34 +0000
reviewersjimm
bugs1467452
milestone62.0a1
Bug 1467452 - Back out f5f49315fec2 to restore getJavaEnv/getJavaPeer NPAPIs to fix Flash crash. r?jimm Flash still calls these NPAPIs to initialize some ancient LiveConnect/OJI code (just in case). MozReview-Commit-ID: JBmLK43cSyx
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsNPAPIPlugin.h
dom/plugins/ipc/PluginModuleChild.cpp
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -108,18 +108,18 @@ static NPNetscapeFuncs sBrowserFuncs = {
   nullptr, // _write, unimplemented
   nullptr, // _destroystream, unimplemented
   _status,
   _useragent,
   _memalloc,
   _memfree,
   _memflush,
   _reloadplugins,
-  nullptr, // _getJavaEnv, unimplemented
-  nullptr, // _getJavaPeer, unimplemented
+  _getJavaEnv,
+  _getJavaPeer,
   _geturlnotify,
   _posturlnotify,
   _getvalue,
   _setvalue,
   _invalidaterect,
   _invalidateregion,
   _forceredraw,
   _getstringidentifier,
@@ -1698,16 +1698,24 @@ NPError
 }
 
 NPError
 _requestread(NPStream *pstream, NPByteRange *rangeList)
 {
   return NPERR_STREAM_NOT_SEEKABLE;
 }
 
+// Deprecated, only stubbed out
+void* /* OJI type: JRIEnv* */
+_getJavaEnv()
+{
+  NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaEnv\n"));
+  return nullptr;
+}
+
 const char *
 _useragent(NPP npp)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_useragent called from the wrong thread\n"));
     return nullptr;
   }
   NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_UserAgent: npp=%p\n", (void*)npp));
@@ -1731,16 +1739,24 @@ void *
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL,("NPN_memalloc called from the wrong thread\n"));
   }
   NPN_PLUGIN_LOG(PLUGIN_LOG_NOISY, ("NPN_MemAlloc: size=%d\n", size));
   return moz_xmalloc(size);
 }
 
+// Deprecated, only stubbed out
+void* /* OJI type: jref */
+_getJavaPeer(NPP npp)
+{
+  NPN_PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("NPN_GetJavaPeer: npp=%p\n", (void*)npp));
+  return nullptr;
+}
+
 void
 _pushpopupsenabledstate(NPP npp, NPBool enabled)
 {
   if (!NS_IsMainThread()) {
     NPN_PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("NPN_pushpopupsenabledstate called from the wrong thread\n"));
     return;
   }
   nsNPAPIPluginInstance *inst = npp ? (nsNPAPIPluginInstance *)npp->ndata : nullptr;
--- a/dom/plugins/base/nsNPAPIPlugin.h
+++ b/dom/plugins/base/nsNPAPIPlugin.h
@@ -274,16 +274,23 @@ void
 _forceredraw(NPP npp);
 
 const char*
 _useragent(NPP npp);
 
 void*
 _memalloc (uint32_t size);
 
+// Deprecated entry points for the old Java plugin.
+void* /* OJI type: JRIEnv* */
+_getJavaEnv();
+
+void* /* OJI type: jref */
+_getJavaPeer(NPP npp);
+
 void
 _urlredirectresponse(NPP instance, void* notifyData, NPBool allow);
 
 NPError
 _initasyncsurface(NPP instance, NPSize *size, NPImageFormat format, void *initData, NPAsyncSurface *surface);
 
 NPError
 _finalizeasyncsurface(NPP instance, NPAsyncSurface *surface);
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -870,16 +870,24 @@ static void
 _forceredraw(NPP aNPP);
 
 static const char*
 _useragent(NPP aNPP);
 
 static void*
 _memalloc (uint32_t size);
 
+// Deprecated entry points for the old Java plugin.
+static void* /* OJI type: JRIEnv* */
+_getjavaenv(void);
+
+// Deprecated entry points for the old Java plugin.
+static void* /* OJI type: jref */
+_getjavapeer(NPP aNPP);
+
 static bool
 _invoke(NPP aNPP, NPObject* npobj, NPIdentifier method, const NPVariant *args,
         uint32_t argCount, NPVariant *result);
 
 static bool
 _invokedefault(NPP aNPP, NPObject* npobj, const NPVariant *args,
                uint32_t argCount, NPVariant *result);
 
@@ -974,18 +982,18 @@ const NPNetscapeFuncs PluginModuleChild:
     nullptr, // _write, unimplemented
     nullptr, // _destroystream, unimplemented
     mozilla::plugins::child::_status,
     mozilla::plugins::child::_useragent,
     mozilla::plugins::child::_memalloc,
     mozilla::plugins::child::_memfree,
     mozilla::plugins::child::_memflush,
     mozilla::plugins::child::_reloadplugins,
-    nullptr, // _getjavaenv, unimplemented
-    nullptr, // _getjavapeer, unimplemented
+    mozilla::plugins::child::_getjavaenv,
+    mozilla::plugins::child::_getjavapeer,
     mozilla::plugins::child::_geturlnotify,
     mozilla::plugins::child::_posturlnotify,
     mozilla::plugins::child::_getvalue,
     mozilla::plugins::child::_setvalue,
     mozilla::plugins::child::_invalidaterect,
     mozilla::plugins::child::_invalidateregion,
     mozilla::plugins::child::_forceredraw,
     PluginModuleChild::NPN_GetStringIdentifier,
@@ -1291,16 +1299,31 @@ const char*
 
 void*
 _memalloc(uint32_t aSize)
 {
     PLUGIN_LOG_DEBUG_FUNCTION;
     return moz_xmalloc(aSize);
 }
 
+// Deprecated entry points for the old Java plugin.
+void* /* OJI type: JRIEnv* */
+_getjavaenv(void)
+{
+    PLUGIN_LOG_DEBUG_FUNCTION;
+    return 0;
+}
+
+void* /* OJI type: jref */
+_getjavapeer(NPP aNPP)
+{
+    PLUGIN_LOG_DEBUG_FUNCTION;
+    return 0;
+}
+
 bool
 _invoke(NPP aNPP,
         NPObject* aNPObj,
         NPIdentifier aMethod,
         const NPVariant* aArgs,
         uint32_t aArgCount,
         NPVariant* aResult)
 {