merge plugin work from libchromiumipc. add env var check for OOP iframe. a few small bugfixes here and there.
authorChris Jones <jones.chris.g@gmail.com>
Thu, 02 Jul 2009 11:54:22 -0500
changeset 35746 9c16bf14545c177f98ba8a3ffabf871dbe7c2c55
parent 35745 11c34494c1f3a364a9250c85e9d82639c29bf0d9
child 35747 561253b4575b2ebd17cb53efea9b3ffaf82f53a1
push idunknown
push userunknown
push dateunknown
milestone1.9.2a1pre
merge plugin work from libchromiumipc. add env var check for OOP iframe. a few small bugfixes here and there.
content/base/src/nsFrameLoader.cpp
dom/plugins/Makefile.in
dom/plugins/NPAPIPluginChild.cpp
dom/plugins/NPAPIPluginChild.h
dom/plugins/NPAPIPluginParent.cpp
dom/plugins/NPAPIPluginParent.h
dom/plugins/NPAPIProtocol.h
dom/plugins/NPAPIProtocolChild.h
dom/plugins/NPAPIProtocolParent.h
dom/plugins/NPObjectProtocolChild.h
dom/plugins/NPPInstanceChild.cpp
dom/plugins/NPPInstanceChild.h
dom/plugins/NPPInstanceParent.cpp
dom/plugins/NPPInstanceParent.h
dom/plugins/NPPProtocol.h
dom/plugins/NPPProtocolChild.h
dom/plugins/NPPProtocolParent.h
dom/plugins/PluginMessageUtils.h
dom/plugins/PluginProcessParent.cpp
dom/plugins/PluginProcessParent.h
dom/plugins/PluginThreadChild.h
dom/plugins/SharedPRLibrary.h
ipc/glue/IPCMessageUtils.h
ipc/glue/ProtocolUtils.h
ipc/ipdl/ipdl/lower.py
modules/plugin/base/src/nsNPAPIPlugin.cpp
modules/plugin/test/testplugin/nptest.cpp
modules/plugin/test/testplugin/nptest_windows.cpp
toolkit/xre/nsAppRunner.cpp
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -38,16 +38,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * Class for managing loading of a subframe (creation of the docshell,
  * handling of loads in it, recursion-checking).
  */
 
+#include "prenv.h"
+
 #include "nsIDOMHTMLIFrameElement.h"
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsIDOMWindow.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
@@ -1029,24 +1031,28 @@ nsFrameLoader::CheckForRecursiveLoad(nsI
   }
 
   return NS_OK;
 }
 
 PRBool
 nsFrameLoader::TryNewProcess()
 {
+  if (PR_GetEnv("DISABLE_OOP_IFRAME")) {
+      return PR_FALSE;
+  }
+
   nsIDocument* doc = mOwnerContent->GetDocument();
   if (!doc) {
-    return NS_ERROR_UNEXPECTED;
+    return PR_FALSE;
   }
 
   if (doc->GetDisplayDocument()) {
     // Don't allow subframe loads in external reference documents
-    return NS_ERROR_NOT_AVAILABLE;
+    return PR_FALSE;
   }
 
   nsCOMPtr<nsIWebNavigation> parentAsWebNav =
     do_GetInterface(doc->GetScriptGlobalObject());
 
   if (!parentAsWebNav) {
     return PR_FALSE;
   }
--- a/dom/plugins/Makefile.in
+++ b/dom/plugins/Makefile.in
@@ -57,16 +57,17 @@ EXPORTS_mozilla/plugins =			\
   NPAPIProtocol.h				\
   NPAPIProtocolChild.h				\
   NPAPIProtocolParent.h				\
   NPPInstanceChild.h				\
   NPPInstanceParent.h				\
   NPPProtocol.h					\
   NPPProtocolChild.h				\
   NPPProtocolParent.h				\
+  PluginMessageUtils.h				\
   PluginProcessParent.h				\
   PluginThreadChild.h				\
   $(NULL)
 
 MODULE           = dom
 LIBRARY_NAME     = domplugins_s
 LIBXUL_LIBRARY   = 1
 FORCE_STATIC_LIB = 1
--- a/dom/plugins/NPAPIPluginChild.cpp
+++ b/dom/plugins/NPAPIPluginChild.cpp
@@ -34,34 +34,40 @@
  * 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/plugins/NPAPIPluginChild.h"
 
+#ifdef OS_LINUX
+#include <gtk/gtk.h>
+#endif
+
 #include "nsIFile.h"
 #include "nsILocalFile.h"
 
 #include "nsDebug.h"
 #include "nsCOMPtr.h"
 #include "nsPluginsDir.h"
 
 #include "mozilla/plugins/NPPInstanceChild.h"
 
 namespace mozilla {
 namespace plugins {
 
 
 NPAPIPluginChild::NPAPIPluginChild() :
-    mNpapi(this),
-    mLibrary(0)
-//    ,mInitializeFunc(0),
-//    mShutdownFunc(0)
+    mLibrary(0),
+    mInitializeFunc(0),
+    mShutdownFunc(0)
+#ifdef OS_WIN
+  , mGetEntryPointsFunc(0)
+#endif
 //  ,mNextInstanceId(0)
 {
     memset(&mFunctions, 0, sizeof(mFunctions));
     memset(&mSavedData, 0, sizeof(mSavedData));
 }
 
 NPAPIPluginChild::~NPAPIPluginChild()
 {
@@ -74,60 +80,86 @@ bool
 NPAPIPluginChild::Init(const std::string& aPluginFilename,
                        MessageLoop* aIOLoop,
                        IPC::Channel* aChannel)
 {
     _MOZ_LOG(__FUNCTION__);
 
     NS_ASSERTION(aChannel, "need a channel");
 
+    if (!InitGraphics())
+        return false;
+
     nsCString filename;
     filename = aPluginFilename.c_str();
     nsCOMPtr<nsILocalFile> pluginFile;
     NS_NewNativeLocalFile(filename,
                           PR_TRUE,
                           getter_AddRefs(pluginFile));
 
     PRBool exists;
     pluginFile->Exists(&exists);
     NS_ASSERTION(exists, "plugin file ain't there");
 
     nsCOMPtr<nsIFile> pluginIfile;
     pluginIfile = do_QueryInterface(pluginFile);
 
     nsPluginFile lib(pluginIfile);
 
-    int rv = lib.LoadPlugin(mLibrary);
+    nsresult rv = lib.LoadPlugin(mLibrary);
     NS_ASSERTION(NS_OK == rv, "trouble with mPluginFile");
     NS_ASSERTION(mLibrary, "couldn't open shared object");
 
-    if (!mNpapi.Open(aChannel, aIOLoop))
+    if (!Open(aChannel, aIOLoop))
         return false;
 
     memset((void*) &mFunctions, 0, sizeof(mFunctions));
     mFunctions.size = sizeof(mFunctions);
 
 
-#ifdef OS_LINUX
+#if defined(OS_LINUX)
     mShutdownFunc =
         (NP_PLUGINSHUTDOWN) PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
 
     // create the new plugin handler
 
     mInitializeFunc =
         (NP_PLUGINUNIXINIT) PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
     NS_ASSERTION(mInitializeFunc, "couldn't find NP_Initialize()");
 
-    return true;
+#elif defined(OS_WIN)
+    mShutdownFunc =
+        (NP_PLUGINSHUTDOWN)PR_FindFunctionSymbol(mLibrary, "NP_Shutdown");
 
+    mGetEntryPointsFunc =
+        (NP_GETENTRYPOINTS)PR_FindSymbol(mLibrary, "NP_GetEntryPoints");
+    NS_ENSURE_TRUE(mGetEntryPointsFunc, false);
+
+    mInitializeFunc =
+        (NP_PLUGININIT)PR_FindFunctionSymbol(mLibrary, "NP_Initialize");
+    NS_ENSURE_TRUE(mInitializeFunc, false);
 #else
 
 #error Please copy the initialization code from nsNPAPIPlugin.cpp
 
 #endif
+    return true;
+}
+
+bool
+NPAPIPluginChild::InitGraphics()
+{
+    // FIXME/cjones: is this the place for this?
+#if defined(OS_LINUX)
+    gtk_init(0, 0);
+#else
+    // may not be necessary on all platforms
+#endif
+
+    return true;
 }
 
 void
 NPAPIPluginChild::CleanUp()
 {
     // FIXME/cjones: destroy all instances
 }
 
@@ -852,34 +884,46 @@ NPError NP_CALLBACK
                        uint32_t* aPasswordLength)
 {
     _MOZ_LOG(__FUNCTION__);
     return NPERR_NO_ERROR;
 }
 
 #endif /* NP_VERSION_MINOR > 19 */
 
-NPError
-NPAPIPluginChild::NP_Initialize()
+nsresult
+NPAPIPluginChild::AnswerNP_Initialize(NPError* rv)
 {
     _MOZ_LOG(__FUNCTION__);
 
-#ifdef OS_LINUX
-    return mInitializeFunc(&sBrowserFuncs, &mFunctions);
+#if defined(OS_LINUX)
+    *rv = mInitializeFunc(&sBrowserFuncs, &mFunctions);
+    return NS_OK;
+
+#elif defined(OS_WIN)
+    nsresult rv = mGetEntryPointsFunc(&mFunctions);
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    NS_ASSERTION(HIBYTE(mFunctions.version) >= NP_VERSION_MAJOR,
+                 "callback version is less than NP version");
+
+    *rv = mInitializeFunc(&sBrowserFuncs);
+    return NS_OK;
 #else
 #  error Please implement me for your platform
 #endif
 }
 
-NPError
-NPAPIPluginChild::NPP_New(const String& aMimeType,
-                          /*const NPPParent*&*/const int& aHandle,
-                          const uint16_t& aMode,
-                          const StringArray& aNames,
-                          const StringArray& aValues)
+NPPProtocolChild*
+NPAPIPluginChild::NPPConstructor(const String& aMimeType,
+                                 /*const NPPParent*&*/const int& aHandle,
+                                 const uint16_t& aMode,
+                                 const StringArray& aNames,
+                                 const StringArray& aValues,
+                                 NPError* rv)
 {
     _MOZ_LOG(__FUNCTION__);
 
     // create our wrapper instance
     NPPInstanceChild* childInstance = new NPPInstanceChild(&mFunctions);
 
     // unpack the arguments into a C format
     int argc = aNames.size();
@@ -897,39 +941,42 @@ NPAPIPluginChild::NPP_New(const String& 
         argv[i] = strdup(aValues[i].c_str());
         printf("%s=%s, ", argn[i], argv[i]);
     }
     printf(")\n");
 
     NPP npp = childInstance->GetNPP();
 
     // FIXME/cjones: use SAFE_CALL stuff
-    NPError rv = mFunctions.newp((char*) aMimeType.c_str(),
-                                 npp,
-                                 aMode,
-                                 argc,
-                                 argn,
-                                 argv,
-                                 0);
-    if (NPERR_NO_ERROR != rv)
+    *rv = mFunctions.newp((char*) aMimeType.c_str(),
+                          npp,
+                          aMode,
+                          argc,
+                          argn,
+                          argv,
+                          0);
+    if (NPERR_NO_ERROR != *rv) {
+        childInstance = 0;
         goto out;
-
-
-    // FIXME/cjones: HACK ALERT!  kill this and manage through NPAPI
-    childInstance->mNpp.SetChannel(mNpapi.HACK_getchannel_please());
-    mNpapi.HACK_npp = &(childInstance->mNpp);
-
+    }
 
 out:
-    printf ("[NPAPIPluginChild] %s: returning %hd\n", __FUNCTION__, rv);
+    printf ("[NPAPIPluginChild] %s: returning %hd\n", __FUNCTION__, *rv);
     for (int i = 0; i < argc; ++i) {
         free(argn[i]);
         free(argv[i]);
     }
     free(argn);
     free(argv);
 
-    return rv;
+    return childInstance;
+}
+
+
+nsresult
+NPAPIPluginChild::NPPDestructor(NPPProtocolChild* actor, NPError* rv)
+{
+    return NS_OK;
 }
 
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/NPAPIPluginChild.h
+++ b/dom/plugins/NPAPIPluginChild.h
@@ -1,8 +1,9 @@
+
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: sw=4 ts=4 et :
  * ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
@@ -38,16 +39,18 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef dom_plugins_NPAPIPluginChild_h
 #define dom_plugins_NPAPIPluginChild_h 1
 
 #include <string>
 #include <vector>
 
+#include "base/basictypes.h"
+
 #include "prlink.h"
 
 #include "npapi.h"
 #include "npfunctions.h"
 #include "nsplugindefs.h"
 
 #include "base/hash_tables.h"
 
@@ -86,58 +89,62 @@ typedef NS_NPAPIPLUGIN_CALLBACK(NPError,
 
 #undef _MOZ_LOG
 #define _MOZ_LOG(s)  printf("[NPAPIPluginChild] %s\n", s)
 
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
-class NPAPIPluginChild : public NPAPIProtocol::Child
+class NPAPIPluginChild : public NPAPIProtocolChild
 {
-private:
-    typedef mozilla::ipc::String String;
-    typedef mozilla::ipc::StringArray StringArray;
+protected:
+    // Implement the NPAPIProtocolChild interface
+    virtual nsresult AnswerNP_Initialize(NPError* rv);
+
+    virtual NPPProtocolChild* NPPConstructor(
+        const String& aMimeType,
+        /*const NPPParent*&*/const int& aHandle,
+        const uint16_t& aMode,
+        const StringArray& aNames,
+        const StringArray& aValues,
+        NPError* rv);
+
+    virtual nsresult NPPDestructor(
+        NPPProtocolChild* actor,
+        NPError* rv);
 
 public:
     NPAPIPluginChild();
     virtual ~NPAPIPluginChild();
 
     bool Init(const std::string& aPluginFilename,
               MessageLoop* aIOLoop,
               IPC::Channel* aChannel);
 
     void CleanUp();
 
-    // Implement the NPAPIProtocol::Child interface
-    virtual NPError NP_Initialize();
-
-    virtual NPError NPP_New(const String& aMimeType,
-                            /*const NPPParent*&*/const int& aHandle,
-                            const uint16_t& aMode,
-                            const StringArray& aNames,
-                            const StringArray& aValues);
-
-    virtual void NPP_Destroy()
-    {
-        _MOZ_LOG(__FUNCTION__);
-    }
-
     static const NPNetscapeFuncs sBrowserFuncs;
 
 private:
+    bool InitGraphics();
+
     std::string mPluginFilename;
-    NPAPIProtocolChild mNpapi;
     PRLibrary* mLibrary;
 
 //  base::hash_map<int, Instance*> mInstances;
 //  int mNextInstanceId;
 
     // we get this from the plugin
+#ifdef OS_LINUX
     NP_PLUGINUNIXINIT mInitializeFunc;
+#elif OS_WIN
+    NP_PLUGININIT mInitializeFunc;
+    NP_GETENTRYPOINTS mGetEntryPointsFunc;
+#endif
     NP_PLUGINSHUTDOWN mShutdownFunc;
     NPPluginFuncs mFunctions;
     NPSavedData mSavedData;
 };
 
 } /* namespace plugins */
 } /* namespace mozilla */
 
--- a/dom/plugins/NPAPIPluginParent.cpp
+++ b/dom/plugins/NPAPIPluginParent.cpp
@@ -31,20 +31,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 ***** */
 
+#include "mozilla/plugins/NPAPIPluginParent.h"
+
 #include "base/task.h"
 
 #include "mozilla/ipc/GeckoThread.h"
-#include "mozilla/plugins/NPAPIPluginParent.h"
 
 using mozilla::Monitor;
 using mozilla::MonitorAutoEnter;
 using mozilla::ipc::BrowserProcessSubThread;
 
 template<>
 struct RunnableMethodTraits<mozilla::plugins::NPAPIPluginParent>
 {
@@ -52,47 +53,45 @@ struct RunnableMethodTraits<mozilla::plu
     static void ReleaseCallee(mozilla::plugins::NPAPIPluginParent* obj) { }
 };
 
 namespace mozilla {
 namespace plugins {
 
 
 SharedLibrary*
-NPAPIPluginParent::LoadModule(const char* aFullPath,
-                              PRLibrary* aLibrary)
+NPAPIPluginParent::LoadModule(const char* aFilePath, PRLibrary* aLibrary)
 {
     _MOZ_LOG(__FUNCTION__);
 
     // Block on the child process being launched and initialized.
-    NPAPIPluginParent* parent = new NPAPIPluginParent(aFullPath);
+    NPAPIPluginParent* parent = new NPAPIPluginParent(aFilePath);
 
     // launch the process synchronously
     {MonitorAutoEnter mon(parent->mMonitor);
         BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)
             ->PostTask(
                 FROM_HERE,
                 NewRunnableMethod(parent,
                                   &NPAPIPluginParent::LaunchSubprocess));
         mon.Wait();
     }
 
-    parent->mNpapi.Open(parent->mSubprocess.GetChannel());
+    parent->Open(parent->mSubprocess.GetChannel());
 
     // FIXME/cjones: leaking NPAPIPluginParents ...
     return parent->mShim;
 }
 
 
-NPAPIPluginParent::NPAPIPluginParent(const char* aFullPath) :
-    mFullPath(aFullPath),       // what's this for?
-    mSubprocess(aFullPath),
-    mNpapi(this),
+NPAPIPluginParent::NPAPIPluginParent(const char* aFilePath) :
+    mFilePath(aFilePath),
+    mSubprocess(aFilePath),
     mMonitor("mozilla.plugins.NPAPIPluginParent.LaunchPluginProcess"),
-    mShim(new Shim(this))
+    ALLOW_THIS_IN_INITIALIZER_LIST(mShim(new Shim(this)))
 {
 }
 
 NPAPIPluginParent::~NPAPIPluginParent()
 {
     _MOZ_LOG("  (closing Shim ...)");
     delete mShim;
 }
@@ -100,91 +99,138 @@ NPAPIPluginParent::~NPAPIPluginParent()
 void
 NPAPIPluginParent::LaunchSubprocess()
 {
     MonitorAutoEnter mon(mMonitor);
     mSubprocess.Launch();
     mon.Notify();
 }
 
-void
-NPAPIPluginParent::NPN_GetValue()
+NPPProtocolParent*
+NPAPIPluginParent::NPPConstructor(const String& aMimeType,
+                                  const int& aHandle,
+                                  const uint16_t& aMode,
+                                  const StringArray& aNames,
+                                  const StringArray& aValues,
+                                  NPError* rv)
 {
-    _MOZ_LOG(__FUNCTION__);
+    return new NPPInstanceParent(mNPNIface);
+}
+
+nsresult
+NPAPIPluginParent::NPPDestructor(NPPProtocolParent* __a,
+                                 NPError* rv)
+{
+    return NS_OK;
 }
 
+void
+NPAPIPluginParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
+{
+    aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
+    aFuncs->javaClass = nsnull;
+
+    // FIXME/cjones: /should/ dynamically allocate shim trampoline.
+    // but here we just HACK
+    aFuncs->newp = Shim::NPP_New;
+    aFuncs->destroy = Shim::NPP_Destroy;
+    aFuncs->setwindow = Shim::NPP_SetWindow;
+    aFuncs->newstream = Shim::NPP_NewStream;
+    aFuncs->destroystream = Shim::NPP_DestroyStream;
+    aFuncs->asfile = Shim::NPP_StreamAsFile;
+    aFuncs->writeready = Shim::NPP_WriteReady;
+    aFuncs->write = Shim::NPP_Write;
+    aFuncs->print = Shim::NPP_Print;
+    aFuncs->event = Shim::NPP_HandleEvent;
+    aFuncs->urlnotify = Shim::NPP_URLNotify;
+    aFuncs->getvalue = Shim::NPP_GetValue;
+    aFuncs->setvalue = Shim::NPP_SetValue;
+}
+
+#ifdef OS_LINUX
 NPError
 NPAPIPluginParent::NP_Initialize(const NPNetscapeFuncs* npnIface,
                                  NPPluginFuncs* nppIface)
 {
     _MOZ_LOG(__FUNCTION__);
 
-    NPError rv = mNpapi.NP_Initialize();
-    if (NPERR_NO_ERROR != rv)
-        return rv;
-
-    nppIface->version = mVersion;
-    nppIface->javaClass = mJavaClass;
+    NPError prv;
+    nsresult rv = CallNP_Initialize(&prv);
+    if (NS_OK != rv)
+        return NPERR_GENERIC_ERROR;
+    else if (NPERR_NO_ERROR != prv)
+        return prv;
 
-    // FIXME/cjones: /should/ dynamically allocate shim trampoline.
-    // but here we just HACK
-    nppIface->newp = Shim::NPP_New;
-    nppIface->destroy = Shim::NPP_Destroy;
-    nppIface->setwindow = Shim::NPP_SetWindow;
-    nppIface->newstream = Shim::NPP_NewStream;
-    nppIface->destroystream = Shim::NPP_DestroyStream;
-    nppIface->asfile = Shim::NPP_StreamAsFile;
-    nppIface->writeready = Shim::NPP_WriteReady;
-    nppIface->write = Shim::NPP_Write;
-    nppIface->print = Shim::NPP_Print;
-    nppIface->event = Shim::NPP_HandleEvent;
-    nppIface->urlnotify = Shim::NPP_URLNotify;
-    nppIface->getvalue = Shim::NPP_GetValue;
-    nppIface->setvalue = Shim::NPP_SetValue;
+    SetPluginFuncs(nppIface);
+    return NPERR_NO_ERROR;
+}
+#else
+NPError
+NPAPIPluginParent::NP_Initialize(const NPNetscapeFuncs* npnIface)
+{
+    _MOZ_LOG(__FUNCTION__);
+
+    NPError prv;
+    nsresult rv = CallNP_Initialize(&prv);
+    if (NS_OK != rv)
+        return rv;
+    else if (NPERR_NO_ERROR != prv)
+        return prv
 
     return NPERR_NO_ERROR;
 }
 
 NPError
+NPAPIPluginParent::NP_GetEntryPoints(NPPluginFuncs* nppIface)
+{
+    NS_ASSERTION(nppIface, "Null pointer!");
+
+    SetPluginFuncs(nppIface);
+    return NPERR_NO_ERROR;
+}
+#endif
+
+NPError
 NPAPIPluginParent::NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode,
                            int16_t argc, char* argn[], char* argv[],
                            NPSavedData* saved)
 {
     _MOZ_LOG(__FUNCTION__);
 
-    // create our wrapper instance
-    NPPInstanceParent* parentInstance = new NPPInstanceParent(mNPNIface);
-
     // create the instance on the other side
     StringArray names;
     StringArray values;
 
     for (int i = 0; i < argc; ++i) {
         names.push_back(argn[i]);
         values.push_back(argv[i]);
     }
 
-    NPError rv = mNpapi.NPP_New(pluginType,
-                                /*instance*/42,
-                                mode, names,
-                                values);
+    NPError prv;
+    NPPInstanceParent* parentInstance = static_cast<NPPInstanceParent*>(
+        CallNPPConstructor(pluginType,
+                           /*instance*/42,
+                           mode, names,
+                           values,
+                           &prv));
     printf ("[NPAPIPluginParent] %s: got return value %hd\n", __FUNCTION__,
-            rv);
+            prv);
 
-    if (NPERR_NO_ERROR != rv)
-        return rv;
-
+    if (NPERR_NO_ERROR != prv)
+        return prv;
+    NS_ASSERTION(parentInstance,
+                 "if there's no parentInstance, there should be an error");
 
     // FIXME/cjones: HACK ALERT!  kill this and manage through NPAPI
-    parentInstance->mNpp.SetChannel(mNpapi.HACK_getchannel_please());
-    mNpapi.HACK_npp = &(parentInstance->mNpp);
+//    parentInstance->mNpp.SetChannel(mNpapi.HACK_getchannel_please());
+//    mNpapi.HACK_npp = &(parentInstance->mNpp);
 
 
     instance->pdata = (void*) parentInstance;
-    return rv;
+    return prv;
 }
 
 // HACKS
 NPAPIPluginParent* NPAPIPluginParent::Shim::HACK_target;
 
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/NPAPIPluginParent.h
+++ b/dom/plugins/NPAPIPluginParent.h
@@ -36,16 +36,18 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef dom_plugins_NPAPIPluginParent_h
 #define dom_plugins_NPAPIPluginParent_h
 
 #include <cstring>
 
+#include "base/basictypes.h"
+
 #include "prlink.h"
 
 #include "npapi.h"
 #include "npfunctions.h"
 #include "nsplugindefs.h"
 
 #include "base/string_util.h"
 
@@ -69,49 +71,63 @@ namespace plugins {
  * This class implements the NPP API from the perspective of the rest
  * of Gecko, forwarding NPP calls along to the child process that is
  * actually running the plugin.
  *
  * This class /also/ implements a version of the NPN API, because the
  * child process needs to make these calls back into Gecko proper.
  * This class is responsible for "actually" making those function calls.
  */
-class NPAPIPluginParent : public NPAPIProtocol::Parent
+class NPAPIPluginParent : public NPAPIProtocolParent
 {
 private:
     typedef mozilla::SharedLibrary SharedLibrary;
-    typedef mozilla::ipc::String String;
-    typedef mozilla::ipc::StringArray StringArray;
+
+protected:
+    NPPProtocolParent* NPPConstructor(
+                const String& aMimeType,
+                const int& aHandle,
+                const uint16_t& aMode,
+                const StringArray& aNames,
+                const StringArray& aValues,
+                NPError* rv);
+
+    virtual nsresult NPPDestructor(
+                NPPProtocolParent* __a,
+                NPError* rv);
 
 public:
-    NPAPIPluginParent(const char* aFullPath);
+    NPAPIPluginParent(const char* aFilePath);
 
     virtual ~NPAPIPluginParent();
 
     /**
      * LoadModule
      *
      * Returns a SharedLibrary from which plugin symbols should be
      * resolved.  This may or may not launch a plugin child process,
      * and may or may not be very expensive.
      */
-    static SharedLibrary* LoadModule(const char* aFullPath,
+    static SharedLibrary* LoadModule(const char* aFilePath,
                                      PRLibrary* aLibrary);
 
-    // Implement the NPAPIProtocol::Parent interface
-    virtual void NPN_GetValue();
-
 private:
     void LaunchSubprocess();
 
+    void SetPluginFuncs(NPPluginFuncs* aFuncs);
+
     // Implement the module-level functions from NPAPI; these are
     // normally resolved directly from the DSO.
-     
+#ifdef OS_LINUX
     NPError NP_Initialize(const NPNetscapeFuncs* npnIface,
                           NPPluginFuncs* nppIface);
+#else
+    NPError NP_Initialize(const NPNetscapeFuncs* npnIface);
+    NPError NP_GetEntryPoints(NPPluginFuncs* nppIface);
+#endif
 
     NPError NP_Shutdown()
     {
         // FIXME/cjones: shut down all our instances, and kill
         // off the child process
 
         _MOZ_LOG(__FUNCTION__);
         return 1;
@@ -461,22 +477,19 @@ private:
         ScriptableRemoveProperty,
         ScriptableEnumerate,
         ScriptableConstruct
     };
 #endif
 
 
 private:
-    const char* mFullPath;
+    const char* mFilePath;
     PluginProcessParent mSubprocess;
-    NPAPIProtocolParent mNpapi;
     const NPNetscapeFuncs* mNPNIface;
-    uint16_t mVersion;
-    void* mJavaClass;
 
     mozilla::Monitor mMonitor;
 
     // NPObject interface
 
 #if 0
     struct PluginNPObject : NPObject
     {
@@ -523,55 +536,72 @@ private:
             mTarget = 0;
         }
 
         virtual symbol_type
         FindSymbol(const char* aSymbolName)
         {
             if (!strcmp("NP_Shutdown", aSymbolName))
                 return (symbol_type) NP_Shutdown;
-            else if (!strcmp("NP_Initialize", aSymbolName))
+            if (!strcmp("NP_Initialize", aSymbolName))
                 return (symbol_type) NP_Initialize;
-            else if (!strcmp("NP_GetMIMEDescription", aSymbolName))
+            if (!strcmp("NP_GetMIMEDescription", aSymbolName))
                 return (symbol_type) NP_GetMIMEDescription;
-            else if (!strcmp("NP_GetValue", aSymbolName))
+            if (!strcmp("NP_GetValue", aSymbolName))
                 return (symbol_type) NP_GetValue;
-            else {
-                _MOZ_LOG("WARNING! FAILED TO FIND SYMBOL");
-                return 0;
-            }
+#ifdef OS_WINDOWS
+            if (!strcmp("NP_GetEntryPoints", aSymbolName))
+                return (symbol_type) NP_GetEntryPoints;
+#endif
+
+            _MOZ_LOG("WARNING! FAILED TO FIND SYMBOL");
+            return 0;
         }
 
         virtual function_type
         FindFunctionSymbol(const char* aSymbolName)
         {
             if (!strcmp("NP_Shutdown", aSymbolName))
                 return (function_type) NP_Shutdown;
-            else if (!strcmp("NP_Initialize", aSymbolName))
+            if (!strcmp("NP_Initialize", aSymbolName))
                 return (function_type) NP_Initialize;
-            else if (!strcmp("NP_GetMIMEDescription", aSymbolName))
+            if (!strcmp("NP_GetMIMEDescription", aSymbolName))
                 return (function_type) NP_GetMIMEDescription;
-            else if (!strcmp("NP_GetValue", aSymbolName))
+            if (!strcmp("NP_GetValue", aSymbolName))
                 return (function_type) NP_GetValue;
-            else {
-                _MOZ_LOG("WARNING! FAILED TO FIND SYMBOL");
-                return 0;
-            }
+#ifdef OS_WINDOWS
+            if (!strcmp("NP_GetEntryPoints", aSymbolName))
+                return (function_type) NP_GetEntryPoints;
+#endif
+
+            _MOZ_LOG("WARNING! FAILED TO FIND SYMBOL");
+            return 0;
         }
 
     private:
         NPAPIPluginParent* mTarget;
 
         // HACKS HACKS HACKS! from here on down
 
+#ifdef OS_LINUX
         static NPError NP_Initialize(const NPNetscapeFuncs* npnIface,
                                      NPPluginFuncs* nppIface)
         {
             return HACK_target->NP_Initialize(npnIface, nppIface);
         }
+#else
+        static NPError NP_Initialize(const NPNetscapeFuncs* npnIface)
+        {
+            return HACK_target->NP_Initialize(npnIface);
+        }
+        static NPError NP_GetEntryPoints(NPPluginFuncs* nppIface)
+        {
+            return HACK_target->NP_GetEntryPoints(nppIface);
+        }
+#endif
         static NPError NP_Shutdown()
         {
             return HACK_target->NP_Shutdown();
         }
         static char* NP_GetPluginVersion()
         {
             return HACK_target->NP_GetPluginVersion();
         }
--- a/dom/plugins/NPAPIProtocol.h
+++ b/dom/plugins/NPAPIProtocol.h
@@ -1,254 +1,264 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Plugin App.
- *
- * The Initial Developer of the Original Code is
- *   Chris Jones <jones.chris.g@gmail.com>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * 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 ***** */
+//
+// Automatically generated by ipdlc.
+// Edit at your own risk
+//
 
-#ifndef dom_plugins_NPAPIProtocol_h
-#define dom_plugins_NPAPIProtocol_h 1
+#ifndef mozilla_plugins_NPAPIProtocol_h
+#define mozilla_plugins_NPAPIProtocol_h
 
-#include "npapi.h"
-
+#include "nscore.h"
 #include "IPC/IPCMessageUtils.h"
 #include "mozilla/ipc/MessageTypes.h"
+#include "mozilla/ipc/ProtocolUtils.h"
+#include "npapi.h"
+#include "mozilla/plugins/NPPProtocol.h"
 
 namespace mozilla {
 namespace plugins {
-//-----------------------------------------------------------------------------
-
-class NS_FINAL_CLASS NPAPIProtocol
-{
-public:
-    /**
-     * These methods mirror the messages that are sent from
-     * Child-->Parent.
-     *
-     * A class in the parent must implement this interface.
-     *
-     * The child has access to this interface through an
-     * NPAPIProtocolChildImpl instace.
-     */
-    /*interface*/ class Parent
-    {
-    protected:
-        Parent() { }
-        virtual ~Parent() { }
-        Parent(const Parent&);
-        Parent& operator=(const Parent&);
-    };
+namespace NPAPIProtocol {
 
-    /**
-     * These methods mirror the messages that are sent from
-     * Parent-->Child.
-     *
-     * A class in the child must implement this interface.
-     *
-     * The parent has access to this interface through an
-     * NPAPIProtocolParentImpl instace.
-     */
-    /*interface*/ class Child
-    {
-    public:
-        virtual NPError NP_Initialize() = 0;
 
-        virtual NPError NPP_New(const mozilla::ipc::String& aMimeType,
-                                /*const NPP::Parent**/ const int& aHandle,
-                                const uint16_t& aMode,
-                                const mozilla::ipc::StringArray& aNames,
-                                const mozilla::ipc::StringArray& aValues) = 0;
-
-        virtual void NPP_Destroy(/*...*/) = 0;
-
-    protected:
-        Child() { }
-        virtual ~Child() { }
-        Child(const Child&);
-        Child& operator=(const Child&);
-    };
-
-    enum State {
-        StateStart = 0,
-
-        StateInitializing = StateStart,
-        StateInitialized,
-        StateNotScriptable,
-        StateScriptable,
-
-        // placeholder
-        StateLast
-    };
-
-    // FIXME add transition table
-
-private:
-    NPAPIProtocol();
-    virtual ~NPAPIProtocol() = 0;
-    NPAPIProtocol& operator=(const NPAPIProtocol&);
-    // FIXME/cjones state to allow dynamic checking?
+enum State {
 };
 
-//-----------------------------------------------------------------------------
-// Start NPAPI protocol messages
-//
+enum NPAPIProtocolMsgType {
+    NPAPIProtocolStart = NPAPIProtocolMsgStart << 12,
+    NPAPIProtocolPreStart = (NPAPIProtocolMsgStart << 12) - 1,
+    Msg_NP_Initialize__ID,
+    Reply_NP_Initialize__ID,
+    Msg_NPPConstructor__ID,
+    Reply_NPPConstructor__ID,
+    Msg_NPPDestructor__ID,
+    Reply_NPPDestructor__ID,
+    NPAPIProtocolEnd
+};
+class Msg_NP_Initialize :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-// FIXME/cjones: we should generate code for the "Param" serialization and
-// deserialization of message parameters, so as to avoid the macro/template
-// garbage that impedes debugging.  the amount of generated code should be
-// approximately the same, unless we have a lot of messages with the same
-// parameters.  e.g., Msg1(int, int), Msg2(int, int) ... it's a trade off
-// between code size and debugging ease
+public:
+    enum {
+        ID = Msg_NP_Initialize__ID
+    };
+    Msg_NP_Initialize() :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+    }
 
-// messages that are sent from parent to the child.  a "reply" to a child
-// message is sent parent to child (ChildToParentMsg_Reply...)
-enum NPAPI_ParentToChildMsgType {
-    NPAPI_ParentToChildStart = NPAPI_ParentToChildMsgStart << 12,
-    NPAPI_ParentToChildPreStart = (NPAPI_ParentToChildMsgStart << 12) - 1,
+    static bool Read(const Message* msg)
+    {
+        return true;
+    }
+};
+class Reply_NP_Initialize :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-    NPAPI_ParentToChildMsg_NP_Initialize__ID,
-    NPAPI_ParentToChildMsg_NPP_New__ID,
-    NPAPI_ParentToChildMsg_NPP_Destroy__ID,
+public:
+    enum {
+        ID = Reply_NP_Initialize__ID
+    };
+    Reply_NP_Initialize(const NPError& rv) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, rv);
+    }
 
-    NPAPI_ParentToChildEnd
-};
+    static bool Read(
+                const Message* msg,
+                NPError* rv)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), rv))) {
+            return false;
+        }
 
-class NPAPI_ParentToChildMsg_NP_Initialize : public IPC::Message
+        return true;
+    }
+};
+class Msg_NPPConstructor :
+    public IPC::Message
 {
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
 public:
-    enum { ID = NPAPI_ParentToChildMsg_NP_Initialize__ID };
-    NPAPI_ParentToChildMsg_NP_Initialize() :
-        IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL)
-    {}
+    enum {
+        ID = Msg_NPPConstructor__ID
+    };
+    Msg_NPPConstructor(
+                const String& aMimeType,
+                const int& aHandle,
+                const uint16_t& aMode,
+                const StringArray& aNames,
+                const StringArray& aValues,
+                const mozilla::ipc::ActorHandle& __ah) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, aMimeType);
+        IPC::WriteParam(this, aHandle);
+        IPC::WriteParam(this, aMode);
+        IPC::WriteParam(this, aNames);
+        IPC::WriteParam(this, aValues);
+        IPC::WriteParam(this, __ah);
+    }
+
+    static bool Read(
+                const Message* msg,
+                String* aMimeType,
+                int* aHandle,
+                uint16_t* aMode,
+                StringArray* aNames,
+                StringArray* aValues,
+                mozilla::ipc::ActorHandle* __ah)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), aMimeType))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), aHandle))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), aMode))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), aNames))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), aValues))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), __ah))) {
+            return false;
+        }
+
+        return true;
+    }
 };
+class Reply_NPPConstructor :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-class NPAPI_ParentToChildMsg_NPP_New :
-        public IPC::MessageWithTuple<
-    Tuple5<mozilla::ipc::String, int, uint16_t, mozilla::ipc::StringArray, mozilla::ipc::StringArray> >
-{
 public:
-    enum { ID = NPAPI_ParentToChildMsg_NPP_New__ID };
-    NPAPI_ParentToChildMsg_NPP_New(const mozilla::ipc::String& aMimeType,
-                                   /*const NPP::Parent*& aHandle,*/
-                                   const int& aHandle,
-                                   const uint16_t& aMode,
-                                   const mozilla::ipc::StringArray& aNames,
-                                   const mozilla::ipc::StringArray& aValues) :
-        IPC::MessageWithTuple<
-        Tuple5<mozilla::ipc::String, int, uint16_t, mozilla::ipc::StringArray, mozilla::ipc::StringArray> >(
-            MSG_ROUTING_CONTROL, ID, MakeTuple(aMimeType,
-                                               aHandle,
-                                               aMode,
-                                               aNames,
-                                               aValues))
-    {}
+    enum {
+        ID = Reply_NPPConstructor__ID
+    };
+    Reply_NPPConstructor(
+                const NPError& rv,
+                const mozilla::ipc::ActorHandle& __ah) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, rv);
+        IPC::WriteParam(this, __ah);
+    }
+
+    static bool Read(
+                const Message* msg,
+                NPError* rv,
+                mozilla::ipc::ActorHandle* __ah)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), rv))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), __ah))) {
+            return false;
+        }
+
+        return true;
+    }
 };
+class Msg_NPPDestructor :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-class NPAPI_ParentToChildMsg_NPP_Destroy : public IPC::Message {
 public:
-    enum { ID = NPAPI_ParentToChildMsg_NPP_Destroy__ID };
-    NPAPI_ParentToChildMsg_NPP_Destroy() :
-        IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL)
-    {}
+    enum {
+        ID = Msg_NPPDestructor__ID
+    };
+    Msg_NPPDestructor(const mozilla::ipc::ActorHandle& __ah) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, __ah);
+    }
+
+    static bool Read(
+                const Message* msg,
+                mozilla::ipc::ActorHandle* __ah)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), __ah))) {
+            return false;
+        }
+
+        return true;
+    }
+};
+class Reply_NPPDestructor :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
+public:
+    enum {
+        ID = Reply_NPPDestructor__ID
+    };
+    Reply_NPPDestructor(
+                const NPError& rv,
+                const mozilla::ipc::ActorHandle& __ah) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, rv);
+        IPC::WriteParam(this, __ah);
+    }
+
+    static bool Read(
+                const Message* msg,
+                NPError* rv,
+                mozilla::ipc::ActorHandle* __ah)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), rv))) {
+            return false;
+        }
+
+        if (!(IPC::ReadParam(msg, &(iter), __ah))) {
+            return false;
+        }
+
+        return true;
+    }
 };
 
 
-// messages from child->parent
-enum NPAPI_ChildToParentMsgType {
-    NPAPI_ChildToParentStart = NPAPI_ChildToParentMsgStart << 12,
-    NPAPI_ChildToParentPreStart = (NPAPI_ChildToParentMsgStart << 12) - 1,
-
-    NPAPI_ChildToParentMsg_Reply_NP_Initialize__ID,
-
-    NPAPI_ChildToParentMsg_Reply_NPP_New__ID,
-    NPAPI_ChildToParentMsg_Reply_NPP_Destroy__ID,
-
-    NPAPI_ChildToParentEnd
-};
-
-class NPAPI_ChildToParentMsg_Reply_NP_Initialize :
-        public IPC::MessageWithTuple<NPError>
-{
-public:
-    enum { ID = NPAPI_ChildToParentMsg_Reply_NP_Initialize__ID };
-    NPAPI_ChildToParentMsg_Reply_NP_Initialize(const NPError& arg1) :
-        IPC::MessageWithTuple<NPError>(MSG_ROUTING_CONTROL, ID, arg1)
-    {}
-};
-
-class NPAPI_ChildToParentMsg_Reply_NPP_New :
-        public IPC::MessageWithTuple<NPError>
-{
-public:
-    enum { ID = NPAPI_ChildToParentMsg_Reply_NPP_New__ID };
-    NPAPI_ChildToParentMsg_Reply_NPP_New(const NPError& arg1) :
-        IPC::MessageWithTuple<NPError>(MSG_ROUTING_CONTROL, ID, arg1)
-    {}
-};
-
-class NPAPI_ChildToParentMsg_Reply_NPP_Destroy : public IPC::Message
-{
-public:
-    enum { ID = NPAPI_ChildToParentMsg_Reply_NPP_Destroy__ID };
-    NPAPI_ChildToParentMsg_Reply_NPP_Destroy()
-        : IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL)
-    {}
-};
-
-
-#if 0
-// (note to self: see plugin_messages.h for how to define msg with > 6 params)
-class FOO_5PARAMS :
-        public IPC::MessageWithTuple<
-    Tuple5<NPError, int, bool, std::string, short> >
-{
-public:
-    enum { ID = FOO_5PARAMS__ID };
-    FOO_5PARAMS(const NPError& arg1,
-                const int& arg2,
-                const bool& arg3,
-                const std::string& arg4,
-                const short& arg5) :
-        IPC::MessageWithTuple<
-        Tuple5<NPError, int, bool, std::string, short> >(
-            MSG_ROUTING_CONTROL, ID, MakeTuple(arg1, arg2, arg3, arg4, arg5))
-    {}
-};
-#endif
-
-
+} // namespace NPAPIProtocol
 } // namespace plugins
 } // namespace mozilla
 
-
-#endif  // ifndef dom_plugins_NPAPIProtocol_h
+#endif // ifndef mozilla_plugins_NPAPIProtocol_h
--- a/dom/plugins/NPAPIProtocolChild.h
+++ b/dom/plugins/NPAPIProtocolChild.h
@@ -1,184 +1,198 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Plugin App.
- *
- * The Initial Developer of the Original Code is
- *   Chris Jones <jones.chris.g@gmail.com>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * 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 ***** */
+//
+// Automatically generated by ipdlc.
+// Edit at your own risk
+//
 
-#ifndef dom_plugins_NPAPIProtocolChildImpl_h
-#define dom_plugins_NPAPIProtocolChildImpl_h 1
-
-#include "chrome/common/ipc_channel.h"
-#include "chrome/common/ipc_message.h"
-
-#include "mozilla/ipc/RPCChannel.h"
-#include "mozilla/plugins/NPAPIProtocol.h"
-
-// FIXME/cjones: HACK ALERT!!!
-#include "mozilla/plugins/NPPProtocolChild.h"
-
+#ifndef mozilla_plugins_NPAPIProtocolChild_h
+#define mozilla_plugins_NPAPIProtocolChild_h
 
-#ifdef DEBUG
-#  undef _MSG_LOG0
-#  undef _MSG_LOG
-
-#  define _MSG_LOG0(fmt, ...)                                       \
-    do {                                                            \
-        printf("[NPAPIProtocolChild] %s "fmt"\n", __VA_ARGS__);     \
-    } while(0)
-
-#  define _MSG_LOG(fmt, ...)                    \
-    _MSG_LOG0(fmt, __FUNCTION__,## __VA_ARGS__)
-#else
-#  define _MSG_LOG(fmt, ...)
-#endif
+#include "mozilla/plugins/NPAPIProtocol.h"
+#include "mozilla/plugins/NPPProtocolChild.h"
+#include "base/id_map.h"
+#include "mozilla/ipc/RPCChannel.h"
 
 namespace mozilla {
 namespace plugins {
-//-----------------------------------------------------------------------------
+
+
+class /*NS_ABSTRACT_CLASS*/ NPAPIProtocolChild :
+    public mozilla::ipc::RPCChannel::Listener,
+    public mozilla::ipc::IProtocolManager
+{
+protected:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-/**
- * The child-side of the protocol.  Inheriting from ::Parent looks
- * odd, but remember that this is the interface that code in the
- * child process sees.
- */
-class NS_FINAL_CLASS NPAPIProtocolChild : 
-        public NPAPIProtocol::Parent,
-        public mozilla::ipc::RPCChannel::Listener
-{
+    virtual nsresult AnswerNP_Initialize(NPError* rv) = 0;
+    virtual NPPProtocolChild* NPPConstructor(
+                const String& aMimeType,
+                const int& aHandle,
+                const uint16_t& aMode,
+                const StringArray& aNames,
+                const StringArray& aValues,
+                NPError* rv) = 0;
+    virtual nsresult NPPDestructor(
+                NPPProtocolChild* __a,
+                NPError* rv) = 0;
+
 private:
     typedef IPC::Message Message;
-    typedef mozilla::ipc::RPCChannel RPCChannel;
+    typedef mozilla::ipc::RPCChannel Channel;
 
 public:
-    NPAPIProtocolChild(NPAPIProtocol::Child* aChild) :
-        mChild(aChild),
-        mRpc(this)
+    NPAPIProtocolChild() :
+        mChannel(this)
     {
     }
 
-    ~NPAPIProtocolChild()
+    virtual ~NPAPIProtocolChild()
     {
     }
 
-    bool Open(IPC::Channel* aChannel, MessageLoop* aIOLoop)
+    bool Open(
+                IPC::Channel* aChannel,
+                MessageLoop* aThread = 0)
     {
-        return mRpc.Open(aChannel, aIOLoop);
+        return mChannel.Open(aChannel, aThread);
     }
 
     void Close()
     {
-        mRpc.Close();
-    }
-
-    void NextState(NPAPIProtocol::State aNextState)
-    {
-        
+        mChannel.Close();
     }
 
-    // Implement the parent interface
-    virtual void NPN_GetValue(/*...*/)
+    virtual Result OnMessageReceived(const Message& msg)
     {
-        _MSG_LOG("outcall NPN_GetValue()");
-        // mRpc->Send(...);
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
     }
-    // ...
-
-    // Implement the RPCChannel::Listener interface
-    virtual Result OnCallReceived(const Message& msg, Message*& reply)
-    {
-        switch(msg.type()) {
-        case NPAPI_ParentToChildMsg_NP_Initialize__ID: {
-            _MSG_LOG("incall NP_Initialize()");
-
-            NPError val0 = mChild->NP_Initialize();
-            reply = new NPAPI_ChildToParentMsg_Reply_NP_Initialize(val0);
-            reply->set_reply();
-            return MsgProcessed;
-        }
 
-        case NPAPI_ParentToChildMsg_NPP_New__ID: {
-            mozilla::ipc::String aMimeType;
-            int aHandle;
-            uint16_t aMode;
-            mozilla::ipc::StringArray aNames;
-            mozilla::ipc::StringArray aValues;
-            
-            NPAPI_ParentToChildMsg_NPP_New::Param p;
-            NS_ASSERTION(NPAPI_ParentToChildMsg_NPP_New::Read(&msg, &p),
-                         "bad types in NPP_New() msg");
-            aMimeType = p.a;
-            aHandle = p.b;
-            aMode = p.c;
-            aNames = p.d;
-            aValues = p.e;
-
-            _MSG_LOG("incall NPP_New(%s, %d, %d, <vec>, <vec>)",
-                     aMimeType.c_str(), aHandle, aMode);
-
-            NPError val0 = mChild->NPP_New(aMimeType,
-                                           aHandle,
-                                           aMode,
-                                           aNames,
-                                           aValues);
-            reply = new NPAPI_ChildToParentMsg_Reply_NPP_New(val0);
-            reply->set_reply();
-            return MsgProcessed;
-        }
-
+    virtual Result OnMessageReceived(
+                const Message& msg,
+                Message*& reply)
+    {
+        switch (msg.type()) {
         default:
-            // FIXME/cjones: HACK ALERT! use routing, do checks, etc.
-            return HACK_npp->OnCallReceived(msg, reply);
-            
-            
-//            return MsgNotKnown;
+            {
+                return MsgNotKnown;
+            }
         }
     }
 
-    // FIXME/cjones: kill this and manage through NPAPI
-    RPCChannel* HACK_getchannel_please() { return &mRpc; }
-    NPPProtocolChild* HACK_npp;
-    // FIXME
+    virtual Result OnCallReceived(
+                const Message& msg,
+                Message*& reply)
+    {
+        int __route;
+        __route = msg.routing_id();
+        if ((MSG_ROUTING_CONTROL) != (__route)) {
+            Channel::Listener* __routed;
+            __routed = Lookup(__route);
+            if (!(__routed)) {
+                return MsgRouteError;
+            }
+            return __routed->OnCallReceived(msg, reply);
+        }
+
+        switch (msg.type()) {
+        case NPAPIProtocol::Msg_NP_Initialize__ID:
+            {
+                NPError rv;
+
+                if (!(NPAPIProtocol::Msg_NP_Initialize::Read(&(msg)))) {
+                    return MsgPayloadError;
+                }
+                if (AnswerNP_Initialize(&(rv))) {
+                    return MsgValueError;
+                }
+
+                reply = new NPAPIProtocol::Reply_NP_Initialize(rv);
+                reply->set_reply();
+                return MsgProcessed;
+            }
+        case NPAPIProtocol::Msg_NPPConstructor__ID:
+            {
+                String aMimeType;
+                int aHandle;
+                uint16_t aMode;
+                StringArray aNames;
+                StringArray aValues;
+                NPError rv;
+                mozilla::ipc::ActorHandle __ah;
+
+                if (!(NPAPIProtocol::Msg_NPPConstructor::Read(&(msg), &(aMimeType), &(aHandle), &(aMode), &(aNames), &(aValues), &(__ah)))) {
+                    return MsgPayloadError;
+                }
+
+                NPPProtocolChild* __a;
+                __a = NPPConstructor(aMimeType, aHandle, aMode, aNames, aValues, &(rv));
+                if (!(__a)) {
+                    return MsgValueError;
+                }
 
+                __ah.mChildId = __a->mId = Register(__a);
+                __a->mPeerId = __ah.mParentId;
+                __a->mManager = this;
+                __a->mChannel = &(mChannel);
+
+                reply = new NPAPIProtocol::Reply_NPPConstructor(rv, __ah);
+                reply->set_reply();
+                return MsgProcessed;
+            }
+        case NPAPIProtocol::Msg_NPPDestructor__ID:
+            {
+                NPError rv;
+                mozilla::ipc::ActorHandle __ah;
+
+                if (!(NPAPIProtocol::Msg_NPPDestructor::Read(&(msg), &(__ah)))) {
+                    return MsgPayloadError;
+                }
+                NPPProtocolChild* __a;
+                __a = dynamic_cast<NPPProtocolChild*>(Lookup(__ah.mChildId));
+                if (!(__a)) {
+                    return MsgValueError;
+                }
+                if (NPPDestructor(__a, &(rv))) {
+                    return MsgValueError;
+                }
+                Unregister(__ah.mChildId);
+                __ah.mChildId = -1;
+
+                reply = new NPAPIProtocol::Reply_NPPDestructor(rv, __ah);
+                reply->set_reply();
+                return MsgProcessed;
+            }
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
+    }
+
+    virtual int32 Register(Channel::Listener* aRouted)
+    {
+        return mActorMap.Add(aRouted);
+    }
+    virtual Channel::Listener* Lookup(int32 aId)
+    {
+        return mActorMap.Lookup(aId);
+    }
+    virtual void Unregister(int32 aId)
+    {
+        return mActorMap.Remove(aId);
+    }
 
 private:
-    NPAPIProtocol::Child* mChild;
-    mozilla::ipc::RPCChannel mRpc;
+    Channel mChannel;
+    IDMap<Channel::Listener> mActorMap;
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
-#endif  // ifndef dom_plugins_NPAPIProtocolChildImpl_h
+#endif // ifndef mozilla_plugins_NPAPIProtocolChild_h
--- a/dom/plugins/NPAPIProtocolParent.h
+++ b/dom/plugins/NPAPIProtocolParent.h
@@ -1,196 +1,212 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Plugin App.
- *
- * The Initial Developer of the Original Code is
- *   Chris Jones <jones.chris.g@gmail.com>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * 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 ***** */
+//
+// Automatically generated by ipdlc.
+// Edit at your own risk
+//
 
-#ifndef dom_plugins_NPAPIProtocolParentImpl_h
-#define dom_plugins_NPAPIProtocolParentImpl_h 1
-
-#include "chrome/common/ipc_channel.h"
-#include "chrome/common/ipc_message.h"
-
-#include "nsDebug.h"
-
-#include "mozilla/ipc/RPCChannel.h"
-#include "mozilla/plugins/NPAPIProtocol.h"
-
-// FIXME/cjones HACK ALERT!!!
-#include "mozilla/plugins/NPPProtocolParent.h"
+#ifndef mozilla_plugins_NPAPIProtocolParent_h
+#define mozilla_plugins_NPAPIProtocolParent_h
 
-#ifdef DEBUG
-#  undef _MSG_LOG0
-#  undef _MSG_LOG
-
-#  define _MSG_LOG0(fmt, ...)                                       \
-    do {                                                            \
-        printf("[NPAPIProtocolParent] %s "fmt"\n", __VA_ARGS__);    \
-    } while(0)
-
-#  define _MSG_LOG(fmt, ...)                    \
-    _MSG_LOG0(fmt, __FUNCTION__,## __VA_ARGS__)
-#else
-#  define _MSG_LOG(fmt, ...)
-#endif
+#include "mozilla/plugins/NPAPIProtocol.h"
+#include "mozilla/plugins/NPPProtocolParent.h"
+#include "base/id_map.h"
+#include "mozilla/ipc/RPCChannel.h"
 
 namespace mozilla {
 namespace plugins {
-//-----------------------------------------------------------------------------
+
+
+class /*NS_ABSTRACT_CLASS*/ NPAPIProtocolParent :
+    public mozilla::ipc::RPCChannel::Listener,
+    public mozilla::ipc::IProtocolManager
+{
+protected:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-/**
- * The parent-side of the protocol.  Inheriting from ::Child looks
- * odd, but remember that this is the interface that code in the
- * parent process sees.
- */
-class NS_FINAL_CLASS NPAPIProtocolParent :
-        public NPAPIProtocol::Child,
-        public mozilla::ipc::RPCChannel::Listener
-{
+    virtual NPPProtocolParent* NPPConstructor(
+                const String& aMimeType,
+                const int& aHandle,
+                const uint16_t& aMode,
+                const StringArray& aNames,
+                const StringArray& aValues,
+                NPError* rv) = 0;
+    virtual nsresult NPPDestructor(
+                NPPProtocolParent* __a,
+                NPError* rv) = 0;
+
 private:
     typedef IPC::Message Message;
-    typedef mozilla::ipc::RPCChannel RPCChannel;
+    typedef mozilla::ipc::RPCChannel Channel;
 
 public:
-    NPAPIProtocolParent(NPAPIProtocol::Parent* aParent) :
-        mParent(aParent),
-        mRpc(this)
+    NPAPIProtocolParent() :
+        mChannel(this)
     {
     }
 
     virtual ~NPAPIProtocolParent()
     {
     }
 
-    bool Open(IPC::Channel* aChannel)
+    bool Open(
+                IPC::Channel* aChannel,
+                MessageLoop* aThread = 0)
     {
-        return mRpc.Open(aChannel);
+        return mChannel.Open(aChannel, aThread);
     }
 
     void Close()
     {
-        mRpc.Close();
-    }
-
-    void NextState(NPAPIProtocol::State aNextState)
-    {
-        // FIXME impl
+        mChannel.Close();
     }
 
-    // Implement the child interface
-    virtual NPError NP_Initialize()
+    nsresult CallNP_Initialize(NPError* rv)
     {
-        _MSG_LOG("outcall NP_Initialize()");
-
-        Message reply;
-
-        mRpc.Call(new NPAPI_ParentToChildMsg_NP_Initialize(),
-                  &reply);
-        NS_ASSERTION(NPAPI_ChildToParentMsg_Reply_NP_Initialize__ID
-                     == reply.type(),
-                     "wrong reply msg to NP_Initialize()");
-        
-        NPError ret0;
-        NS_ASSERTION(NPAPI_ChildToParentMsg_Reply_NP_Initialize
-                     ::Read(&reply, &ret0),
-                     "bad types in reply msg to NP_Initialize()");
-
-        return ret0;
+        Message __reply;
+        Message* __msg;
+        __msg = new NPAPIProtocol::Msg_NP_Initialize();
+        __msg->set_routing_id(MSG_ROUTING_CONTROL);
+        if (!(mChannel.Call(__msg, &(__reply)))) {
+            return NS_ERROR_FAILURE;
+        }
+        if (!(NPAPIProtocol::Reply_NP_Initialize::Read(&(__reply), rv))) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+        return NS_OK;
     }
 
-    virtual NPError NPP_New(const mozilla::ipc::String& aMimeType,
-                            /*const NPP::Parent* aHandle,*/ const int& aHandle,
-                            const uint16_t& aMode,
-                            const mozilla::ipc::StringArray& aNames,
-                            const mozilla::ipc::StringArray& aValues)
+    NPPProtocolParent* CallNPPConstructor(
+                const String& aMimeType,
+                const int& aHandle,
+                const uint16_t& aMode,
+                const StringArray& aNames,
+                const StringArray& aValues,
+                NPError* rv)
     {
-        _MSG_LOG("outcall NPP_New(%s, %hd, %hd, <vec>, <vec>)",
-                 aMimeType.c_str(), aHandle, aMode);
-
-        Message reply;
+        NPPProtocolParent* __a;
+        __a = NPPConstructor(aMimeType, aHandle, aMode, aNames, aValues, rv);
+        if (!(__a)) {
+            return 0;
+        }
+        __a->mId = Register(__a);
+        mozilla::ipc::ActorHandle __ah;
+        __ah.mParentId = __a->mId;
 
-        mRpc.Call(new NPAPI_ParentToChildMsg_NPP_New(aMimeType,
-                                                     aHandle,
-                                                     aMode,
-                                                     aNames,
-                                                     aValues),
-                  &reply);
-        NS_ASSERTION(NPAPI_ChildToParentMsg_Reply_NPP_New__ID
-                     == reply.type(),
-                     "wrong reply msg to NPP_New()");
-
-        NPError ret0;
-        NS_ASSERTION(NPAPI_ChildToParentMsg_Reply_NPP_New
-                     ::Read(&reply, &ret0),
-                     "bad types in reply msg to NPP_New()");
-
-        return ret0;
+        Message __reply;
+        Message* __msg;
+        __msg = new NPAPIProtocol::Msg_NPPConstructor(aMimeType, aHandle, aMode, aNames, aValues, __ah);
+        __msg->set_routing_id(MSG_ROUTING_CONTROL);
+        if (!(mChannel.Call(__msg, &(__reply)))) {
+            return 0;
+        }
+        if (!(NPAPIProtocol::Reply_NPPConstructor::Read(&(__reply), rv, &(__ah)))) {
+            return 0;
+        }
+        __a->mPeerId = __ah.mChildId;
+        __a->mManager = this;
+        __a->mChannel = &(mChannel);
+        return __a;
     }
 
-    virtual void NPP_Destroy()
+    nsresult CallNPPDestructor(
+                NPPProtocolParent* __a,
+                NPError* rv)
     {
-        _MSG_LOG("outcall NPP_New()");
-    }
-    // ...
+        if (!(__a)) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+        NPPProtocolParent* __b;
+        __b = dynamic_cast<NPPProtocolParent*>(Lookup(__a->mId));
+        if ((__a) != (__b)) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+
+        mozilla::ipc::ActorHandle __ah;
+        __ah.mParentId = __a->mId;
+        __ah.mChildId = __a->mPeerId;
 
-    // Implement the RPCChannel::Listener interface
-    virtual Result OnCallReceived(const Message& msg, Message*& reply)
+        Message __reply;
+        Message* __msg;
+        __msg = new NPAPIProtocol::Msg_NPPDestructor(__ah);
+        __msg->set_routing_id(MSG_ROUTING_CONTROL);
+        if (!(mChannel.Call(__msg, &(__reply)))) {
+            return NS_ERROR_FAILURE;
+        }
+        if (!(NPAPIProtocol::Reply_NPPDestructor::Read(&(__reply), rv, &(__ah)))) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+        Unregister(__a->mId);
+        __a->mId = -1;
+        __a->mManager = 0;
+        __a->mPeerId = -1;
+        return NS_OK;
+    }
+
+    virtual Result OnMessageReceived(const Message& msg)
     {
-        switch(msg.type()) {
+        switch (msg.type()) {
         default:
-            // FIXME/cjones: HACK ALERT! use routing, do checks, etc.
-            return HACK_npp->OnCallReceived(msg, reply);
-
-
-//            return MsgNotKnown;
+            {
+                return MsgNotKnown;
+            }
         }
     }
 
-    // FIXME/cjones: kill this and manage through NPAPI
-    RPCChannel* HACK_getchannel_please() { return &mRpc; }
-    NPPProtocolParent* HACK_npp;
-    // FIXME
+    virtual Result OnMessageReceived(
+                const Message& msg,
+                Message*& reply)
+    {
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
+    }
 
+    virtual Result OnCallReceived(
+                const Message& msg,
+                Message*& reply)
+    {
+        int __route;
+        __route = msg.routing_id();
+        if ((MSG_ROUTING_CONTROL) != (__route)) {
+            Channel::Listener* __routed;
+            __routed = Lookup(__route);
+            if (!(__routed)) {
+                return MsgRouteError;
+            }
+            return __routed->OnCallReceived(msg, reply);
+        }
+
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
+    }
+
+    virtual int32 Register(Channel::Listener* aRouted)
+    {
+        return mActorMap.Add(aRouted);
+    }
+    virtual Channel::Listener* Lookup(int32 aId)
+    {
+        return mActorMap.Lookup(aId);
+    }
+    virtual void Unregister(int32 aId)
+    {
+        return mActorMap.Remove(aId);
+    }
 
 private:
-    NPAPIProtocol::Parent* mParent;
-    RPCChannel mRpc;
-    NPAPIProtocol::State mState;
+    Channel mChannel;
+    IDMap<Channel::Listener> mActorMap;
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
-#endif  // ifndef dom_plugins_NPAPIProtocolParentImpl_h
+#endif // ifndef mozilla_plugins_NPAPIProtocolParent_h
--- a/dom/plugins/NPObjectProtocolChild.h
+++ b/dom/plugins/NPObjectProtocolChild.h
@@ -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 ***** */
 
 #ifndef NPObjectProtocolChild_h
 #define NPObjectProtocolChild_h 1
 
+#include "base/basictypes.h"
 #include "mozilla/plugins/NPRuntimeBase.h"
 
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
 class NPObjectProtocolChild
 {
--- a/dom/plugins/NPPInstanceChild.cpp
+++ b/dom/plugins/NPPInstanceChild.cpp
@@ -31,23 +31,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 "NPPInstanceChild.h"
+
+#ifdef OS_LINUX
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #include <gdk/gdk.h>
-
 #include "gtk2xtbin.h"
-
-#include "NPPInstanceChild.h"
+#endif
 
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
 static const char*
 NPNVariableToString(NPNVariable aVar)
 {
@@ -81,80 +82,97 @@ NPNVariableToString(NPNVariable aVar)
 }
 
 NPError
 NPPInstanceChild::NPN_GetValue(NPNVariable aVar, void* aValue)
 {
     printf ("[NPPInstanceChild] NPN_GetValue(%s)\n",
             NPNVariableToString(aVar));
 
-#ifdef OS_LINUX
-    // FIXME/cjones: assuming a lot here
+    switch(aVar) {
 
-    switch(aVar) {
+    case NPNVSupportsWindowless:
+        // FIXME/cjones report PR_TRUE here and use XComposite + child
+        // surface to implement windowless plugins
+        *((NPBool*)aValue) = PR_FALSE;
+        return NPERR_NO_ERROR;
+
+#if defined(OS_LINUX)
     case NPNVSupportsXEmbedBool:
-        *((PRBool*)aValue) = PR_TRUE;
+        *((NPBool*)aValue) = PR_TRUE;
         return NPERR_NO_ERROR;
 
     case NPNVToolkit:
         *((NPNToolkitType*)aValue) = NPNVGtk2;
         return NPERR_NO_ERROR;
 
-    case NPNVSupportsWindowless:
-        // FIXME/cjones report PR_TRUE here and use XComposite + child
-        // surface to implement windowless plugins
-        *((PRBool*)aValue) = PR_FALSE;
-        return NPERR_NO_ERROR;
-
+#elif defined(OS_WIN)
+    case NPNVToolkit:
+        return NPERR_GENERIC_ERROR;
+#endif
     default:
         printf("  unhandled var %s\n", NPNVariableToString(aVar));
         return NPERR_GENERIC_ERROR;   
     }
-#else
-#  error Add support for your OS
-#endif
 
 }
 
-NPError
-NPPInstanceChild::NPP_SetWindow(XID aWindow, int32_t aWidth, int32_t aHeight)
+nsresult
+NPPInstanceChild::AnswerNPP_GetValue(const String& key, String* value)
+{
+    return NPERR_GENERIC_ERROR;
+}
+
+nsresult
+NPPInstanceChild::AnswerNPP_SetWindow(const NPWindow& aWindow, NPError* rv)
 {
     printf("[NPPInstanceChild] NPP_SetWindow(%lx, %d, %d)\n",
-           aWindow, aWidth, aHeight);
+           reinterpret_cast<unsigned long>(aWindow.window),
+           aWindow.width, aWindow.height);
 
-#ifdef OS_LINUX
+#if defined(OS_LINUX)
     // XXX/cjones: the minimum info is sent over IPC to allow this
-    // code to determine the rest.  this code is probably wrong on
+    // code to determine the rest.  this code is possibly wrong on
     // some systems, in some conditions
 
-    GdkNativeWindow handle = (GdkNativeWindow) aWindow;
-    mPlug = gtk_plug_new(handle);
-    
-    mWindow.window = (void*) handle;
-    mWindow.width = aWidth;
-    mWindow.height = aHeight;
-    mWindow.type = NPWindowTypeWindow;
-
+    GdkNativeWindow handle = (GdkNativeWindow) aWindow.window;
     GdkWindow* gdkWindow = gdk_window_lookup(handle);
 
-    fprintf (stderr, "GDK_WINDOW\n");
+    mWindow.window = (void*) handle;
+    mWindow.width = aWindow.width;
+    mWindow.height = aWindow.height;
+    mWindow.type = NPWindowTypeWindow;
+
+    mWsInfo.display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
+
+    // FIXME/cjones: the code below is correct, but apparently to get
+    // a valid GdkWindow*, one needs to create the gtk_plug.  but if we
+    // do that, then the plugin can't plug in to plug.  a hacky solution
+    // may be to create the plug, then create another socket within that
+    // plug.  yuck.
+#if 0
     mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow);
-    fprintf (stderr, "GDK_COLORMAP\n");
-    mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow));
-    fprintf (stderr, "gdk_get_visual\n");
+    mWsInfo.colormap =
+        GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow));
     GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow);
-    fprintf (stderr, "GDK_VISUAL_XVISUAL\n");
     mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual);
-    fprintf (stderr, "gdkVisual->depth\n");
     mWsInfo.depth = gdkVisual->depth;
+#endif
 
     mWindow.ws_info = (void*) &mWsInfo;
 
-    return mPluginIface->setwindow(&mData, &mWindow);
+#elif defined(OS_WIN)
+    mWindow.window = aWindow.window;
+    mWindow.width = aWindow.width;
+    mWindow.height = aWindow.height;
+    mWindow.type = NPWindowTypeWindow;
 
 #else
 #  error Implement me for your OS
 #endif
+
+    *rv = mPluginIface->setwindow(&mData, &mWindow);
+    return NS_OK;
 }
 
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/NPPInstanceChild.h
+++ b/dom/plugins/NPPInstanceChild.h
@@ -45,54 +45,51 @@
 
 #undef _MOZ_LOG
 #define _MOZ_LOG(s) printf("[NPPInstanceChild] %s\n", s)
 
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
-class NPPInstanceChild : public NPPProtocol::Child
+class NPPInstanceChild : public NPPProtocolChild
 {
-    friend class NPAPIPluginChild;
+protected:
+    virtual nsresult AnswerNPP_SetWindow(const NPWindow& window, NPError* rv);
+
+    virtual nsresult AnswerNPP_GetValue(const String& key, String* value);
 
 public:
     NPPInstanceChild(const NPPluginFuncs* aPluginIface) :
-        mPluginIface(aPluginIface),
-        mNpp(this)
+        mPluginIface(aPluginIface)
     {
+        memset(&mWindow, 0, sizeof(mWindow));
         mData.ndata = (void*) this;
     }
 
     virtual ~NPPInstanceChild()
     {
 
     }
 
     NPP GetNPP()
     {
         return &mData;
     }
 
-    // NB: not part of NPP since we can't ship all these requests
-    // across the wire.  some are handled locally, and some are passed
-    // back to the parent through our mNpp
-    NPError NPN_GetValue(NPNVariable aVar, void* aValue);
-
-    // Implement the NPPProtocol::Child interface
-    virtual NPError NPP_SetWindow(XID aWindow,
-                                  int32_t aWidth,
-                                  int32_t aHeight);
+    NPError NPN_GetValue(NPNVariable aVariable, void* aValue);
 
 private:
     const NPPluginFuncs* mPluginIface;
-    NPPProtocolChild mNpp;
     NPP_t mData;
+#ifdef OS_LINUX
     GtkWidget* mPlug;
+#endif
     NPWindow mWindow;
+#ifdef OS_LINUX
     NPSetWindowCallbackStruct mWsInfo;
+#endif
 };
 
-
 } // namespace plugins
 } // namespace mozilla
 
 #endif // ifndef dom_plugins_NPPInstanceChild_h
--- a/dom/plugins/NPPInstanceParent.cpp
+++ b/dom/plugins/NPPInstanceParent.cpp
@@ -41,54 +41,40 @@
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
 NPError
 NPPInstanceParent::NPP_SetWindow(NPWindow* aWindow)
 {
     _MOZ_LOG(__FUNCTION__);
-
-#ifdef OS_LINUX
-
-    // FIXME/cjones: need to support windowless through Xcomposite; here
-    // we assume that we have a windowed plugin implemented by a 
-    // GtkSocket without anything beneath it
-
-    // assuming the socket ID is a long, but so does everything else
-    XID window = (XID) aWindow->window;
+    NS_ENSURE_TRUE(aWindow, NPERR_GENERIC_ERROR);
 
-    return mNpp.NPP_SetWindow((XID) aWindow->window,
-                              aWindow->width,
-                              aWindow->height);
-    // leaving out wsinfo here.  using the window XID, we can look all
-    // of that up in the plugin process. (XXX probably height/width too)
-
-#else
-#  error Implement me for your OS
-#endif
+    NPError prv;
+    nsresult rv = CallNPP_SetWindow(*aWindow, &prv);
+    if (NS_OK != rv)
+        return NPERR_GENERIC_ERROR;
+    return prv;
 }
 
 NPError
 NPPInstanceParent::NPP_GetValue(NPPVariable variable, void *ret_value)
 {
     _MOZ_LOG(__FUNCTION__);
 
     // FIXME/cjones: HACK ALERT! should forward to child
+    switch(variable) {
 #ifdef OS_LINUX
-
-    switch(variable) {
     case NPPVpluginNeedsXEmbed:
         (*(PRBool*)ret_value) = PR_TRUE;
         return NPERR_NO_ERROR;
-            
+#endif
     default:
         return NPERR_GENERIC_ERROR;
     }
 
-#else
-#  error Implement me for your system
-#endif
+    NS_NOTREACHED("Don't get here!");
+    return NPERR_GENERIC_ERROR;
 }
 
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/NPPInstanceParent.h
+++ b/dom/plugins/NPPInstanceParent.h
@@ -45,37 +45,34 @@
 
 #undef _MOZ_LOG
 #define _MOZ_LOG(s) printf("[NPPInstanceParent] %s\n", s)
 
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
-class NPPInstanceParent : public NPPProtocol::Parent
+class NPPInstanceParent :
+    public NPPProtocolParent
 {
-    friend class NPAPIPluginParent;
-
 public:
     NPPInstanceParent(const NPNetscapeFuncs* mNPNIface) :
-        mNpp(this),
         mNPNIface(mNPNIface)
     {
 
     }
 
     virtual ~NPPInstanceParent()
     {
 
     }
 
-    // Implement the NPPProtocol::Parent interface
-    virtual void NPN_GetValue()
+    virtual nsresult AnswerNPN_GetValue(const String& in, String* out)
     {
-        
+        return NS_OK;
     }
 
     NPError NPP_SetWindow(NPWindow* aWindow);
     NPError NPP_GetValue(NPPVariable variable, void *ret_value);
 
     NPError NPP_SetValue(NPNVariable variable, void *value)
     {
         _MOZ_LOG(__FUNCTION__);
@@ -126,17 +123,16 @@ public:
     }
 
     void NPP_URLNotify(const char* url, NPReason reason, void* notifyData)
     {
         _MOZ_LOG(__FUNCTION__);
     }
 
 private:
-    NPPProtocolParent mNpp;
     const NPNetscapeFuncs* mNPNIface;
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
 #endif // ifndef dom_plugins_NPPInstanceParent_h
--- a/dom/plugins/NPPProtocol.h
+++ b/dom/plugins/NPPProtocol.h
@@ -1,174 +1,221 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Plugin App.
- *
- * The Initial Developer of the Original Code is
- *   Chris Jones <jones.chris.g@gmail.com>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * 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 ***** */
+//
+// Automatically generated by ipdlc.
+// Edit at your own risk
+//
 
-#ifndef dom_plugins_NPPProtocol_h
-#define dom_plugins_NPPProtocol_h 1
+#ifndef mozilla_plugins_NPPProtocol_h
+#define mozilla_plugins_NPPProtocol_h
 
-// standard includes
+#include "nscore.h"
 #include "IPC/IPCMessageUtils.h"
 #include "mozilla/ipc/MessageTypes.h"
-
-// extra includes
-#include "npapi.h"
-#include "X11/X.h"
+#include "mozilla/ipc/ProtocolUtils.h"
+#include "PluginMessageUtils.h"
+#include "mozilla/plugins/NPAPIProtocol.h"
 
 namespace mozilla {
 namespace plugins {
-//-----------------------------------------------------------------------------
-
-class NS_FINAL_CLASS NPPProtocol
-{
-public:
-    /*interface*/ class Parent
-    {
-    public:
-        virtual void NPN_GetValue() = 0;
-
-    protected:
-        Parent() { }
-        virtual ~Parent() { }
-        Parent(const Parent&);
-        Parent& operator=(const Parent&);
-    };
-
-    /*interface*/ class Child
-    {
-    public:
-        virtual NPError NPP_SetWindow(XID aWindow,
-                                      int32_t aWidth,
-                                      int32_t aHeight) = 0;
-
-    protected:
-        Child() { }
-        virtual ~Child() { }
-        Child(const Child&);
-        Child& operator=(const Child&);
-    };
-
-    enum State {
-        StateStart = 0,
+namespace NPPProtocol {
 
 
-        // placeholder
-        StateLast
-    };
-
-private:
-    NPPProtocol();
-    virtual ~NPPProtocol() = 0;
-    NPPProtocol& operator=(const NPPProtocol&);
-    // FIXME/cjones state to allow dynamic checking?
+enum State {
 };
 
-//-----------------------------------------------------------------------------
-// Start NPP protocol messages
-//
+enum NPPProtocolMsgType {
+    NPPProtocolStart = NPPProtocolMsgStart << 12,
+    NPPProtocolPreStart = (NPPProtocolMsgStart << 12) - 1,
+    Msg_NPP_SetWindow__ID,
+    Reply_NPP_SetWindow__ID,
+    Msg_NPP_GetValue__ID,
+    Reply_NPP_GetValue__ID,
+    Msg_NPN_GetValue__ID,
+    Reply_NPN_GetValue__ID,
+    NPPProtocolEnd
+};
+class Msg_NPP_SetWindow :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
+public:
+    enum {
+        ID = Msg_NPP_SetWindow__ID
+    };
+    Msg_NPP_SetWindow(const NPWindow& window) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, window);
+    }
+
+    static bool Read(
+                const Message* msg,
+                NPWindow* window)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), window))) {
+            return false;
+        }
 
-// messages from parent->child
-enum NPP_ParentToChildMsgType {
-    NPP_ParentToChildStart = NPP_ParentToChildMsgStart << 12,
-    NPP_ParentToChildPreStart = (NPP_ParentToChildMsgStart << 12) - 1,
+        return true;
+    }
+};
+class Reply_NPP_SetWindow :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
+public:
+    enum {
+        ID = Reply_NPP_SetWindow__ID
+    };
+    Reply_NPP_SetWindow(const NPError& rv) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, rv);
+    }
+
+    static bool Read(
+                const Message* msg,
+                NPError* rv)
+    {
+        void* iter = 0;
 
-    NPP_ParentToChildMsg_NPP_SetWindow__ID,
+        if (!(IPC::ReadParam(msg, &(iter), rv))) {
+            return false;
+        }
+
+        return true;
+    }
+};
+class Msg_NPP_GetValue :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-    NPP_ParentToChildMsg_Reply_NPN_GetValue__ID,
+public:
+    enum {
+        ID = Msg_NPP_GetValue__ID
+    };
+    Msg_NPP_GetValue(const String& key) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, key);
+    }
 
-    NPP_ParentToChildEnd
-};
+    static bool Read(
+                const Message* msg,
+                String* key)
+    {
+        void* iter = 0;
 
-class NPP_ParentToChildMsg_NPP_SetWindow :
-        public IPC::MessageWithTuple<
-    Tuple3<XID, int32_t, int32_t> >
+        if (!(IPC::ReadParam(msg, &(iter), key))) {
+            return false;
+        }
+
+        return true;
+    }
+};
+class Reply_NPP_GetValue :
+    public IPC::Message
 {
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
+public:
+    enum {
+        ID = Reply_NPP_GetValue__ID
+    };
+    Reply_NPP_GetValue(const String& value) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, value);
+    }
+
+    static bool Read(
+                const Message* msg,
+                String* value)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), value))) {
+            return false;
+        }
+
+        return true;
+    }
+};
+class Msg_NPN_GetValue :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
 public:
-    enum { ID = NPP_ParentToChildMsg_NPP_SetWindow__ID };
-    NPP_ParentToChildMsg_NPP_SetWindow(const XID& window,
-                                       const int32_t& width,
-                                       const int32_t& height) :
-        IPC::MessageWithTuple<
-        Tuple3<XID, int32_t, int32_t> >(
-            MSG_ROUTING_CONTROL, ID, MakeTuple(window, width, height))
-    {}
+    enum {
+        ID = Msg_NPN_GetValue__ID
+    };
+    Msg_NPN_GetValue(const String& key) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, key);
+    }
+
+    static bool Read(
+                const Message* msg,
+                String* key)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), key))) {
+            return false;
+        }
+
+        return true;
+    }
 };
+class Reply_NPN_GetValue :
+    public IPC::Message
+{
+private:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
 
-class NPP_ParentToChildMsg_Reply_NPN_GetValue : public IPC::Message
-{
 public:
-    enum { ID = NPP_ParentToChildMsg_Reply_NPN_GetValue__ID };
-    NPP_ParentToChildMsg_Reply_NPN_GetValue() :
-        IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL)
-    {}
+    enum {
+        ID = Reply_NPN_GetValue__ID
+    };
+    Reply_NPN_GetValue(const String& value) :
+        IPC::Message(MSG_ROUTING_NONE, ID, PRIORITY_NORMAL)
+    {
+        IPC::WriteParam(this, value);
+    }
+
+    static bool Read(
+                const Message* msg,
+                String* value)
+    {
+        void* iter = 0;
+
+        if (!(IPC::ReadParam(msg, &(iter), value))) {
+            return false;
+        }
+
+        return true;
+    }
 };
 
 
-// messages from child->parent
-enum NPP_ChildToParentMsgType {
-    NPP_ChildToParentStart = NPP_ChildToParentMsgStart << 12,
-    NPP_ChildToParentPreStart = (NPP_ChildToParentMsgStart << 12) - 1,
-
-    NPP_ChildToParentMsg_NPN_GetValue__ID,
-
-    NPP_ChildToParentMsg_Reply_NPP_SetWindow__ID,
-
-    NPP_ChildToParentEnd
-};
-
-class NPP_ChildToParentMsg_NPN_GetValue : public IPC::Message
-{
-public:
-    enum { ID = NPP_ChildToParentMsg_NPN_GetValue__ID };
-    NPP_ChildToParentMsg_NPN_GetValue() :
-        IPC::Message(MSG_ROUTING_CONTROL, ID, PRIORITY_NORMAL)
-    {}
-};
-
-class NPP_ChildToParentMsg_Reply_NPP_SetWindow :
-        public IPC::MessageWithTuple<NPError>
-{
-public:
-    enum { ID = NPP_ChildToParentMsg_Reply_NPP_SetWindow__ID };
-    NPP_ChildToParentMsg_Reply_NPP_SetWindow(const NPError& arg1) :
-        IPC::MessageWithTuple<NPError>(MSG_ROUTING_CONTROL, ID, arg1)
-    {}
-};
-
-
+} // namespace NPPProtocol
 } // namespace plugins
 } // namespace mozilla
 
-#endif // ifndef dom_plugins_NPPProtocol_h
+#endif // ifndef mozilla_plugins_NPPProtocol_h
--- a/dom/plugins/NPPProtocolChild.h
+++ b/dom/plugins/NPPProtocolChild.h
@@ -1,159 +1,139 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Plugin App.
- *
- * The Initial Developer of the Original Code is
- *   Chris Jones <jones.chris.g@gmail.com>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * 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 ***** */
+//
+// Automatically generated by ipdlc.
+// Edit at your own risk
+//
 
-#ifndef dom_plugins_NPPProtocolChild_h
-#define dom_plugins_NPPProtocolChild_h 1
-
-#include "npapi.h"
-
-#include "nsDebug.h"
-
-#include "IPC/IPCMessageUtils.h"
-#include "mozilla/ipc/RPCChannel.h"
-#include "mozilla/plugins/NPPProtocol.h"
+#ifndef mozilla_plugins_NPPProtocolChild_h
+#define mozilla_plugins_NPPProtocolChild_h
 
-#ifdef DEBUG
-#  undef _MSG_LOG0
-#  undef _MSG_LOG
-
-#  define _MSG_LOG0(fmt, ...)                                       \
-    do {                                                            \
-        printf("[NPAPIProtocolChild] %s "fmt"\n", __VA_ARGS__);    \
-    } while(0)
-
-#  define _MSG_LOG(fmt, ...)                    \
-    _MSG_LOG0(fmt, __FUNCTION__,## __VA_ARGS__)
-#else
-#  define _MSG_LOG(fmt, ...)
-#endif
+#include "mozilla/plugins/NPPProtocol.h"
+#include "mozilla/ipc/RPCChannel.h"
 
 namespace mozilla {
 namespace plugins {
-//-----------------------------------------------------------------------------
+
+
+class /*NS_ABSTRACT_CLASS*/ NPPProtocolChild :
+    public mozilla::ipc::RPCChannel::Listener
+{
+    friend class NPAPIProtocolChild;
 
-class NS_FINAL_CLASS NPPProtocolChild :
-        public NPPProtocol::Parent,
-        public mozilla::ipc::RPCChannel::Listener
-{
+protected:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
+    virtual nsresult AnswerNPP_SetWindow(
+                const NPWindow& window,
+                NPError* rv) = 0;
+    virtual nsresult AnswerNPP_GetValue(
+                const String& key,
+                String* value) = 0;
+
 private:
     typedef IPC::Message Message;
-    typedef mozilla::ipc::RPCChannel RPCChannel;
+    typedef mozilla::ipc::RPCChannel Channel;
 
 public:
-    NPPProtocolChild(NPPProtocol::Child* aChild) :
-        mChild(aChild)
+    NPPProtocolChild()
     {
-
     }
 
     virtual ~NPPProtocolChild()
     {
+    }
 
+    nsresult CallNPN_GetValue(
+                const String& key,
+                String* value)
+    {
+        Message __reply;
+        Message* __msg;
+        __msg = new NPPProtocol::Msg_NPN_GetValue(key);
+        __msg->set_routing_id(mPeerId);
+        if (!(mChannel->Call(__msg, &(__reply)))) {
+            return NS_ERROR_FAILURE;
+        }
+        if (!(NPPProtocol::Reply_NPN_GetValue::Read(&(__reply), value))) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+        return NS_OK;
     }
 
-    // FIXME/cjones: how is this protocol opened/closed with respect
-    // the higher level protocol?
-
-    void SetChannel(RPCChannel* aRpc)
+    virtual Result OnMessageReceived(const Message& msg)
     {
-        // FIXME also assert on channel state
-        NS_ASSERTION(aRpc, "need a valid RPC channel");
-        mRpc = aRpc;
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
     }
 
-    void NextState(NPPProtocol::State aNextState)
+    virtual Result OnMessageReceived(
+                const Message& msg,
+                Message*& reply)
     {
-        // FIXME impl
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
     }
 
-    // Implement the parent interface
-    virtual void NPN_GetValue(/*...*/)
-    {
-        _MSG_LOG("outcall NPN_GetValue()");
-
-        Message reply;
-
-        mRpc->Call(new NPP_ChildToParentMsg_NPN_GetValue(),
-                   &reply);
-        NS_ASSERTION(NPP_ParentToChildMsg_Reply_NPN_GetValue__ID
-                     == reply.type(),
-                     "wrong reply msg to NPN_GetValue()");
-        // nothing to unpack
-        return;
-    }
-
-    virtual Result OnCallReceived(const Message& msg, Message*& reply)
+    virtual Result OnCallReceived(
+                const Message& msg,
+                Message*& reply)
     {
-        switch(msg.type()) {
-        case NPP_ParentToChildMsg_NPP_SetWindow__ID: {
-            XID aWindow;
-            int32_t aWidth;
-            int32_t aHeight;
+        switch (msg.type()) {
+        case NPPProtocol::Msg_NPP_SetWindow__ID:
+            {
+                NPWindow window;
+                NPError rv;
+
+                if (!(NPPProtocol::Msg_NPP_SetWindow::Read(&(msg), &(window)))) {
+                    return MsgPayloadError;
+                }
+                if (AnswerNPP_SetWindow(window, &(rv))) {
+                    return MsgValueError;
+                }
 
-            NPP_ParentToChildMsg_NPP_SetWindow::Param p;
-            NS_ASSERTION(NPP_ParentToChildMsg_NPP_SetWindow::Read(&msg, &p),
-                         "bad types in NPP_SetWindow() msg");
-            aWindow = p.a;
-            aWidth = p.b;
-            aHeight = p.c;
+                reply = new NPPProtocol::Reply_NPP_SetWindow(rv);
+                reply->set_reply();
+                return MsgProcessed;
+            }
+        case NPPProtocol::Msg_NPP_GetValue__ID:
+            {
+                String key;
+                String value;
 
-            _MSG_LOG("incall NPP_SetWindow(%lx, %d, %d)\n",
-                     aWindow, aWidth, aHeight);
+                if (!(NPPProtocol::Msg_NPP_GetValue::Read(&(msg), &(key)))) {
+                    return MsgPayloadError;
+                }
+                if (AnswerNPP_GetValue(key, &(value))) {
+                    return MsgValueError;
+                }
 
-            NPError val0 = mChild->NPP_SetWindow(aWindow, aWidth, aHeight);
-            reply = new NPP_ChildToParentMsg_Reply_NPP_SetWindow(val0);
-            reply->set_reply();
-            return MsgProcessed;
-        }
-
+                reply = new NPPProtocol::Reply_NPP_GetValue(value);
+                reply->set_reply();
+                return MsgProcessed;
+            }
         default:
-            return MsgNotKnown;
+            {
+                return MsgNotKnown;
+            }
         }
     }
 
 private:
-    NPPProtocol::Child* mChild;
-    NPPProtocol::State mState;
-    RPCChannel* mRpc;
+    Channel* mChannel;
+    int mId;
+    int mPeerId;
+    mozilla::ipc::IProtocolManager* mManager;
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
-#endif // ifndef dom_plugins_NPPProtocolChild_h
+#endif // ifndef mozilla_plugins_NPPProtocolChild_h
--- a/dom/plugins/NPPProtocolParent.h
+++ b/dom/plugins/NPPProtocolParent.h
@@ -1,159 +1,137 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Plugin App.
- *
- * The Initial Developer of the Original Code is
- *   Chris Jones <jones.chris.g@gmail.com>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * 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 ***** */
+//
+// Automatically generated by ipdlc.
+// Edit at your own risk
+//
 
-#ifndef dom_plugins_NPPProtocolParent_h
-#define dom_plugins_NPPProtocolParent_h 1
+#ifndef mozilla_plugins_NPPProtocolParent_h
+#define mozilla_plugins_NPPProtocolParent_h
 
 #include "mozilla/plugins/NPPProtocol.h"
-
-#include "npapi.h"
-
-#include "nsDebug.h"
-#include "IPC/IPCMessageUtils.h"
-
 #include "mozilla/ipc/RPCChannel.h"
 
-#ifdef DEBUG
-#  undef _MSG_LOG0
-#  undef _MSG_LOG
-
-#  define _MSG_LOG0(fmt, ...)                                       \
-    do {                                                            \
-        printf("[NPAPIProtocolParent] %s "fmt"\n", __VA_ARGS__);    \
-    } while(0)
-
-#  define _MSG_LOG(fmt, ...)                    \
-    _MSG_LOG0(fmt, __FUNCTION__,## __VA_ARGS__)
-#else
-#  define _MSG_LOG(fmt, ...)
-#endif
-
 namespace mozilla {
 namespace plugins {
-//-----------------------------------------------------------------------------
+
+
+class /*NS_ABSTRACT_CLASS*/ NPPProtocolParent :
+    public mozilla::ipc::RPCChannel::Listener
+{
+    friend class NPAPIProtocolParent;
 
-class NS_FINAL_CLASS NPPProtocolParent :
-        public NPPProtocol::Child,
-        public mozilla::ipc::RPCChannel::Listener
-{
+protected:
+    typedef mozilla::ipc::String String;
+    typedef mozilla::ipc::StringArray StringArray;
+
+    virtual nsresult AnswerNPN_GetValue(
+                const String& key,
+                String* value) = 0;
+
 private:
     typedef IPC::Message Message;
-    typedef mozilla::ipc::RPCChannel RPCChannel;
+    typedef mozilla::ipc::RPCChannel Channel;
 
 public:
-    NPPProtocolParent(NPPProtocol::Parent* aParent) :
-        mParent(aParent)
+    NPPProtocolParent()
     {
-
     }
 
     virtual ~NPPProtocolParent()
     {
-
     }
 
-    // FIXME/cjones: how is this protocol opened/closed with respect
-    // the higher level protocol?
-
-    void SetChannel(RPCChannel* aRpc)
+    nsresult CallNPP_SetWindow(
+                const NPWindow& window,
+                NPError* rv)
     {
-        // FIXME also assert on channel state
-        NS_ASSERTION(aRpc, "need a valid RPC channel");
-        mRpc = aRpc;
+        Message __reply;
+        Message* __msg;
+        __msg = new NPPProtocol::Msg_NPP_SetWindow(window);
+        __msg->set_routing_id(mPeerId);
+        if (!(mChannel->Call(__msg, &(__reply)))) {
+            return NS_ERROR_FAILURE;
+        }
+        if (!(NPPProtocol::Reply_NPP_SetWindow::Read(&(__reply), rv))) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+        return NS_OK;
     }
 
-    void NextState(NPPProtocol::State aNextState)
+    nsresult CallNPP_GetValue(
+                const String& key,
+                String* value)
     {
-        // FIXME impl
+        Message __reply;
+        Message* __msg;
+        __msg = new NPPProtocol::Msg_NPP_GetValue(key);
+        __msg->set_routing_id(mPeerId);
+        if (!(mChannel->Call(__msg, &(__reply)))) {
+            return NS_ERROR_FAILURE;
+        }
+        if (!(NPPProtocol::Reply_NPP_GetValue::Read(&(__reply), value))) {
+            return NS_ERROR_ILLEGAL_VALUE;
+        }
+        return NS_OK;
     }
 
-    // Implement the child interface
-    virtual NPError NPP_SetWindow(XID aWindow,
-                                  int32_t aWidth,
-                                  int32_t aHeight)
+    virtual Result OnMessageReceived(const Message& msg)
     {
-        _MSG_LOG("outcall NPP_SetWindow(%lx, %d, %d)",
-                 aWindow, aWidth, aHeight);
-
-        Message reply;
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
+    }
 
-        mRpc->Call(new NPP_ParentToChildMsg_NPP_SetWindow(aWindow,
-                                                          aWidth,
-                                                          aHeight),
-                   &reply);
-        NS_ASSERTION(NPP_ChildToParentMsg_Reply_NPP_SetWindow__ID
-                     == reply.type(),
-                     "wrong reply msg to NPP_SetWindow()");
-
-        NPError ret0;
-        NS_ASSERTION(NPP_ChildToParentMsg_Reply_NPP_SetWindow
-                     ::Read(&reply, &ret0),
-                     "bad types in reply msg to NPP_SetWindow()");
-
-        return ret0;
+    virtual Result OnMessageReceived(
+                const Message& msg,
+                Message*& reply)
+    {
+        switch (msg.type()) {
+        default:
+            {
+                return MsgNotKnown;
+            }
+        }
     }
 
-    virtual Result OnCallReceived(const Message& msg, Message*& reply)
+    virtual Result OnCallReceived(
+                const Message& msg,
+                Message*& reply)
     {
-        switch(msg.type()) {
-        case NPP_ChildToParentMsg_NPN_GetValue__ID: {
-            _MSG_LOG("incall NPN_GetValue()");
+        switch (msg.type()) {
+        case NPPProtocol::Msg_NPN_GetValue__ID:
+            {
+                String key;
+                String value;
 
-            // nothing to unpack
-            mParent->NPN_GetValue();
+                if (!(NPPProtocol::Msg_NPN_GetValue::Read(&(msg), &(key)))) {
+                    return MsgPayloadError;
+                }
+                if (AnswerNPN_GetValue(key, &(value))) {
+                    return MsgValueError;
+                }
 
-            reply = new NPP_ParentToChildMsg_Reply_NPN_GetValue();
-            return MsgProcessed;
-        }
-
+                reply = new NPPProtocol::Reply_NPN_GetValue(value);
+                reply->set_reply();
+                return MsgProcessed;
+            }
         default:
-            return MsgNotKnown;
+            {
+                return MsgNotKnown;
+            }
         }
     }
 
 private:
-    NPPProtocol::Parent* mParent;
-    NPPProtocol::State mState;
-    RPCChannel* mRpc;
+    Channel* mChannel;
+    int mId;
+    int mPeerId;
+    mozilla::ipc::IProtocolManager* mManager;
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
-#endif // ifndef dom_plugins_NPPProtocolParent_h
+#endif // ifndef mozilla_plugins_NPPProtocolParent_h
new file mode 100644
--- /dev/null
+++ b/dom/plugins/PluginMessageUtils.h
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * vim: sw=4 ts=4 et :
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Plugin App.
+ *
+ * The Initial Developer of the Original Code is
+ *   Chris Jones <jones.chris.g@gmail.com>
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * 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 ***** */
+
+#ifndef DOM_PLUGINS_PLUGINMESSAGEUTILS_H
+#define DOM_PLUGINS_PLUGINMESSAGEUTILS_H
+
+#include "IPC/IPCMessageUtils.h"
+
+#include "npapi.h"
+
+namespace IPC {
+
+#if 0
+  void* window;  /* Platform specific window handle */
+                 /* OS/2: x - Position of bottom left corner */
+                 /* OS/2: y - relative to visible netscape window */
+  int32_t  x;      /* Position of top left corner relative */
+  int32_t  y;      /* to a netscape page. */
+  uint32_t width;  /* Maximum window size */
+  uint32_t height;
+  NPRect   clipRect; /* Clipping rectangle in port coordinates */
+                     /* Used by MAC only. */
+#if defined(XP_UNIX) && !defined(XP_MACOSX)
+  void * ws_info; /* Platform-dependent additonal data */
+#endif /* XP_UNIX */
+  NPWindowType type; /* Is this a window or a drawable? */
+#endif
+
+template <>
+struct ParamTraits<NPRect>
+{
+  typedef NPRect paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam)
+  {
+    WriteParam(aMsg, aParam.top);
+    WriteParam(aMsg, aParam.left);
+    WriteParam(aMsg, aParam.bottom);
+    WriteParam(aMsg, aParam.right);
+  }
+
+  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
+  {
+    uint16_t top, left, bottom, right;
+    if (ReadParam(aMsg, aIter, &top) &&
+        ReadParam(aMsg, aIter, &left) &&
+        ReadParam(aMsg, aIter, &bottom) &&
+        ReadParam(aMsg, aIter, &right)) {
+      aResult->top = top;
+      aResult->left = left;
+      aResult->bottom = bottom;
+      aResult->right = right;
+      return true;
+    }
+    return false;
+  }
+
+  static void Log(const paramType& aParam, std::wstring* aLog)
+  {
+    aLog->append(StringPrintf(L"[%u, %u, %u, %u]", aParam.top, aParam.left,
+                              aParam.bottom, aParam.right));
+  }
+};
+
+template <>
+struct ParamTraits<NPWindowType>
+{
+  typedef NPWindowType paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam)
+  {
+    aMsg->WriteInt16(int16(aParam));
+  }
+
+  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
+  {
+    int16 result;
+    if (aMsg->ReadInt16(aIter, &result)) {
+      *aResult = paramType(result);
+      return true;
+    }
+    return false;
+  }
+
+  static void Log(const paramType& aParam, std::wstring* aLog)
+  {
+    aLog->append(StringPrintf(L"%d", int16(aParam)));
+  }
+};
+
+template <>
+struct ParamTraits<NPWindow>
+{
+  typedef NPWindow paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam)
+  {
+    aMsg->WriteULong(reinterpret_cast<unsigned long>(aParam.window));
+    WriteParam(aMsg, aParam.x);
+    WriteParam(aMsg, aParam.y);
+    WriteParam(aMsg, aParam.width);
+    WriteParam(aMsg, aParam.height);
+    WriteParam(aMsg, aParam.clipRect);
+    // we don't serialize ws_info because it stores pointers to this
+    // process's address space.  it is reconstructed for each process
+    // using the window ID
+    WriteParam(aMsg, aParam.type);
+  }
+
+  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
+  {
+    unsigned long window;
+    int32_t x, y;
+    uint32_t width, height;
+    NPWindowType type;
+    if (aMsg->ReadULong(aIter, &window) &&
+        ReadParam(aMsg, aIter, &x) &&
+        ReadParam(aMsg, aIter, &y) &&
+        ReadParam(aMsg, aIter, &width) &&
+        ReadParam(aMsg, aIter, &height) &&
+        ReadParam(aMsg, aIter, &type)) {
+      aResult->window = (void*)window;
+      aResult->x = x;
+      aResult->y = y;
+      aResult->width = width;
+      aResult->height = height;
+#if defined(XP_UNIX) && !defined(XP_MACOSX)
+      aResult->ws_info = 0;     // graphics code fills this in
+#endif
+      aResult->type = type;
+      return true;
+    }
+    return false;
+  }
+
+  static void Log(const paramType& aParam, std::wstring* aLog)
+  {
+    aLog->append(StringPrintf(L"[%u, %d, %d, %u, %u, %d",
+                              (unsigned long)aParam.window,
+                              aParam.x, aParam.y, aParam.width,
+                              aParam.height, (long)aParam.type));
+  }
+};
+
+} /* namespace IPC */
+
+#endif /* DOM_PLUGINS_PLUGINMESSAGEUTILS_H */
--- a/dom/plugins/PluginProcessParent.cpp
+++ b/dom/plugins/PluginProcessParent.cpp
@@ -50,18 +50,18 @@ namespace plugins {
 
 
 const char* PluginProcessParent::kPluginProcessName = "gecko-plugin"
 #ifdef OS_WIN
                                                     ".exe"
 #endif
                                                     ;
 
-PluginProcessParent::PluginProcessParent(const std::string& aPluginFilename) :
-    mPluginFilename(aPluginFilename)
+PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath) :
+    mPluginFilePath(aPluginFilePath)
 {
 }
 
 PluginProcessParent::~PluginProcessParent()
 {
 }
 
 bool
@@ -79,17 +79,17 @@ PluginProcessParent::Launch()
 #if defined(OS_POSIX)
     int srcChannelFd, dstChannelFd;
     channel().GetClientFileDescriptorMapping(&srcChannelFd, &dstChannelFd);
     mFileMap.push_back(std::pair<int,int>(srcChannelFd, dstChannelFd));
 #endif
 
     CommandLine cmdLine(exePath.ToWStringHack());
     cmdLine.AppendSwitchWithValue(switches::kProcessChannelID, channel_id());
-    cmdLine.AppendLooseValue(UTF8ToWide(mPluginFilename));
+    cmdLine.AppendLooseValue(UTF8ToWide(mPluginFilePath));
 
     base::ProcessHandle process;
 #if defined(OS_WIN)
     base::LaunchApp(cmdLine, false, false, &process);
 #elif defined(OS_POSIX)
     base::LaunchApp(cmdLine.argv(), mFileMap, false, &process);
 #else
 #error Bad!
--- a/dom/plugins/PluginProcessParent.h
+++ b/dom/plugins/PluginProcessParent.h
@@ -35,16 +35,18 @@
  * 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 ***** */
 
 #ifndef dom_plugins_PluginProcessParent_h
 #define dom_plugins_PluginProcessParent_h 1
 
+#include "base/basictypes.h"
+
 #include "base/file_path.h"
 #include "base/scoped_ptr.h"
 #include "base/thread.h"
 #include "base/waitable_event.h"
 #include "chrome/common/child_process_host.h"
 
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 
@@ -53,17 +55,17 @@
 
 namespace mozilla {
 namespace plugins {
 //-----------------------------------------------------------------------------
 
 class PluginProcessParent : mozilla::ipc::GeckoChildProcessHost
 {
 public:
-    PluginProcessParent(const std::string& aPluginFilename);
+    PluginProcessParent(const std::string& aPluginFilePath);
     ~PluginProcessParent();
 
     /**
      * Asynchronously launch the plugin process.
      */
     bool Launch();
 
     IPC::Channel* GetChannel() {
@@ -77,17 +79,17 @@ public:
 
     base::WaitableEvent* GetShutDownEvent()
     {
         return GetProcessEvent();
     }
 
 private:
     static const char* kPluginProcessName;
-    std::string mPluginFilename;
+    std::string mPluginFilePath;
 
     DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
--- a/dom/plugins/PluginThreadChild.h
+++ b/dom/plugins/PluginThreadChild.h
@@ -35,16 +35,18 @@
  * 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 ***** */
 
 #ifndef dom_plugins_PluginThreadChild_h
 #define dom_plugins_PluginThreadChild_h 1
 
+#include "base/basictypes.h"
+
 #include "chrome/common/child_thread.h"
 #include "base/file_path.h"
 
 #include "mozilla/ipc/GeckoThread.h"
 #include "mozilla/plugins/NPAPIPluginChild.h"
 
 #undef _MOZ_LOG
 #define _MOZ_LOG(s)  printf("[PluginThreadChild] %s", s)
--- a/dom/plugins/SharedPRLibrary.h
+++ b/dom/plugins/SharedPRLibrary.h
@@ -44,18 +44,17 @@
 #include "mozilla/SharedLibrary.h"
 
 namespace mozilla {
 
 
 class SharedPRLibrary : public SharedLibrary
 {
 public:
-    SharedPRLibrary(const char* aFullPath,
-                    PRLibrary* aLibrary) :
+    SharedPRLibrary(const char* aFilePath, PRLibrary* aLibrary) :
         mLibrary(aLibrary)
     {
         NS_ASSERTION(mLibrary, "need non-null lib");
         // addref here??
     }
 
     virtual ~SharedPRLibrary()
     {
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -41,25 +41,18 @@
 
 #include "prtypes.h"
 #include "nsStringGlue.h"
 #include "nsTArray.h"
 
 // Used by chrome code, we override this here and #ifdef theirs out. See the
 // comments in chrome/common/ipc_message_utils.h for info about this enum.
 enum IPCMessageStart {
-  //NPAPIProtocolMsgStart = 0,
-  //NPPProtocolMsgStart = 0,
-  // FIXME/cjones: blow these away when plugin fixes are merged
-  NPAPI_ParentToChildMsgStart = 0,
-  NPAPI_ChildToParentMsgStart,
-  NPP_ParentToChildMsgStart,
-  NPP_ChildToParentMsgStart,
-  NPObject_ParentToChildMsgStart,
-  NPObject_ChildToParentMsgStart,
+  NPAPIProtocolMsgStart = 0,
+  NPPProtocolMsgStart = 0,
 
   IFrameEmbedding_ParentToChildMsgStart,
   IFrameEmbedding_ChildToParentMsgStart,
 
   LastMsgIndex
 };
 
 COMPILE_ASSERT(LastMsgIndex <= 16, need_to_update_IPC_MESSAGE_MACRO);
--- a/ipc/glue/ProtocolUtils.h
+++ b/ipc/glue/ProtocolUtils.h
@@ -53,17 +53,17 @@ struct ActorHandle
     int mChildId;
 };
 
 
 class /*NS_INTERFACE_CLASS*/ IProtocolManager
 {
 public:
     virtual int32 Register(RPCChannel::Listener*) = 0;
-    RPCChannel::Listener* Lookup(int32) = 0;
+    virtual RPCChannel::Listener* Lookup(int32) = 0;
     virtual void Unregister(int32) = 0;
 };
 
 } // namespace ipc
 } // namespace mozilla
 
 
 namespace IPC {
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -573,25 +573,27 @@ class GenerateProtocolActorHeader(Visito
 
             routeif.ifb.addstmt(cxx.StmtReturn(cxx.ExprCall(
                         cxx.ExprSelect(routedvar, '->', dispatchMethod),
                         params)))
             mdefn.addstmt(routeif)
             mdefn.addstmt(cxx.Whitespace.NL)
 
 
-        if p.decl.type.isToplevel():
+        # FIXME/cjones: re-enable when we have AsyncChannel
+        if 0 and p.decl.type.isToplevel():
             addDispatcher(asynchandler, 'OnMessageReceived',
                           [ cxx.ExprVar('msg') ])
         asynchandler.addstmt(self.asyncswitch)
         cls.addstmt(asynchandler)
         cls.addstmt(cxx.Whitespace.NL)
 
         if p.decl.type.talksSync():
-            if p.decl.type.isToplevel():
+            # FIXME/cjones: re-enable when we have SyncChannel
+            if 0 and p.decl.type.isToplevel():
                 addDispatcher(synchandler, 'OnMessageReceived',
                               [ cxx.ExprVar('msg'), cxx.ExprVar('reply') ])
             synchandler.addstmt(self.syncswitch)
             cls.addstmt(synchandler)
             cls.addstmt(cxx.Whitespace.NL)
 
             if p.decl.type.talksRpc():
                 if p.decl.type.isToplevel():
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -83,19 +83,20 @@
 #include <gdk/gdkx.h>
 #include "gtk2xtbin.h"
 #endif
 
 #include "nsJSNPRuntime.h"
 #include "nsIHttpAuthManager.h"
 #include "nsICookieService.h"
 
-#  include "mozilla/SharedPRLibrary.h"
+#include "mozilla/SharedPRLibrary.h"
+#include "mozilla/plugins/NPAPIPluginParent.h"
+
 using mozilla::SharedPRLibrary;
-#  include "mozilla/plugins/NPAPIPluginParent.h"
 using mozilla::plugins::NPAPIPluginParent;
 
 static PRLock *sPluginThreadAsyncCallLock = nsnull;
 static PRCList sPendingAsyncCalls = PR_INIT_STATIC_CLIST(&sPendingAsyncCalls);
 
 // POST/GET stream type
 enum eNPPStreamTypeInternal {
   eNPPStreamTypeInternal_Get,
@@ -278,30 +279,30 @@ nsNPAPIPlugin::nsNPAPIPlugin(NPPluginFun
   memset((void*) &fCallbacks, 0, sizeof(fCallbacks));
   fLibrary = nsnull;
 
 #if defined(XP_WIN) || defined(XP_OS2)
   // On Windows (and Mac) we need to keep a direct reference to the
   // fCallbacks and NOT just copy the struct. See Bugzilla 85334
 
   NP_GETENTRYPOINTS pfnGetEntryPoints =
-    (NP_GETENTRYPOINTS)PR_FindSymbol(aLibrary, "NP_GetEntryPoints");
+    (NP_GETENTRYPOINTS)aLibrary->FindSymbol("NP_GetEntryPoints");
 
   if (!pfnGetEntryPoints)
     return;
 
   fCallbacks.size = sizeof(fCallbacks);
 
   nsresult result = pfnGetEntryPoints(&fCallbacks);
   NS_ASSERTION(result == NS_OK, "Failed to get callbacks");
 
   NS_ASSERTION(HIBYTE(fCallbacks.version) >= NP_VERSION_MAJOR,
                "callback version is less than NP version");
 
-  fShutdownEntry = (NP_PLUGINSHUTDOWN)PR_FindSymbol(aLibrary, "NP_Shutdown");
+  fShutdownEntry = (NP_PLUGINSHUTDOWN)aLibrary->FindSymbol("NP_Shutdown");
 #elif defined(XP_MACOSX)
   NPPluginFuncs np_callbacks;
   memset((void*) &np_callbacks, 0, sizeof(np_callbacks));
   np_callbacks.size = sizeof(np_callbacks);
 
   fShutdownEntry = (NP_PLUGINSHUTDOWN)PR_FindSymbol(aLibrary, "NP_Shutdown");
   NP_GETENTRYPOINTS pfnGetEntryPoints = (NP_GETENTRYPOINTS)PR_FindSymbol(aLibrary, "NP_GetEntryPoints");
   NP_PLUGININIT pfnInitialize = (NP_PLUGININIT)PR_FindSymbol(aLibrary, "NP_Initialize");
@@ -365,17 +366,17 @@ nsNPAPIPlugin::CreatePlugin(const char* 
 #if defined(XP_UNIX) && !defined(XP_MACOSX)
   nsNPAPIPlugin *plptr;
 
   NPPluginFuncs callbacks;
   memset((void*) &callbacks, 0, sizeof(callbacks));
   callbacks.size = sizeof(callbacks);
 
   SharedLibrary* pluginLib;
-  if (PR_GetEnv("DISABLE_OOP_PLUGINS"))
+  if (PR_GetEnv("DISABLE_OOP_PLUGINS") || !aFilePath)
     pluginLib = new SharedPRLibrary(aFilePath, aLibrary);
   else
     pluginLib = NPAPIPluginParent::LoadModule(aFilePath, aLibrary);
 
   NP_PLUGINSHUTDOWN pfnShutdown =
     (NP_PLUGINSHUTDOWN) pluginLib->FindFunctionSymbol("NP_Shutdown");
 
   // create the new plugin handler
@@ -405,16 +406,22 @@ nsNPAPIPlugin::CreatePlugin(const char* 
   if (pfnInitialize(&(nsNPAPIPlugin::CALLBACKS),&callbacks) != NS_OK)
     return NS_ERROR_UNEXPECTED;
 
   // now copy function table back to nsNPAPIPlugin instance
   memcpy((void*) &(plptr->fCallbacks), (void*)&callbacks, sizeof(callbacks));
 #endif
 
 #ifdef XP_WIN
+  SharedLibrary* pluginLib;
+  if (PR_GetEnv("DISABLE_OOP_PLUGINS") || !aFilePath)
+    pluginLib = new SharedPRLibrary(aFilePath, aLibrary);
+  else
+    pluginLib = NPAPIPluginParent::LoadModule(aFilePath, aLibrary);
+
   // Note: on Windows, we must use the fCallback because plugins may
   // change the function table. The Shockwave installer makes changes
   // in the table while running
   *aResult = new nsNPAPIPlugin(nsnull, aLibrary, nsnull);
 
   if (*aResult == NULL)
     return NS_ERROR_OUT_OF_MEMORY;
 
@@ -424,17 +431,17 @@ nsNPAPIPlugin::CreatePlugin(const char* 
   // when we call into the NP_Initialize entry point - NPN functions
   // require that mBrowserManager be set up
   if (NS_FAILED((*aResult)->Initialize())) {
     NS_RELEASE(*aResult);
     return NS_ERROR_FAILURE;
   }
 
   NP_PLUGININIT pfnInitialize =
-    (NP_PLUGININIT)PR_FindSymbol(aLibrary, "NP_Initialize");
+    (NP_PLUGININIT)pluginLib->FindSymbol("NP_Initialize");
 
   if (!pfnInitialize)
     return NS_ERROR_UNEXPECTED;
 
   if (pfnInitialize(&(nsNPAPIPlugin::CALLBACKS)) != NS_OK)
     return NS_ERROR_UNEXPECTED;
 #endif
 
--- a/modules/plugin/test/testplugin/nptest.cpp
+++ b/modules/plugin/test/testplugin/nptest.cpp
@@ -279,85 +279,96 @@ NPP_New(NPMIMEType pluginType, NPP insta
   // set up our our instance data
   InstanceData* instanceData = (InstanceData*)malloc(sizeof(InstanceData));
   if (!instanceData)
     return NPERR_OUT_OF_MEMORY_ERROR;
   memset(instanceData, 0, sizeof(InstanceData));
   instanceData->npp = instance;
   instance->pdata = instanceData;
 
+#if 0
   TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
   if (!scriptableObject) {
     printf("NPN_CreateObject failed to create an object, can't create a plugin instance\n");
     free(instanceData);
     return NPERR_GENERIC_ERROR;
   }
   NPN_RetainObject(scriptableObject);
   scriptableObject->npp = instance;
   scriptableObject->drawMode = DM_DEFAULT;
   scriptableObject->drawColor = 0;
   instanceData->scriptableObject = scriptableObject;
 
   instanceData->instanceCountWatchGeneration = sCurrentInstanceCountWatchGeneration;
-  
+ 
   bool requestWindow = false;
+
   // handle extra params
   for (int i = 0; i < argc; i++) {
     if (strcmp(argn[i], "drawmode") == 0) {
       if (strcmp(argv[i], "solid") == 0)
         scriptableObject->drawMode = DM_SOLID_COLOR;    
     }
     else if (strcmp(argn[i], "color") == 0) {
       scriptableObject->drawColor = parseHexColor(argv[i]);
     }
     else if (strcmp(argn[i], "wmode") == 0) {
       if (strcmp(argv[i], "window") == 0) {
         requestWindow = true;
       }
     }
   }
+#else
+  bool requestWindow = true;
+#endif
 
   if (!browserSupportsWindowless || !pluginSupportsWindowlessMode()) {
     requestWindow = true;
   } else if (!pluginSupportsWindowMode()) {
     requestWindow = false;
   }
   if (requestWindow) {
     instanceData->hasWidget = true;
   } else {
     // NPPVpluginWindowBool should default to true, so we may as well
     // test that by not setting it in the window case
     NPN_SetValue(instance, NPPVpluginWindowBool, (void*)false);
   }
 
+#if 0
   if (scriptableObject->drawMode == DM_SOLID_COLOR &&
       (scriptableObject->drawColor & 0xFF000000) != 0xFF000000) {
     NPN_SetValue(instance, NPPVpluginTransparentBool, (void*)true);
   }
+#endif
 
   instanceData->lastReportedPrivateModeState = false;
 
   // do platform-specific initialization
   NPError err = pluginInstanceInit(instanceData);
   if (err != NPERR_NO_ERROR) {
+#if 0
     NPN_ReleaseObject(scriptableObject);
+#endif
     free(instanceData);
     return err;
   }
 
   ++sInstanceCount;
   return NPERR_NO_ERROR;
 }
 
 NPError
 NPP_Destroy(NPP instance, NPSavedData** save)
 {
   InstanceData* instanceData = (InstanceData*)(instance->pdata);
   pluginInstanceShutdown(instanceData);
+#if 0
   NPN_ReleaseObject(instanceData->scriptableObject);
+#endif
   free(instanceData);
 
   if (sCurrentInstanceCountWatchGeneration == instanceData->instanceCountWatchGeneration) {
     --sInstanceCount;
   }
 
   return NPERR_NO_ERROR;
 }
@@ -420,22 +431,24 @@ void
 NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
 {
 }
 
 NPError
 NPP_GetValue(NPP instance, NPPVariable variable, void* value)
 {
   InstanceData* instanceData = (InstanceData*)instance->pdata;
+#if 0
   if (variable == NPPVpluginScriptableNPObject) {
     NPObject* object = instanceData->scriptableObject;
     NPN_RetainObject(object);
     *((NPObject**)value) = object;
     return NPERR_NO_ERROR;
   }
+#endif
   if (variable == NPPVpluginNeedsXEmbed) {
     // Only relevant for X plugins
     *(NPBool*)value = instanceData->hasWidget;
     return NPERR_NO_ERROR;
   }
 
   return NPERR_GENERIC_ERROR;
 }
--- a/modules/plugin/test/testplugin/nptest_windows.cpp
+++ b/modules/plugin/test/testplugin/nptest_windows.cpp
@@ -274,28 +274,28 @@ LRESULT CALLBACK PluginWndProc(HWND hWnd
 
   return CallWindowProc(wndProc, hWnd, uMsg, wParam, lParam);
 }
 
 void
 ClearSubclass(HWND hWnd)
 {
   if (GetProp(hWnd, "MozillaWndProc")) {
-    ::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)GetProp(hWnd, "MozillaWndProc"));
+    ::SetWindowLong(hWnd, GWL_WNDPROC, (long)GetProp(hWnd, "MozillaWndProc"));
     RemoveProp(hWnd, "MozillaWndProc");
     RemoveProp(hWnd, "InstanceData");
   }
 }
 
 void
 SetSubclass(HWND hWnd, InstanceData* instanceData)
 {
   // Subclass the plugin window so we can handle our own windows events.
   SetProp(hWnd, "InstanceData", (HANDLE)instanceData);
-  WNDPROC origProc = (WNDPROC)::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)PluginWndProc);
+  WNDPROC origProc = (WNDPROC)::SetWindowLong(hWnd, GWL_WNDPROC, (long)PluginWndProc);
   SetProp(hWnd, "MozillaWndProc", (HANDLE)origProc);
 }
 
 /* utils */
 
 Color
 GetColorsFromRGBA(PRUint32 rgba)
 {
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2922,16 +2922,21 @@ XRE_main(int argc, char* argv[], const n
   }
     
 #ifdef NS_TRACE_MALLOC
   gArgc = argc = NS_TraceMallocStartupArgs(gArgc, gArgv);
 #endif
 
   MOZ_SPLASHSCREEN_UPDATE(20);
 
+  // Set up chromium libs
+  base::AtExitManager exitManager;
+  CommandLine::Init(gArgc, gArgv);
+  MessageLoopForUI mainMessageLoop;
+
   {
     nsXREDirProvider dirProvider;
     rv = dirProvider.Initialize(gAppData->directory, gAppData->xreDirectory);
     if (NS_FAILED(rv))
       return 1;
 
     // Check for -register, which registers chrome and then exits immediately.
     ar = CheckArg("register", PR_TRUE);
@@ -3368,23 +3373,43 @@ XRE_main(int argc, char* argv[], const n
                                      PromiseFlatCString(profileName).get());
 #endif /* MOZ_ENABLE_XREMOTE */
 
             // enable win32 DDE responses and Mac appleevents responses
             nativeApp->Enable();
           }
 
           MOZ_SPLASHSCREEN_UPDATE(90);
-
-          NS_TIMELINE_ENTER("appStartup->Run");
-          rv = appStartup->Run();
-          NS_TIMELINE_LEAVE("appStartup->Run");
-          if (NS_FAILED(rv)) {
-            NS_ERROR("failed to run appstartup");
-            gLogConsoleErrors = PR_TRUE;
+          {
+#if 0 && defined(OS_LINUX)
+            // The lifetime of the BACKGROUND_X11 thread is a subset
+            // of the IO thread so we start it now.
+             scoped_ptr<base::Thread> x11Thread(
+               new BrowserProcessSubThread(BrowserProcessSubThread::BACKGROUND_X11));
+             if (NS_UNLIKELY(!x11Thread->Start())) {
+               NS_ERROR("Failed to create chromium's X11 thread!");
+               return NS_ERROR_FAILURE;
+             }
+#endif
+            scoped_ptr<base::Thread> ipcThread(
+              new BrowserProcessSubThread(BrowserProcessSubThread::IO));
+            base::Thread::Options options;
+            options.message_loop_type = MessageLoop::TYPE_IO;
+            if (NS_UNLIKELY(!ipcThread->StartWithOptions(options))) {
+              NS_ERROR("Failed to create chromium's IO thread!");
+              return NS_ERROR_FAILURE;
+            }
+
+            NS_TIMELINE_ENTER("appStartup->Run");
+            rv = appStartup->Run();
+            NS_TIMELINE_LEAVE("appStartup->Run");
+            if (NS_FAILED(rv)) {
+              NS_ERROR("failed to run appstartup");
+              gLogConsoleErrors = PR_TRUE;
+            }
           }
 
           // Check for an application initiated restart.  This is one that
           // corresponds to nsIAppStartup.quit(eRestart)
           if (rv == NS_SUCCESS_RESTART_APP) {
             needsRestart = PR_TRUE;
             appInitiatedRestart = PR_TRUE;
           }