// MccPluginHostCtrl.h : Declaration of the CMccPluginHostCtrl #ifndef __MCCPLUGINHOSTCTRL_H_ #define __MCCPLUGINHOSTCTRL_H_ #include "resource.h" // メイン シンボル #include #include "nsPluginWnd.h" class nsURLDataCallback; template class nsSimpleArray { Entry *m_pData; unsigned long m_nSize; unsigned long m_nMaxSize; unsigned long m_nExpandArrayBy; public: nsSimpleArray(unsigned long nExpandArrayBy = 10) : m_pData(NULL), m_nSize(0), m_nMaxSize(0), m_nExpandArrayBy(nExpandArrayBy) { } virtual ~nsSimpleArray() { Empty(); } Entry ElementAt(unsigned long aIndex) const { ATLASSERT(aIndex < m_nSize); return m_pData[aIndex]; } Entry operator[](unsigned long aIndex) const { return ElementAt(aIndex); } void AppendElement(Entry entry) { if (!m_pData) { m_nMaxSize = m_nExpandArrayBy; m_pData = (Entry *) malloc(sizeof(Entry) * m_nMaxSize); } else if (m_nSize == m_nMaxSize) { m_nMaxSize += m_nExpandArrayBy; m_pData = (Entry *) realloc(m_pData, sizeof(Entry) * m_nMaxSize); } ATLASSERT(m_pData); if (m_pData) { m_pData[m_nSize++] = entry; } } void RemoveElementAt(unsigned long nIndex) { ATLASSERT(aIndex < m_nSize); if (nIndex < m_nSize) { m_nSize--; if (m_nSize > 0) { m_pData[nIndex] = m_pData[m_nSize - 1]; m_nSize--; } } } void RemoveElement(Entry entry) { unsigned long i = 0; while (i < m_nSize) { if (m_pData[i] == entry) { m_nSize--; if (m_nSize > 0) { m_pData[i] = m_pData[m_nSize - 1]; m_nSize--; } continue; } i++; } } void Empty() { if (m_pData) { free(m_pData); m_pData = NULL; m_nSize = m_nMaxSize = 0; } } BOOL IsEmpty() const { return m_nSize == 0 ? TRUE : FALSE; } unsigned long Count() const { return m_nSize; } }; #define PLUGINS_FROM_IE 0x1 #define PLUGINS_FROM_NS4X 0x2 #define PLUGINS_FROM_NS6X 0x4 #define PLUGINS_FROM_MOZILLA 0x8 ///////////////////////////////////////////////////////////////////////////// // CMccPluginHostCtrl class ATL_NO_VTABLE CMccPluginHostCtrl : public CComObjectRootEx, public CStockPropImpl, public CComControl, public IPersistStreamInitImpl, public IOleControlImpl, public IOleObjectImpl, public IOleInPlaceActiveObjectImpl, public IViewObjectExImpl, public IOleInPlaceObjectWindowlessImpl, public ISupportErrorInfo, public IConnectionPointContainerImpl, public IPersistStorageImpl, public IPersistPropertyBagImpl, public IObjectSafetyImpl, public ISpecifyPropertyPagesImpl, public IQuickActivateImpl, public IDataObjectImpl, public IProvideClassInfo2Impl<&CLSID_MccPluginHostCtrl, &DIID__IMccPluginHostCtrlEvents, &LIBID_MCCPLUGINLib>, public IPropertyNotifySinkCP, public CComCoClass { protected: virtual ~CMccPluginHostCtrl(); public: CMccPluginHostCtrl(); DECLARE_REGISTRY_RESOURCEID(IDR_MCCPLUGINHOSTCTRL) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(CMccPluginHostCtrl) COM_INTERFACE_ENTRY(IMccPluginHostCtrl) COM_INTERFACE_ENTRY2(IDispatch, IMccPluginHostCtrl) COM_INTERFACE_ENTRY(IViewObjectEx) COM_INTERFACE_ENTRY(IViewObject2) COM_INTERFACE_ENTRY(IViewObject) COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY(IOleInPlaceObject) COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY(IOleInPlaceActiveObject) COM_INTERFACE_ENTRY(IOleControl) COM_INTERFACE_ENTRY(IOleObject) COM_INTERFACE_ENTRY(IPersistStreamInit) COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit) COM_INTERFACE_ENTRY(IObjectSafety) COM_INTERFACE_ENTRY(IPersistPropertyBag) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY(IConnectionPointContainer) COM_INTERFACE_ENTRY(IQuickActivate) COM_INTERFACE_ENTRY(IPersistStorage) COM_INTERFACE_ENTRY(IDataObject) COM_INTERFACE_ENTRY(IProvideClassInfo) COM_INTERFACE_ENTRY(IProvideClassInfo2) END_COM_MAP() BEGIN_PROP_MAP(CMccPluginHostCtrl) PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4) PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4) PROP_ENTRY("HWND", DISPID_HWND, CLSID_NULL) PROP_ENTRY("Text", DISPID_TEXT, CLSID_NULL) // Mozilla plugin host control properties PROP_ENTRY("type", 1, CLSID_NULL) PROP_ENTRY("src", 2, CLSID_NULL) PROP_ENTRY("pluginspage", 3, CLSID_NULL) // Example entries // PROP_ENTRY("Property Description", dispid, clsid) // PROP_PAGE(CLSID_StockColorPage) END_PROP_MAP() BEGIN_CONNECTION_POINT_MAP(CMccPluginHostCtrl) CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink) END_CONNECTION_POINT_MAP() BEGIN_MSG_MAP(CMccPluginHostCtrl) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_DESTROY, OnDestroy) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_PAINT, OnPaint) CHAIN_MSG_MAP(CComControl) END_MSG_MAP() // Handler prototypes: // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); // ISupportsErrorInfo STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) { static const IID* arr[] = { &IID_IMccPluginHostCtrl, }; for (int i=0; i m_Plugins; // Array of names and values to pass to the new plugin unsigned long m_nArgs; unsigned long m_nArgsMax; char **m_pszArgNames; char **m_pszArgValues; // Array of loaded plugins which is shared amongst instances of this control struct LoadedPluginInfo { TCHAR *szFullPath; // Path + plugin name HINSTANCE hInstance; DWORD nRefCount; NPPluginFuncs NPPFuncs; }; static nsSimpleArray m_LoadedPlugins; LoadedPluginInfo *m_pLoadedPlugin; NPWindow m_NPWindow; HRESULT CreatePluginList(unsigned long ulFlags); HRESULT CreatePluginListFrom(const TCHAR *szPluginsDir); HRESULT CleanupPluginList(); HRESULT GetPluginInfo(const TCHAR * pszPluginPath, PluginInfo *pInfo); public: NPP_t m_NPP; BOOL m_bPluginIsAlive; BOOL m_bCreatePluginFromStreamData; nsPluginWnd m_wndPlugin; // Struct holding pointers to the functions within the plugin NPPluginFuncs m_NPPFuncs; HRESULT GetWebBrowserApp(IWebBrowserApp **pBrowser); HRESULT GetBaseURL(TCHAR **szBaseURL); HRESULT AddPluginParam(const char *szName, const char *szValue); HRESULT LoadPluginByContentType(const TCHAR *pszContentType); HRESULT LoadPlugin(const TCHAR *pszPluginPath); HRESULT FindPluginPathByContentType(const TCHAR *pszContentType, TCHAR **ppszPluginPath); HRESULT UnloadPlugin(); HRESULT OpenURLStream(const TCHAR *szURL, void *pNotifyData, const void *pPostData, unsigned long nDataLength); HRESULT CreatePluginInstance(); HRESULT DestroyPluginInstance(); HRESULT SizeToFitPluginInstance(); }; #endif //__MCCPLUGINHOSTCTRL_H_