hooked up the plugin manager to the webshell.

git-svn-id: svn://10.0.0.236/trunk@6578 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
michaelp%netscape.com 1998-07-27 23:08:52 +00:00
parent feaa1ebcb4
commit 1c0dd973b4
9 changed files with 148 additions and 69 deletions

View File

@ -31,6 +31,9 @@
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "plevent.h" #include "plevent.h"
#include "nsplugin.h"
#include "nsIPluginHost.h"
#include "nsPluginsCID.h"
#include "prlog.h" #include "prlog.h"
@ -154,6 +157,8 @@ public:
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent); static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
static nsresult CreatePluginHost(void);
protected: protected:
nsIScriptGlobalObject *mScriptGlobal; nsIScriptGlobalObject *mScriptGlobal;
nsIScriptContext* mScriptContext; nsIScriptContext* mScriptContext;
@ -181,6 +186,9 @@ protected:
nsScrollPreference mScrollPref; nsScrollPreference mScrollPref;
void ReleaseChildren(); void ReleaseChildren();
static nsIPluginHost *mPluginHost;
static nsIPluginManager *mPluginManager;
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -202,10 +210,39 @@ static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID);
// XXX not sure // XXX not sure
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID); static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
nsIPluginHost *nsWebShell::mPluginHost = nsnull;
nsIPluginManager *nsWebShell::mPluginManager = nsnull;
nsresult nsWebShell::CreatePluginHost(void)
{
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == mPluginManager)
{
rv = NSRepository::CreateInstance(kCPluginHostCID, nsnull,
kIPluginManagerIID,
(void**)&mPluginManager);
if (NS_OK == rv)
{
if (NS_OK == mPluginManager->QueryInterface(kIPluginHostIID,
(void **)&mPluginHost))
{
mPluginHost->Init();
mPluginHost->LoadPlugins();
}
}
}
return rv;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Note: operator new zeros our memory // Note: operator new zeros our memory
@ -309,6 +346,11 @@ nsWebShell::QueryCapability(const nsIID &aIID, void** aInstancePtr)
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
//XXX this seems a little wrong. MMP
if (nsnull != mPluginManager)
return mPluginManager->QueryInterface(aIID, aInstancePtr);
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }
@ -349,6 +391,11 @@ nsWebShell::Init(nsNativeWidget aNativeParent,
const nsRect& aBounds, const nsRect& aBounds,
nsScrollPreference aScrolling) nsScrollPreference aScrolling)
{ {
//XXX make sure plugins have started up. this really needs to
//be associated with the nsIContentViewerContainer interfaces,
//not the nsIWebShell interfaces. this is a hack. MMP
CreatePluginHost();
mScrollPref = aScrolling; mScrollPref = aScrolling;
WEB_TRACE(WEB_TRACE_CALLS, WEB_TRACE(WEB_TRACE_CALLS,

View File

@ -28,6 +28,7 @@
#include "nsplugin.h" #include "nsplugin.h"
#include "nsIPluginHost.h" #include "nsIPluginHost.h"
#include "nsString.h" #include "nsString.h"
#include "nsIContentViewerContainer.h"
#include "prmem.h" #include "prmem.h"
#define nsObjectFrameSuper nsLeafFrame #define nsObjectFrameSuper nsLeafFrame
@ -199,38 +200,46 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
} }
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID); static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
nsISupports *container, *pluginsup; nsISupports *container, *pluginsup;
nsIPluginHost *pm; nsIPluginHost *pm;
nsIContentViewerContainer *cv;
rv = aPresContext.GetContainer(&container); rv = aPresContext.GetContainer(&container);
if (NS_OK == rv) { if (NS_OK == rv) {
rv = container->QueryInterface(kIPluginHostIID, (void **)&pm); rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv);
if (NS_OK == rv) { if (NS_OK == rv) {
nsString type; rv = cv->QueryCapability(kIPluginHostIID, (void **)&pm);
char *buf;
PRInt32 buflen;
mContent->GetAttribute(nsString("type"), type); if (NS_OK == rv) {
nsString type;
char *buf;
PRInt32 buflen;
buflen = type.Length(); mContent->GetAttribute(nsString("type"), type);
if (buflen > 0) { buflen = type.Length();
buf = (char *)PR_Malloc(buflen + 1);
if (nsnull != buf) { if (buflen > 0) {
type.ToCString(buf, buflen + 1); buf = (char *)PR_Malloc(buflen + 1);
rv = pm->InstantiatePlugin(buf, &pluginsup); if (nsnull != buf) {
type.ToCString(buf, buflen + 1);
if (NS_OK == rv) { rv = pm->InstantiatePlugin(buf, &pluginsup);
if (NS_OK == rv) {
}
} }
} }
NS_RELEASE(pm);
} }
NS_RELEASE(pm); NS_RELEASE(cv);
} }
NS_RELEASE(container); NS_RELEASE(container);

View File

@ -28,6 +28,7 @@
#include "nsplugin.h" #include "nsplugin.h"
#include "nsIPluginHost.h" #include "nsIPluginHost.h"
#include "nsString.h" #include "nsString.h"
#include "nsIContentViewerContainer.h"
#include "prmem.h" #include "prmem.h"
#define nsObjectFrameSuper nsLeafFrame #define nsObjectFrameSuper nsLeafFrame
@ -199,38 +200,46 @@ nsObjectFrame::Reflow(nsIPresContext& aPresContext,
} }
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID); static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
nsISupports *container, *pluginsup; nsISupports *container, *pluginsup;
nsIPluginHost *pm; nsIPluginHost *pm;
nsIContentViewerContainer *cv;
rv = aPresContext.GetContainer(&container); rv = aPresContext.GetContainer(&container);
if (NS_OK == rv) { if (NS_OK == rv) {
rv = container->QueryInterface(kIPluginHostIID, (void **)&pm); rv = container->QueryInterface(kIContentViewerContainerIID, (void **)&cv);
if (NS_OK == rv) { if (NS_OK == rv) {
nsString type; rv = cv->QueryCapability(kIPluginHostIID, (void **)&pm);
char *buf;
PRInt32 buflen;
mContent->GetAttribute(nsString("type"), type); if (NS_OK == rv) {
nsString type;
char *buf;
PRInt32 buflen;
buflen = type.Length(); mContent->GetAttribute(nsString("type"), type);
if (buflen > 0) { buflen = type.Length();
buf = (char *)PR_Malloc(buflen + 1);
if (nsnull != buf) { if (buflen > 0) {
type.ToCString(buf, buflen + 1); buf = (char *)PR_Malloc(buflen + 1);
rv = pm->InstantiatePlugin(buf, &pluginsup); if (nsnull != buf) {
type.ToCString(buf, buflen + 1);
if (NS_OK == rv) { rv = pm->InstantiatePlugin(buf, &pluginsup);
if (NS_OK == rv) {
}
} }
} }
NS_RELEASE(pm);
} }
NS_RELEASE(pm); NS_RELEASE(cv);
} }
NS_RELEASE(container); NS_RELEASE(container);

View File

@ -18,10 +18,10 @@ IGNORE_MANIFEST=1
THIS_MAKEFILE=nglayout.mak THIS_MAKEFILE=nglayout.mak
THAT_MAKEFILE=makefile.win THAT_MAKEFILE=makefile.win
!if !defined(MODULAR_NETLIB) || !defined(STANDALONE_IMAGE_LIB) !if !defined(MODULAR_NETLIB) || !defined(STANDALONE_IMAGE_LIB) || !defined(NGLAYOUT_PLUGINS)
ERR_MSG = ^ ERR_MSG = ^
You need to set MODULAR_NETLIB=1 and STANDALONE_IMAGE_LIB=1 ^ You need to set MODULAR_NETLIB=1, STANDALONE_IMAGE_LIB=1 ^
in your environment. and NGLAYOUT_PLUGINS=1 in your environment.
!ERROR $(ERR_MSG) !ERROR $(ERR_MSG)
!endif !endif

View File

@ -26,7 +26,7 @@ REQUIRES=xpcom raptor dom js netlib
EXTRA_DSO_LDOPTS += -lm EXTRA_DSO_LDOPTS += -lm
INCLUDES += -I../public -I$(PUBLIC)/raptor -I$(PUBLIC)/xpcom -I$(PUBLIC)/dom -I$(PUBLIC)/js -I(PUBLIC)/netlib INCLUDES += -I../public -I$(PUBLIC)/raptor -I$(PUBLIC)/xpcom -I$(PUBLIC)/dom -I$(PUBLIC)/js -I$(PUBLIC)/netlib -I$(PUBLIC)/plugin -I$(PUBLIC)/java
DEFINES = -D_IMPL_NS_WEB DEFINES = -D_IMPL_NS_WEB

View File

@ -38,7 +38,8 @@ CPP_OBJS= \
$(NULL) $(NULL)
LINCS=-I..\public -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \ LINCS=-I..\public -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
-I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib -I$(PUBLIC)\dom -I$(PUBLIC)\js -I$(PUBLIC)\netlib \
-I$(PUBLIC)\plugin -I$(PUBLIC)\java
MAKE_OBJ_TYPE = DLL MAKE_OBJ_TYPE = DLL
DLLNAME = raptorweb DLLNAME = raptorweb

View File

@ -31,6 +31,9 @@
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "plevent.h" #include "plevent.h"
#include "nsplugin.h"
#include "nsIPluginHost.h"
#include "nsPluginsCID.h"
#include "prlog.h" #include "prlog.h"
@ -154,6 +157,8 @@ public:
static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent); static nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent);
static nsresult CreatePluginHost(void);
protected: protected:
nsIScriptGlobalObject *mScriptGlobal; nsIScriptGlobalObject *mScriptGlobal;
nsIScriptContext* mScriptContext; nsIScriptContext* mScriptContext;
@ -181,6 +186,9 @@ protected:
nsScrollPreference mScrollPref; nsScrollPreference mScrollPref;
void ReleaseChildren(); void ReleaseChildren();
static nsIPluginHost *mPluginHost;
static nsIPluginManager *mPluginManager;
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -202,10 +210,39 @@ static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID);
// XXX not sure // XXX not sure
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID); static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
nsIPluginHost *nsWebShell::mPluginHost = nsnull;
nsIPluginManager *nsWebShell::mPluginManager = nsnull;
nsresult nsWebShell::CreatePluginHost(void)
{
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == mPluginManager)
{
rv = NSRepository::CreateInstance(kCPluginHostCID, nsnull,
kIPluginManagerIID,
(void**)&mPluginManager);
if (NS_OK == rv)
{
if (NS_OK == mPluginManager->QueryInterface(kIPluginHostIID,
(void **)&mPluginHost))
{
mPluginHost->Init();
mPluginHost->LoadPlugins();
}
}
}
return rv;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Note: operator new zeros our memory // Note: operator new zeros our memory
@ -309,6 +346,11 @@ nsWebShell::QueryCapability(const nsIID &aIID, void** aInstancePtr)
AddRef(); AddRef();
return NS_OK; return NS_OK;
} }
//XXX this seems a little wrong. MMP
if (nsnull != mPluginManager)
return mPluginManager->QueryInterface(aIID, aInstancePtr);
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }
@ -349,6 +391,11 @@ nsWebShell::Init(nsNativeWidget aNativeParent,
const nsRect& aBounds, const nsRect& aBounds,
nsScrollPreference aScrolling) nsScrollPreference aScrolling)
{ {
//XXX make sure plugins have started up. this really needs to
//be associated with the nsIContentViewerContainer interfaces,
//not the nsIWebShell interfaces. this is a hack. MMP
CreatePluginHost();
mScrollPref = aScrolling; mScrollPref = aScrolling;
WEB_TRACE(WEB_TRACE_CALLS, WEB_TRACE(WEB_TRACE_CALLS,

View File

@ -23,10 +23,7 @@
#include "nsWidgetsCID.h" #include "nsWidgetsCID.h"
#include "nsGfxCIID.h" #include "nsGfxCIID.h"
#include "nsViewsCID.h" #include "nsViewsCID.h"
#ifdef VIEWER_PLUGINS
#include "nsPluginsCID.h" #include "nsPluginsCID.h"
#endif
#include "nsIBrowserWindow.h" #include "nsIBrowserWindow.h"
#include "nsIWebShell.h" #include "nsIWebShell.h"
@ -77,10 +74,7 @@ static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID); static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kCDocumentLoaderCID, NS_DOCUMENTLOADER_CID); static NS_DEFINE_IID(kCDocumentLoaderCID, NS_DOCUMENTLOADER_CID);
static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID); static NS_DEFINE_IID(kThrobberCID, NS_THROBBER_CID);
#ifdef VIEWER_PLUGINS
static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID); static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID);
#endif
extern "C" void extern "C" void
NS_SetupRegistry() NS_SetupRegistry()
@ -110,8 +104,5 @@ NS_SetupRegistry()
NSRepository::RegisterFactory(kCDocumentLoaderCID, WEB_DLL, PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kCDocumentLoaderCID, WEB_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kThrobberCID, WEB_DLL, PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kThrobberCID, WEB_DLL, PR_FALSE, PR_FALSE);
NSRepository::RegisterFactory(kPrefCID, PREF_DLL, PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kPrefCID, PREF_DLL, PR_FALSE, PR_FALSE);
#ifdef VIEWER_PLUGINS
NSRepository::RegisterFactory(kCPluginHostCID, PLUGIN_DLL, PR_FALSE, PR_FALSE); NSRepository::RegisterFactory(kCPluginHostCID, PLUGIN_DLL, PR_FALSE, PR_FALSE);
#endif
} }

View File

@ -35,11 +35,6 @@
#include "JSConsole.h" #include "JSConsole.h"
#endif #endif
#ifdef VIEWER_PLUGINS
static nsIPluginManager *gPluginManager = nsnull;
static nsIPluginHost *gPluginHost = nsnull;
#endif
extern nsresult NS_NewBrowserWindowFactory(nsIFactory** aFactory); extern nsresult NS_NewBrowserWindowFactory(nsIFactory** aFactory);
extern "C" void NS_SetupRegistry(); extern "C" void NS_SetupRegistry();
extern "C" int NET_PollSockets(); extern "C" int NET_PollSockets();
@ -145,26 +140,6 @@ nsViewerApp::Initialize(int argc, char** argv)
} }
#endif #endif
#ifdef VIEWER_PLUGINS
if (nsnull == gPluginManager) {
rv = NSRepository::CreateInstance(kCPluginHostCID, nsnull,
kIPluginManagerIID,
(void**)&gPluginManager);
if (NS_OK==rv)
{
if (NS_OK == gPluginManager->QueryInterface(kIPluginHostIID,
(void **)&gPluginHost))
{
gPluginHost->Init();
gPluginHost->LoadPlugins();
}
}
// It's ok if we can't host plugins
rv = NS_OK;
}
#endif
// Finally process our arguments // Finally process our arguments
rv = ProcessArguments(argc, argv); rv = ProcessArguments(argc, argv);