NOT PART OF BUILD. Bump development environment up to VS2002. Add support for windowless plugins. Factor out functionality from nsPluginHostCtrl into nsPluginHostWnd base class.

This commit is contained in:
locka%iol.ie 2005-08-28 20:00:31 +00:00
Родитель 6e481078c3
Коммит 7eb92dd53e
16 изменённых файлов: 2092 добавлений и 1338 удалений

Просмотреть файл

@ -1,38 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "stdafx.h"
#ifdef _ATL_STATIC_REGISTRY

Просмотреть файл

@ -1,39 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,

Просмотреть файл

@ -1,46 +1,44 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
*/
#include "stdafx.h"
#include "npn.h"
#include "Pluginhostctrl.h"
#include "nsPluginHostCtrl.h"
#include "nsPluginHostWnd.h"
static NPError
_OpenURL(NPP npp, const char *szURL, const char *szTarget, void *pNotifyData, const char *pData, uint32 len, NPBool isFile)
@ -65,14 +63,14 @@ _OpenURL(NPP npp, const char *szURL, const char *szTarget, void *pNotifyData, co
}
}
nsPluginHostCtrl *pCtrl = (nsPluginHostCtrl *) npp->ndata;
ATLASSERT(pCtrl);
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
// Other window targets
if (szTarget)
{
CComPtr<IWebBrowserApp> cpBrowser;
pCtrl->GetWebBrowserApp(&cpBrowser);
pWnd->GetWebBrowserApp(&cpBrowser);
if (!cpBrowser)
{
return NPERR_GENERIC_ERROR;
@ -156,7 +154,7 @@ _OpenURL(NPP npp, const char *szURL, const char *szTarget, void *pNotifyData, co
}
USES_CONVERSION;
HRESULT hr = pCtrl->OpenURLStream(A2CT(szURL), pNotifyData, postData, postDataLen);
HRESULT hr = pWnd->OpenURLStream(A2CT(szURL), pNotifyData, postData, postDataLen);
return SUCCEEDED(hr) ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
}
@ -174,6 +172,9 @@ NPN_GetURLNotify(NPP npp,
const char* target,
void* notifyData)
{
if (strncmp("javascript:", relativeURL, 11) == 0)
return NPERR_INVALID_URL;
return _OpenURL(npp, relativeURL, target, notifyData, NULL, 0, FALSE);
}
@ -253,12 +254,12 @@ NPN_Status(NPP npp, const char *message)
return;
}
nsPluginHostCtrl *pCtrl = (nsPluginHostCtrl *) npp->ndata;
ATLASSERT(pCtrl);
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
// Update the status bar in the browser
CComPtr<IWebBrowserApp> cpBrowser;
pCtrl->GetWebBrowserApp(&cpBrowser);
pWnd->GetWebBrowserApp(&cpBrowser);
if (cpBrowser)
{
USES_CONVERSION;
@ -310,7 +311,20 @@ NPN_InvalidateRect(NPP npp, NPRect *invalidRect)
return;
}
// TODO - windowless plugins
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
RECT *prc = NULL;
RECT rcInvalid;
if (invalidRect)
{
prc = &rcInvalid;
prc->left = invalidRect->left;
prc->bottom = invalidRect->bottom;
prc->top = invalidRect->top;
prc->right = invalidRect->right;
}
pWnd->InvalidateRect(prc, FALSE);
}
@ -322,7 +336,10 @@ NPN_InvalidateRegion(NPP npp, NPRegion invalidRegion)
{
return;
}
// TODO - windowless plugins
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
pWnd->InvalidateRgn(invalidRegion, FALSE);
}
@ -334,7 +351,9 @@ NPN_ForceRedraw(NPP npp)
{
return;
}
// TODO - windowless plugins
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
pWnd->InvalidateRect(NULL, FALSE);
}
////////////////////////////////////////////////////////////////////////
@ -351,28 +370,26 @@ NPN_GetValue(NPP npp, NPNVariable variable, void *result)
return NPERR_INVALID_PARAM;
}
nsPluginHostCtrl *pCtrl = (nsPluginHostCtrl *) npp->ndata;
ATLASSERT(pCtrl);
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
CComPtr<IWebBrowserApp> cpBrowser;
pCtrl->GetWebBrowserApp(&cpBrowser);
pWnd->GetWebBrowserApp(&cpBrowser);
// Test the variable
if (variable == NPNVnetscapeWindow)
{
*((HWND *) result) = pCtrl->m_wndPlugin.m_hWnd;
}
else if (variable == NPNVjavascriptEnabledBool)
switch (variable)
{
case NPNVnetscapeWindow:
*((HWND *) result) = pWnd->m_hWnd;
break;
case NPNVjavascriptEnabledBool:
// TODO
*((NPBool *) result) = TRUE;
}
else if (variable == NPNVasdEnabledBool) // Smart update
{
*((NPBool *) result) = FALSE;
}
else if (variable == NPNVisOfflineBool)
{
break;
case NPNVasdEnabledBool:
*((NPBool *) result) = FALSE;
break;
case NPNVisOfflineBool:
*((NPBool *) result) = FALSE;
if (cpBrowser)
{
@ -384,12 +401,10 @@ NPN_GetValue(NPP npp, NPNVariable variable, void *result)
*((NPBool *) result) = (bOffline == VARIANT_TRUE) ? TRUE : FALSE;
}
}
}
else
{
break;
default:
return NPERR_GENERIC_ERROR;
}
return NPERR_NO_ERROR;
}
@ -403,9 +418,22 @@ NPN_SetValue(NPP npp, NPPVariable variable, void *result)
return NPERR_INVALID_INSTANCE_ERROR;
}
// TODO windowless
// NPPVpluginWindowBool
// NPPVpluginTransparentBool
nsPluginHostWnd *pWnd = (nsPluginHostWnd *) npp->ndata;
ATLASSERT(pWnd);
switch (variable)
{
case NPPVpluginWindowBool:
{
pWnd->SetPluginWindowless((result == NULL) ? true : false);
}
return NPERR_NO_ERROR;
case NPPVpluginTransparentBool:
{
pWnd->SetPluginTransparent((result != NULL) ? true : false);
}
return NPERR_NO_ERROR;
}
return NPERR_GENERIC_ERROR;
}
@ -435,7 +463,7 @@ NPN_GetJavaEnv(void)
const char * NP_EXPORT
NPN_UserAgent(NPP npp)
{
return NULL;
return "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6";
}

Просмотреть файл

@ -1,39 +1,35 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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 ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef NPN_H
#define NPN_H

Просмотреть файл

@ -1,54 +1,41 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "stdafx.h"
#include "Pluginhostctrl.h"
#include "nsPluginHostCtrl.h"
#include "nsURLDataCallback.h"
#include "npn.h"
#define NS_4XPLUGIN_CALLBACK(_type, _name) _type (__stdcall * _name)
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_4XPLUGIN_CALLBACK(NPError, NP_PLUGINSHUTDOWN) (void);
const kArraySizeIncrement = 10;
nsSimpleArray<nsPluginHostCtrl::LoadedPluginInfo *> nsPluginHostCtrl::m_LoadedPlugins;
/////////////////////////////////////////////////////////////////////////////
// nsPluginHostCtrl
@ -56,128 +43,12 @@ nsSimpleArray<nsPluginHostCtrl::LoadedPluginInfo *> nsPluginHostCtrl::m_LoadedPl
nsPluginHostCtrl::nsPluginHostCtrl()
{
m_bWindowOnly = TRUE;
m_bPluginIsAlive = FALSE;
m_bCreatePluginFromStreamData = FALSE;
m_pLoadedPlugin = NULL;
m_nArgs = 0;
m_nArgsMax = 0;
m_pszArgNames = NULL;
m_pszArgValues = NULL;
InitPluginCallbacks();
memset(&m_NPPFuncs, 0, sizeof(m_NPPFuncs));
}
nsPluginHostCtrl::~nsPluginHostCtrl()
{
}
LRESULT nsPluginHostCtrl::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
SetWindowLong(GWL_STYLE, GetWindowLong(GWL_STYLE) | WS_CLIPCHILDREN);
// Load a list of plugins
CreatePluginList(
PLUGINS_FROM_IE | PLUGINS_FROM_NS4X |
PLUGINS_FROM_NS6X | PLUGINS_FROM_MOZILLA);
HRESULT hr = E_FAIL;
if (m_bstrContentType.Length() == 0 &&
m_bstrSource.Length() != 0)
{
USES_CONVERSION;
// Do a late instantiation of the plugin based on the content type of
// the stream data.
m_bCreatePluginFromStreamData = TRUE;
hr = OpenURLStream(OLE2T(m_bstrSource), NULL, NULL, 0);
}
else
{
// Create a plugin based upon the specified content type property
USES_CONVERSION;
hr = LoadPluginByContentType(OLE2T(m_bstrContentType));
if (SUCCEEDED(hr))
{
hr = CreatePluginInstance();
if (m_bstrSource.Length())
{
OpenURLStream(OLE2T(m_bstrSource), NULL, NULL, 0);
}
}
}
return SUCCEEDED(hr) ? 0 : -1;
}
LRESULT nsPluginHostCtrl::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
DestroyPluginInstance();
UnloadPlugin();
CleanupPluginList();
return 0;
}
LRESULT nsPluginHostCtrl::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
SizeToFitPluginInstance();
return 0;
}
LRESULT nsPluginHostCtrl::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
PAINTSTRUCT ps;
HDC hdc;
RECT rc;
hdc = BeginPaint(&ps);
GetClientRect(&rc);
FillRect(hdc, &rc, (HBRUSH) GetStockObject(GRAY_BRUSH));
EndPaint(&ps);
return 0;
}
NPNetscapeFuncs nsPluginHostCtrl::g_NPNFuncs;
HRESULT nsPluginHostCtrl::InitPluginCallbacks()
{
static BOOL gCallbacksSet = FALSE;
if (gCallbacksSet)
{
return S_OK;
}
gCallbacksSet = TRUE;
memset(&g_NPNFuncs, 0, sizeof(g_NPNFuncs));
g_NPNFuncs.size = sizeof(g_NPNFuncs);
g_NPNFuncs.version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
g_NPNFuncs.geturl = NewNPN_GetURLProc(NPN_GetURL);
g_NPNFuncs.posturl = NewNPN_PostURLProc(NPN_PostURL);
g_NPNFuncs.requestread = NewNPN_RequestReadProc(NPN_RequestRead);
g_NPNFuncs.newstream = NewNPN_NewStreamProc(NPN_NewStream);
g_NPNFuncs.write = NewNPN_WriteProc(NPN_Write);
g_NPNFuncs.destroystream = NewNPN_DestroyStreamProc(NPN_DestroyStream);
g_NPNFuncs.status = NewNPN_StatusProc(NPN_Status);
g_NPNFuncs.uagent = NewNPN_UserAgentProc(NPN_UserAgent);
g_NPNFuncs.memalloc = NewNPN_MemAllocProc(NPN_MemAlloc);
g_NPNFuncs.memfree = NewNPN_MemFreeProc(NPN_MemFree);
g_NPNFuncs.memflush = NewNPN_MemFlushProc(NPN_MemFlush);
g_NPNFuncs.reloadplugins = NewNPN_ReloadPluginsProc(NPN_ReloadPlugins);
g_NPNFuncs.getJavaEnv = NewNPN_GetJavaEnvProc(NPN_GetJavaEnv);
g_NPNFuncs.getJavaPeer = NewNPN_GetJavaPeerProc(NPN_GetJavaPeer);
g_NPNFuncs.geturlnotify = NewNPN_GetURLNotifyProc(NPN_GetURLNotify);
g_NPNFuncs.posturlnotify = NewNPN_PostURLNotifyProc(NPN_PostURLNotify);
g_NPNFuncs.getvalue = NewNPN_GetValueProc(NPN_GetValue);
g_NPNFuncs.setvalue = NewNPN_SetValueProc(NPN_SetValue);
g_NPNFuncs.invalidaterect = NewNPN_InvalidateRectProc(NPN_InvalidateRect);
g_NPNFuncs.invalidateregion = NewNPN_InvalidateRegionProc(NPN_InvalidateRegion);
g_NPNFuncs.forceredraw = NewNPN_ForceRedrawProc(NPN_ForceRedraw);
return S_OK;
}
HRESULT nsPluginHostCtrl::GetWebBrowserApp(IWebBrowserApp **pBrowser)
{
@ -210,591 +81,6 @@ HRESULT nsPluginHostCtrl::GetWebBrowserApp(IWebBrowserApp **pBrowser)
return S_OK;
}
HRESULT nsPluginHostCtrl::GetBaseURL(TCHAR **ppszBaseURL)
{
ATLASSERT(ppszBaseURL);
*ppszBaseURL = NULL;
CComPtr<IWebBrowserApp> cpWebBrowser;
GetWebBrowserApp(&cpWebBrowser);
if (!cpWebBrowser)
{
return E_FAIL;
}
USES_CONVERSION;
CComBSTR bstrURL;
cpWebBrowser->get_LocationURL(&bstrURL);
DWORD cbBaseURL = (bstrURL.Length() + 1) * sizeof(WCHAR);
DWORD cbBaseURLUsed = 0;
WCHAR *pszBaseURL = (WCHAR *) malloc(cbBaseURL);
ATLASSERT(pszBaseURL);
CoInternetParseUrl(
bstrURL.m_str,
PARSE_ROOTDOCUMENT,
0,
pszBaseURL,
cbBaseURL,
&cbBaseURLUsed,
0);
*ppszBaseURL = _tcsdup(W2T(pszBaseURL));
free(pszBaseURL);
return S_OK;
}
HRESULT nsPluginHostCtrl::LoadPluginByContentType(const TCHAR *pszContentType)
{
TCHAR * pszPluginPath = NULL;
// Set the content type
USES_CONVERSION;
put_PluginContentType(T2OLE(pszContentType));
// Search for a plugin that can handle this content
HRESULT hr = FindPluginPathByContentType(pszContentType, &pszPluginPath);
if (FAILED(hr))
{
// Try the default 'catch-all' plugin
hr = FindPluginPathByContentType(_T("*"), &pszPluginPath);
if (FAILED(hr))
{
return hr;
}
}
hr = LoadPlugin(pszPluginPath);
free(pszPluginPath);
return hr;
}
HRESULT nsPluginHostCtrl::CreatePluginList(unsigned long ulFlags)
{
// This function trawls through the plugin directory and builds a list
// of plugins and what MIME types each plugin handles.
CleanupPluginList();
// Try and obtain a path to the plugins in Netscape 6.x or Mozilla
if (ulFlags & PLUGINS_FROM_NS6X ||
ulFlags & PLUGINS_FROM_MOZILLA)
{
// TODO search for Mozilla/NS 6.x plugins dir
}
// Try and obtain a path to the plugins in Netscape 4.x
if (ulFlags & PLUGINS_FROM_NS4X)
{
TCHAR szPluginsDir[_MAX_PATH];
memset(szPluginsDir, 0, sizeof(szPluginsDir));
CRegKey keyNS;
const TCHAR *kNav4xKey = _T("Software\\Netscape\\Netscape Navigator");
if (keyNS.Open(HKEY_LOCAL_MACHINE, kNav4xKey, KEY_READ) == ERROR_SUCCESS)
{
TCHAR szVersion[10];
DWORD nVersion = sizeof(szVersion) / sizeof(szVersion[0]);
keyNS.QueryValue(szVersion, _T("CurrentVersion"), &nVersion);
CRegKey keyVersion;
if (keyVersion.Open(keyNS, szVersion, KEY_READ) == ERROR_SUCCESS)
{
CRegKey keyMain;
if (keyMain.Open(keyVersion, _T("Main"), KEY_READ) == ERROR_SUCCESS)
{
DWORD nPluginsDir = sizeof(szPluginsDir) / sizeof(szPluginsDir[0]);
keyMain.QueryValue(szPluginsDir, _T("Plugins Directory"), &nPluginsDir);
keyMain.Close();
}
keyVersion.Close();
}
keyNS.Close();
}
if (szPluginsDir[0])
{
CreatePluginListFrom(szPluginsDir);
}
}
// Try and obtain a path to the plugins in Internet Explorer
if (ulFlags & PLUGINS_FROM_IE)
{
TCHAR szPluginsDir[_MAX_PATH];
memset(szPluginsDir, 0, sizeof(szPluginsDir));
CRegKey keyIE;
const TCHAR *kIEKey = _T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\IEXPLORE.EXE");
if (keyIE.Open(HKEY_LOCAL_MACHINE, kIEKey, KEY_READ) == ERROR_SUCCESS)
{
DWORD nPluginsDir = sizeof(szPluginsDir) / sizeof(szPluginsDir[0]);
keyIE.QueryValue(szPluginsDir, _T("Path"), &nPluginsDir);
TCHAR *szSemiColon = _tcschr(szPluginsDir, _TCHAR(';'));
if (szSemiColon)
{
*szSemiColon = _TCHAR('\0');
}
ULONG nLen = _tcslen(szPluginsDir);
if (nLen > 0 && szPluginsDir[nLen - 1] == _TCHAR('\\'))
{
szPluginsDir[nLen - 1] = _TCHAR('\0');
}
_tcscat(szPluginsDir, _T("\\Plugins"));
keyIE.Close();
}
if (szPluginsDir[0])
{
CreatePluginListFrom(szPluginsDir);
}
}
return S_OK;
}
HRESULT nsPluginHostCtrl::CreatePluginListFrom(const TCHAR *szPluginsDir)
{
HANDLE hFind;
WIN32_FIND_DATA finddata;
// Change to the plugin directory
TCHAR szCurrentDir[MAX_PATH + 1];
GetCurrentDirectory(sizeof(szCurrentDir) / sizeof(szCurrentDir[0]), szCurrentDir);
SetCurrentDirectory(szPluginsDir);
// Search for files matching the "np*dll" pattern
hFind = FindFirstFile(_T("np*dll"), &finddata);
if (hFind != INVALID_HANDLE_VALUE)
{
do {
PluginInfo *pInfo = new PluginInfo;
if (!pInfo)
{
CleanupPluginList();
SetCurrentDirectory(szCurrentDir);
return E_OUTOFMEMORY;
}
if (SUCCEEDED(GetPluginInfo(finddata.cFileName, pInfo)))
{
pInfo->szPluginName = _tcsdup(finddata.cFileName);
pInfo->szPluginPath = _tcsdup(szPluginsDir);
m_Plugins.AppendElement(pInfo);
}
else
{
ATLTRACE(_T("Error: Cannot plugin info for \"%s\".\n"), finddata.cFileName);
delete pInfo;
}
} while (FindNextFile(hFind, &finddata));
FindClose(hFind);
}
SetCurrentDirectory(szCurrentDir);
return S_OK;
}
HRESULT nsPluginHostCtrl::CleanupPluginList()
{
// Free the memory used by the plugin info list
for (unsigned long i = 0; i < m_Plugins.Count(); i++)
{
PluginInfo *pI = m_Plugins[i];
if (pI->szMIMEType)
free(pI->szMIMEType);
if (pI->szPluginName)
free(pI->szPluginName);
if (pI->szPluginPath)
free(pI->szPluginPath);
free(pI);
}
m_Plugins.Empty();
return S_OK;
}
HRESULT nsPluginHostCtrl::GetPluginInfo(const TCHAR *pszPluginPath, PluginInfo *pInfo)
{
// Get the version info from the plugin
USES_CONVERSION;
DWORD nVersionInfoSize;
DWORD nZero = 0;
void *pVersionInfo = NULL;
nVersionInfoSize = GetFileVersionInfoSize((TCHAR *)pszPluginPath, &nZero);
if (nVersionInfoSize)
{
pVersionInfo = malloc(nVersionInfoSize);
}
if (!pVersionInfo)
{
return E_OUTOFMEMORY;
}
GetFileVersionInfo((TCHAR *)pszPluginPath, NULL, nVersionInfoSize, pVersionInfo);
// Extract the MIMEType info
TCHAR *szValue = NULL;
UINT nValueLength = 0;
if (!VerQueryValue(pVersionInfo,
_T("\\StringFileInfo\\040904E4\\MIMEType"),
(void **) &szValue, &nValueLength))
{
return E_FAIL;
}
if (pInfo)
{
pInfo->szMIMEType = _tcsdup(szValue);
}
free(pVersionInfo);
return S_OK;
}
HRESULT nsPluginHostCtrl::FindPluginPathByContentType(const TCHAR *pszContentType, TCHAR **ppszPluginPath)
{
*ppszPluginPath = NULL;
if (pszContentType == NULL)
{
return E_FAIL;
}
// Search the list of plugins for one that will handle the content type
TCHAR szPluginPath[_MAX_PATH + 1];
unsigned long nContentType = _tcslen(pszContentType);
for (unsigned long i = 0; i < m_Plugins.Count(); i++)
{
PluginInfo *pI = m_Plugins[i];
if (pI->szMIMEType)
{
TCHAR *pszMIMEType = pI->szMIMEType;
do {
if (_tcsncmp(pszContentType, pszMIMEType, nContentType) == 0)
{
// Found a match
_tmakepath(szPluginPath, NULL,
pI->szPluginPath, pI->szPluginName, NULL);
*ppszPluginPath = _tcsdup(szPluginPath);
return S_OK;
}
// Check the other types the plugin handles
pszMIMEType = _tcschr(pszMIMEType, TCHAR('|'));
if (pszMIMEType)
{
pszMIMEType++;
}
} while (pszMIMEType && *pszMIMEType);
}
}
return E_FAIL;
}
HRESULT nsPluginHostCtrl::LoadPlugin(const TCHAR *szPluginPath)
{
ATLASSERT(m_pLoadedPlugin == NULL);
if (m_pLoadedPlugin)
{
return E_UNEXPECTED;
}
// TODO critical section
// Test if the plugin has already been loaded
for (unsigned long i = 0; i < m_LoadedPlugins.Count(); i++)
{
if (_tcscmp(m_LoadedPlugins[i]->szFullPath, szPluginPath) == 0)
{
m_pLoadedPlugin = m_LoadedPlugins[i];
memcpy(&m_NPPFuncs, &m_pLoadedPlugin->NPPFuncs, sizeof(m_NPPFuncs));
m_pLoadedPlugin->nRefCount++;
return S_OK;
}
}
// Plugin library is being loaded for the first time so initialise it
// and store an entry in the loaded plugins array.
HINSTANCE hInstance = LoadLibrary(szPluginPath);
if (!hInstance)
{
return E_FAIL;
}
m_pLoadedPlugin = new LoadedPluginInfo;
if (!m_pLoadedPlugin)
{
ATLASSERT(m_pLoadedPlugin);
return E_OUTOFMEMORY;
}
// Get the plugin function entry points
NP_GETENTRYPOINTS pfnGetEntryPoints =
(NP_GETENTRYPOINTS) GetProcAddress(hInstance, "NP_GetEntryPoints");
if (pfnGetEntryPoints)
{
pfnGetEntryPoints(&m_NPPFuncs);
}
// Tell the plugin to initialize itself
NP_PLUGININIT pfnInitialize = (NP_PLUGININIT)
GetProcAddress(hInstance, "NP_Initialize");
if (!pfnInitialize)
{
pfnInitialize = (NP_PLUGININIT)
GetProcAddress(hInstance, "NP_PluginInit");
}
if (pfnInitialize)
{
pfnInitialize(&g_NPNFuncs);
}
// Create a new entry for the plugin
m_pLoadedPlugin->szFullPath = _tcsdup(szPluginPath);
m_pLoadedPlugin->nRefCount = 1;
m_pLoadedPlugin->hInstance = hInstance;
memcpy(&m_pLoadedPlugin->NPPFuncs, &m_NPPFuncs, sizeof(m_NPPFuncs));
// Add it to the array
m_LoadedPlugins.AppendElement(m_pLoadedPlugin);
return S_OK;
}
HRESULT nsPluginHostCtrl::UnloadPlugin()
{
if (!m_pLoadedPlugin)
{
return E_FAIL;
}
// TODO critical section
ATLASSERT(m_pLoadedPlugin->nRefCount > 0);
if (m_pLoadedPlugin->nRefCount == 1)
{
NP_PLUGINSHUTDOWN pfnShutdown = (NP_PLUGINSHUTDOWN)
GetProcAddress(
m_pLoadedPlugin->hInstance,
"NP_Shutdown");
if (pfnShutdown)
{
pfnShutdown();
}
FreeLibrary(m_pLoadedPlugin->hInstance);
// Delete the entry from the array
m_LoadedPlugins.RemoveElement(m_pLoadedPlugin);
free(m_pLoadedPlugin->szFullPath);
delete m_pLoadedPlugin;
}
else
{
m_pLoadedPlugin->nRefCount--;
}
m_pLoadedPlugin = NULL;
return S_OK;
}
HRESULT nsPluginHostCtrl::AddPluginParam(const char *szName, const char *szValue)
{
ATLASSERT(szName);
ATLASSERT(szValue);
if (!szName || !szValue)
{
return E_INVALIDARG;
}
// Skip params that already there
for (unsigned long i = 0; i < m_nArgs; i++)
{
if (stricmp(szName, m_pszArgNames[i]) == 0)
{
return S_OK;
}
}
// Add the value
if (!m_pszArgNames)
{
ATLASSERT(!m_pszArgValues);
m_nArgsMax = kArraySizeIncrement;
m_pszArgNames = (char **) malloc(sizeof(char *) * m_nArgsMax);
m_pszArgValues = (char **) malloc(sizeof(char *) * m_nArgsMax);
}
else if (m_nArgs == m_nArgsMax)
{
m_nArgsMax += kArraySizeIncrement;
m_pszArgNames = (char **) realloc(m_pszArgNames, sizeof(char *) * m_nArgsMax);
m_pszArgValues = (char **) realloc(m_pszArgValues, sizeof(char *) * m_nArgsMax);
}
if (!m_pszArgNames || !m_pszArgValues)
{
return E_OUTOFMEMORY;
}
m_pszArgNames[m_nArgs] = strdup(szName);
m_pszArgValues[m_nArgs] = strdup(szValue);
m_nArgs++;
return S_OK;
}
HRESULT nsPluginHostCtrl::CreatePluginInstance()
{
m_NPP.pdata = NULL;
m_NPP.ndata = this;
USES_CONVERSION;
char *szContentType = strdup(OLE2A(m_bstrContentType.m_str));
// Create a child window to house the plugin
RECT rc;
GetClientRect(&rc);
m_wndPlugin.Create(m_hWnd, rc, NULL, WS_CHILD | WS_VISIBLE);
m_NPWindow.window = (void *) m_wndPlugin.m_hWnd;
m_NPWindow.type = NPWindowTypeWindow;
if (m_NPPFuncs.newp)
{
// Create the arguments to be fed into the plugin
if (m_bstrSource.m_str)
{
AddPluginParam("SRC", OLE2A(m_bstrSource.m_str));
}
if (m_bstrContentType.m_str)
{
AddPluginParam("TYPE", OLE2A(m_bstrContentType.m_str));
}
if (m_bstrPluginsPage.m_str)
{
AddPluginParam("PLUGINSPAGE", OLE2A(m_bstrPluginsPage.m_str));
}
char szTmp[50];
sprintf(szTmp, "%d", (int) (rc.right - rc.left));
AddPluginParam("WIDTH", szTmp);
sprintf(szTmp, "%d", (int) (rc.bottom - rc.top));
AddPluginParam("HEIGHT", szTmp);
NPSavedData *pSaved = NULL;
// Create the plugin instance
NPError npres = m_NPPFuncs.newp(szContentType, &m_NPP, NP_EMBED,
(short) m_nArgs, m_pszArgNames, m_pszArgValues, pSaved);
if (npres != NPERR_NO_ERROR)
{
return E_FAIL;
}
}
m_bPluginIsAlive = TRUE;
SizeToFitPluginInstance();
return S_OK;
}
HRESULT nsPluginHostCtrl::DestroyPluginInstance()
{
if (!m_bPluginIsAlive)
{
return S_OK;
}
// Destroy the plugin
if (m_NPPFuncs.destroy)
{
NPSavedData *pSavedData = NULL;
NPError npres = m_NPPFuncs.destroy(&m_NPP, &pSavedData);
// TODO could store saved data instead of just deleting it.
if (pSavedData && pSavedData->buf)
{
NPN_MemFree(pSavedData->buf);
}
}
// Destroy the arguments
if (m_pszArgNames)
{
for (unsigned long i = 0; i < m_nArgs; i++)
{
free(m_pszArgNames[i]);
}
free(m_pszArgNames);
m_pszArgNames = NULL;
}
if (m_pszArgValues)
{
for (unsigned long i = 0; i < m_nArgs; i++)
{
free(m_pszArgValues[i]);
}
free(m_pszArgValues);
m_pszArgValues = NULL;
}
m_wndPlugin.DestroyWindow();
m_bPluginIsAlive = FALSE;
return S_OK;
}
HRESULT nsPluginHostCtrl::SizeToFitPluginInstance()
{
if (!m_bPluginIsAlive)
{
return S_OK;
}
// Resize the plugin to fit the window
RECT rc;
GetClientRect(&rc);
m_wndPlugin.SetWindowPos(HWND_TOP,
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
SWP_NOZORDER);
m_NPWindow.x = 0;
m_NPWindow.y = 0;
m_NPWindow.width = rc.right - rc.left;
m_NPWindow.height = rc.bottom - rc.top;
m_NPWindow.clipRect.left = 0;
m_NPWindow.clipRect.top = 0;
m_NPWindow.clipRect.right = m_NPWindow.width;
m_NPWindow.clipRect.bottom = m_NPWindow.height;
if (m_NPPFuncs.setwindow)
{
NPError npres = m_NPPFuncs.setwindow(&m_NPP, &m_NPWindow);
}
return S_OK;
}
HRESULT nsPluginHostCtrl::OpenURLStream(const TCHAR *szURL, void *pNotifyData, const void *pPostData, unsigned long nPostDataLength)
{
nsURLDataCallback::OpenURL(this, szURL, pNotifyData, pPostData, nPostDataLength);
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
// IMozPluginHostCtrl
@ -838,60 +124,30 @@ STDMETHODIMP nsPluginHostCtrl::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog
STDMETHODIMP nsPluginHostCtrl::get_PluginContentType(BSTR *pVal)
{
if (!pVal)
{
return E_INVALIDARG;
}
*pVal = m_bstrContentType.Copy();
return S_OK;
return GetPluginContentType(pVal);
}
STDMETHODIMP nsPluginHostCtrl::put_PluginContentType(BSTR newVal)
{
// Security. Copying the source BSTR this way ensures that embedded NULL
// characters do not end up in the destination BSTR. SysAllocString will
// create a copy truncated at the first NULL char.
m_bstrContentType.Empty();
m_bstrContentType.Attach(SysAllocString(newVal));
return S_OK;
return SetPluginContentType(newVal);
}
STDMETHODIMP nsPluginHostCtrl::get_PluginSource(BSTR *pVal)
{
if (!pVal)
{
return E_INVALIDARG;
}
*pVal = m_bstrSource.Copy();
return S_OK;
return GetPluginSource(pVal);
}
STDMETHODIMP nsPluginHostCtrl::put_PluginSource(BSTR newVal)
{
// Security. Copying the source BSTR this way ensures that embedded NULL
// characters do not end up in the destination BSTR. SysAllocString will
// create a copy truncated at the first NULL char.
m_bstrSource.Empty();
m_bstrSource.Attach(SysAllocString(newVal));
return S_OK;
return SetPluginSource(newVal);
}
STDMETHODIMP nsPluginHostCtrl::get_PluginsPage(BSTR *pVal)
{
if (!pVal)
{
return E_INVALIDARG;
}
*pVal = m_bstrPluginsPage.Copy();
return S_OK;
return GetPluginsPage(pVal);
}
STDMETHODIMP nsPluginHostCtrl::put_PluginsPage(BSTR newVal)
{
// Security. Copying the source BSTR this way ensures that embedded NULL
// characters do not end up in the destination BSTR. SysAllocString will
// create a copy truncated at the first NULL char.
m_bstrPluginsPage.Empty();
m_bstrPluginsPage.Attach(SysAllocString(newVal));
return S_OK;
return SetPluginsPage(newVal);
}

Просмотреть файл

@ -1,39 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
// nsPluginHostCtrl.h : Declaration of the nsPluginHostCtrl
@ -43,119 +41,15 @@
#include "resource.h" // main symbols
#include <atlctl.h>
#include "nsPluginHostWnd.h"
#include "nsPluginWnd.h"
class nsURLDataCallback;
template <class Entry>
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
/////////////////////////////////////////////////////////////////////////////
// nsPluginHostCtrl
class ATL_NO_VTABLE nsPluginHostCtrl :
public CComObjectRootEx<CComSingleThreadModel>,
public CStockPropImpl<nsPluginHostCtrl, IMozPluginHostCtrl, &IID_IMozPluginHostCtrl, &LIBID_PLUGINHOSTCTRLLib>,
public CComControl<nsPluginHostCtrl>,
public CComControl<nsPluginHostCtrl, nsPluginHostWnd>,
public IPersistStreamInitImpl<nsPluginHostCtrl>,
public IOleControlImpl<nsPluginHostCtrl>,
public IOleObjectImpl<nsPluginHostCtrl>,
@ -226,12 +120,8 @@ BEGIN_CONNECTION_POINT_MAP(nsPluginHostCtrl)
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
END_CONNECTION_POINT_MAP()
BEGIN_MSG_MAP(nsPluginHostCtrl)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
CHAIN_MSG_MAP(CComControl<nsPluginHostCtrl>)
BEGIN_MSG_MAP(nsPluginHostWnd)
CHAIN_MSG_MAP(nsPluginHostWnd)
END_MSG_MAP()
@ -240,8 +130,6 @@ END_MSG_MAP()
// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
{
@ -257,6 +145,9 @@ END_MSG_MAP()
return S_FALSE;
}
// Overrides from nsPluginHostCtrl
virtual HRESULT GetWebBrowserApp(IWebBrowserApp **pBrowser);
// IViewObjectEx
DECLARE_VIEW_STATUS(0)
@ -271,84 +162,6 @@ public:
STDMETHOD(put_PluginContentType)(/*[in]*/ BSTR newVal);
STDMETHOD(get_PluginsPage)(/*[out, retval]*/ BSTR *pVal);
STDMETHOD(put_PluginsPage)(/*[in]*/ BSTR newVal);
// Windows message handlers
public:
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
public:
CComBSTR m_bstrText;
protected:
CComBSTR m_bstrContentType;
CComBSTR m_bstrSource;
CComBSTR m_bstrPluginsPage;
// Array of plugins
struct PluginInfo
{
TCHAR *szPluginPath;
TCHAR *szPluginName;
TCHAR *szMIMEType;
};
nsSimpleArray<PluginInfo *> 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<LoadedPluginInfo *> m_LoadedPlugins;
LoadedPluginInfo *m_pLoadedPlugin;
NPWindow m_NPWindow;
static NPNetscapeFuncs g_NPNFuncs;
static HRESULT InitPluginCallbacks();
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 //__PLUGINHOSTCTRL_H_

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,261 @@
/*
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*
* Adam Lock <adamlock@eircom.net>
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef PLUGINHOSTWND_H
#define PLUGINHOSTWND_H
#include "nsPluginWnd.h"
class nsURLDataCallback;
template <class Entry>
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_FIREFOX 0x4
#define PLUGINS_FROM_MOZILLA 0x8
class nsPluginHostWnd : public CWindowImpl<nsPluginHostWnd>
{
public:
nsPluginHostWnd();
virtual ~nsPluginHostWnd();
DECLARE_WND_CLASS(_T("MozCtrlPluginHostWindow"))
BEGIN_MSG_MAP(nsPluginHostWnd)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_SIZE, OnSize)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
// CHAIN_MSG_MAP(CWindowImpl<nsPluginHostWnd>)
END_MSG_MAP()
// Windows message handlers
public:
LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnMouseMove(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
LRESULT OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
public:
CComBSTR m_bstrText;
public:
CComBSTR m_bstrContentType;
CComBSTR m_bstrSource;
CComBSTR m_bstrPluginsPage;
// Array of plugins
struct PluginInfo
{
TCHAR *szPluginPath;
TCHAR *szPluginName;
TCHAR *szMIMEType;
};
nsSimpleArray<PluginInfo *> 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<LoadedPluginInfo *> m_LoadedPlugins;
LoadedPluginInfo *m_pLoadedPlugin;
NPWindow m_NPWindow;
static NPNetscapeFuncs g_NPNFuncs;
static HRESULT InitPluginCallbacks();
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;
bool m_bPluginIsWindowless;
bool m_bPluginIsTransparent;
nsPluginWnd m_wndPlugin;
// Struct holding pointers to the functions within the plugin
NPPluginFuncs m_NPPFuncs;
virtual HRESULT GetWebBrowserApp(IWebBrowserApp **pBrowser);
HRESULT GetBaseURL(TCHAR **szBaseURL);
HRESULT GetPluginSource(/*[out, retval]*/ BSTR *pVal);
HRESULT SetPluginSource(/*[in]*/ BSTR newVal);
HRESULT GetPluginContentType(/*[out, retval]*/ BSTR *pVal);
HRESULT SetPluginContentType(/*[in]*/ BSTR newVal);
HRESULT GetPluginsPage(/*[out, retval]*/ BSTR *pVal);
HRESULT SetPluginsPage(/*[in]*/ BSTR newVal);
HRESULT AddPluginParam(const char *szName, const char *szValue);
HRESULT LoadPluginByContentType(const TCHAR *pszContentType);
HRESULT ReadPluginsFromGeckoAppPath(const TCHAR *szAppName);
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();
void SetPluginWindowless(bool bWindowless);
void SetPluginTransparent(bool bTransparent);
};
#endif

Просмотреть файл

@ -1,39 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "stdafx.h"
#include "pluginhostctrl.h"
#include "nsPluginWnd.h"

Просмотреть файл

@ -1,39 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef __PLUGINWND_H_
#define __PLUGINWND_H_

Просмотреть файл

@ -1,45 +1,43 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#include "stdafx.h"
#include <process.h>
#include "Pluginhostctrl.h"
#include "nsPluginHostCtrl.h"
#include "nsPluginHostWnd.h"
#include "nsURLDataCallback.h"
@ -101,7 +99,7 @@ void nsURLDataCallback::SetPostData(const void *pData, unsigned long nSize)
}
}
HRESULT nsURLDataCallback::OpenURL(nsPluginHostCtrl *pOwner, const TCHAR *szURL, void *pNotifyData, const void *pPostData, unsigned long nPostDataSize)
HRESULT nsURLDataCallback::OpenURL(nsPluginHostWnd *pOwner, const TCHAR *szURL, void *pNotifyData, const void *pPostData, unsigned long nPostDataSize)
{
// Create the callback object
CComObject<nsURLDataCallback> *pCallback = NULL;

Просмотреть файл

@ -1,39 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
#ifndef __NSURLDATACALLBACK_H_
#define __NSURLDATACALLBACK_H_
@ -43,7 +41,7 @@
#include "npapi.h"
class nsPluginHostCtrl;
class nsPluginHostWnd;
#define WM_NPP_NEWSTREAM WM_USER
#define WM_NPP_DESTROYSTREAM WM_USER + 1
@ -138,7 +136,7 @@ protected:
virtual ~nsURLDataCallback();
protected:
nsPluginHostCtrl *m_pOwner;
nsPluginHostWnd *m_pOwner;
void *m_pNotifyData;
HGLOBAL m_hPostData;
@ -167,13 +165,13 @@ protected:
if (szContentType) { m_szContentType = strdup(szContentType); }
}
void SetPostData(const void *pData, unsigned long nSize);
void SetOwner(nsPluginHostCtrl *pOwner) { m_pOwner = pOwner; }
void SetOwner(nsPluginHostWnd *pOwner) { m_pOwner = pOwner; }
void SetNotifyData(void *pNotifyData) { m_pNotifyData = pNotifyData; }
static void __cdecl StreamThread(void *pThis);
public:
static HRESULT OpenURL(nsPluginHostCtrl *pOwner, const TCHAR *szURL, void *pNotifyData, const void *pData, unsigned long nSize);
static HRESULT OpenURL(nsPluginHostWnd *pOwner, const TCHAR *szURL, void *pNotifyData, const void *pData, unsigned long nSize);
// IBindStatusCallback
public:

Просмотреть файл

@ -1,39 +1,37 @@
/* ***** 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/
*
* 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.
* 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 the Netscape security libraries.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1994-2000
* the Initial Developer. All Rights Reserved.
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1994-2000 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*
* 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.
* Adam Lock <adamlock@eircom.net>
*
* ***** END LICENSE BLOCK ***** */
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 or later (the
* "GPL"), in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your
* version of this file only under the terms of the GPL and not to
* allow others to use your version of this file under the MPL,
* indicate your decision by deleting the provisions above and
* replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient
* may use your version of this file under either the MPL or the
* GPL.
*/
*/
// pluginhostctrl.cpp : Implementation of DLL Exports.

Просмотреть файл

@ -3,7 +3,7 @@
LIBRARY "pluginhostctrl.DLL"
EXPORTS
DllCanUnloadNow @1 PRIVATE
DllGetClassObject @2 PRIVATE
DllRegisterServer @3 PRIVATE
DllUnregisterServer @4 PRIVATE
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

Просмотреть файл

@ -0,0 +1,27 @@
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pluginhostctrl", "pluginhostctrl.vcproj", "{2E8F0B45-A837-4C6C-A072-E89771A90B3A}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
ConfigName.2 = Release MinDependency
ConfigName.3 = Release MinSize
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Debug.ActiveCfg = Debug|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Debug.Build.0 = Debug|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Release.ActiveCfg = Release MinDependency|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Release.Build.0 = Release MinDependency|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Release MinDependency.ActiveCfg = Release MinDependency|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Release MinDependency.Build.0 = Release MinDependency|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Release MinSize.ActiveCfg = Release MinSize|Win32
{2E8F0B45-A837-4C6C-A072-E89771A90B3A}.Release MinSize.Build.0 = Release MinSize|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,372 @@
<?xml version="1.0" encoding = "Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.00"
Name="pluginhostctrl"
ProjectGUID="{2E8F0B45-A837-4C6C-A072-E89771A90B3A}"
SccProjectName=""
SccLocalPath=""
Keyword="AtlProj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="pluginsdk_include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/pluginhostctrl.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;
echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;
"
Outputs="$(OutDir)\regsvr32.trg"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="version.lib odbc32.lib odbccp32.lib"
OutputFile=".\Debug/pluginhostctrl.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=".\pluginhostctrl.def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/pluginhostctrl.pdb"
SubSystem="2"
ImportLibrary=".\Debug/pluginhostctrl.lib"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/pluginhostctrl.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="6153"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release MinSize|Win32"
OutputDirectory=".\ReleaseMinSize"
IntermediateDirectory=".\ReleaseMinSize"
ConfigurationType="2"
UseOfMFC="0"
UseOfATL="2"
ATLMinimizesCRunTimeLibraryUsage="TRUE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="pluginsdk_include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\ReleaseMinSize/pluginhostctrl.pch"
AssemblerListingLocation=".\ReleaseMinSize/"
ObjectFile=".\ReleaseMinSize/"
ProgramDataBaseFileName=".\ReleaseMinSize/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;
echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;
"
Outputs="$(OutDir)\regsvr32.trg"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="version.lib odbc32.lib odbccp32.lib"
OutputFile=".\ReleaseMinSize/pluginhostctrl.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=".\pluginhostctrl.def"
ProgramDatabaseFile=".\ReleaseMinSize/pluginhostctrl.pdb"
SubSystem="2"
ImportLibrary=".\ReleaseMinSize/pluginhostctrl.lib"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\ReleaseMinSize/pluginhostctrl.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="6153"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
<Configuration
Name="Release MinDependency|Win32"
OutputDirectory=".\ReleaseMinDependency"
IntermediateDirectory=".\ReleaseMinDependency"
ConfigurationType="2"
UseOfMFC="0"
UseOfATL="1"
ATLMinimizesCRunTimeLibraryUsage="TRUE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="pluginsdk_include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="3"
PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\ReleaseMinDependency/pluginhostctrl.pch"
AssemblerListingLocation=".\ReleaseMinDependency/"
ObjectFile=".\ReleaseMinDependency/"
ProgramDataBaseFileName=".\ReleaseMinDependency/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"
Description="Performing registration"
CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;
echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;
"
Outputs="$(OutDir)\regsvr32.trg"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="version.lib odbc32.lib odbccp32.lib"
OutputFile=".\ReleaseMinDependency/pluginhostctrl.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ModuleDefinitionFile=".\pluginhostctrl.def"
ProgramDatabaseFile=".\ReleaseMinDependency/pluginhostctrl.pdb"
SubSystem="2"
ImportLibrary=".\ReleaseMinDependency/pluginhostctrl.lib"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\ReleaseMinDependency/pluginhostctrl.tlb"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="6153"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath=".\StdAfx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release MinSize|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release MinDependency|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
<File
RelativePath=".\npn.cpp">
</File>
<File
RelativePath=".\nsPluginHostCtrl.cpp">
</File>
<File
RelativePath="nsPluginHostWnd.cpp">
</File>
<File
RelativePath=".\nsPluginWnd.cpp">
</File>
<File
RelativePath=".\nsURLDataCallback.cpp">
</File>
<File
RelativePath=".\pluginhostctrl.cpp">
</File>
<File
RelativePath=".\pluginhostctrl.def">
</File>
<File
RelativePath=".\pluginhostctrl.idl">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="TRUE"
TypeLibraryName=".\pluginhostctrl.tlb"
HeaderFileName="pluginhostctrl.h"
InterfaceIdentifierFileName="pluginhostctrl_i.c"/>
</FileConfiguration>
<FileConfiguration
Name="Release MinSize|Win32">
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="TRUE"
TypeLibraryName=".\pluginhostctrl.tlb"
HeaderFileName="pluginhostctrl.h"
InterfaceIdentifierFileName="pluginhostctrl_i.c"/>
</FileConfiguration>
<FileConfiguration
Name="Release MinDependency|Win32">
<Tool
Name="VCMIDLTool"
GenerateStublessProxies="TRUE"
TypeLibraryName=".\pluginhostctrl.tlb"
HeaderFileName="pluginhostctrl.h"
InterfaceIdentifierFileName="pluginhostctrl_i.c"/>
</FileConfiguration>
</File>
<File
RelativePath=".\pluginhostctrl.rc">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCResourceCompilerTool"
AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release MinSize|Win32">
<Tool
Name="VCResourceCompilerTool"
AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"/>
</FileConfiguration>
<FileConfiguration
Name="Release MinDependency|Win32">
<Tool
Name="VCResourceCompilerTool"
AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath=".\Resource.h">
</File>
<File
RelativePath=".\StdAfx.h">
</File>
<File
RelativePath=".\npn.h">
</File>
<File
RelativePath=".\nsPluginHostCtrl.h">
</File>
<File
RelativePath="nsPluginHostWnd.h">
</File>
<File
RelativePath=".\nsPluginWnd.h">
</File>
<File
RelativePath=".\nsURLDataCallback.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
<File
RelativePath=".\PluginHostCtrl.rgs">
</File>
</Filter>
<Filter
Name="Test Files"
Filter="">
<File
RelativePath=".\tests\ns4x_reference_test3.htm">
</File>
<File
RelativePath=".\tests\test1.htm">
</File>
<File
RelativePath=".\tests\test2.htm">
</File>
<File
RelativePath=".\tests\test3.htm">
</File>
<File
RelativePath=".\tests\test4.htm">
</File>
<File
RelativePath=".\tests\test5.htm">
</File>
<File
RelativePath=".\tests\test6.htm">
</File>
<File
RelativePath=".\tests\test7.htm">
</File>
<File
RelativePath=".\tests\test8.htm">
</File>
<File
RelativePath=".\tests\test9.htm">
</File>
</Filter>
<File
RelativePath=".\PluginHostCtrlUI.htm">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>