diff --git a/mozilla/modules/plugin/samples/default/windows/Npnul32.dsp b/mozilla/modules/plugin/samples/default/windows/Npnul32.dsp index 5231fda1b38..7ba7b12b1f2 100644 --- a/mozilla/modules/plugin/samples/default/windows/Npnul32.dsp +++ b/mozilla/modules/plugin/samples/default/windows/Npnul32.dsp @@ -52,7 +52,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib libc.lib /nologo /subsystem:windows /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /subsystem:windows /dll /machine:I386 !ELSEIF "$(CFG)" == "Npnul32 - Win32 Debug" diff --git a/mozilla/modules/plugin/samples/default/windows/npshell.cpp b/mozilla/modules/plugin/samples/default/windows/npshell.cpp index e1924c79146..b936030af65 100644 --- a/mozilla/modules/plugin/samples/default/windows/npshell.cpp +++ b/mozilla/modules/plugin/samples/default/windows/npshell.cpp @@ -231,7 +231,10 @@ NPP_NewStream(NPP pInstance, CPlugin * pPlugin = (CPlugin *)pInstance->pdata; assert(pPlugin != NULL); - return NPERR_NO_ERROR; + if (!pPlugin) + return NPERR_GENERIC_ERROR; + + return pPlugin->newStream(type, stream, seekable, stype); } //------------------------------------------------------------------------------------ @@ -263,7 +266,7 @@ NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer CPlugin * pPlugin = (CPlugin *)pInstance->pdata; assert(pPlugin != NULL); - return -1; // tell Nav to abort the stream, don't need it + return -1; // tell the browser to abort the stream, don't need it } //------------------------------------------------------------------------------------ @@ -279,7 +282,10 @@ NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason) CPlugin * pPlugin = (CPlugin *)pInstance->pdata; assert(pPlugin != NULL); - return NPERR_NO_ERROR; + if (!pPlugin) + return NPERR_GENERIC_ERROR; + + return pPlugin->destroyStream(stream, reason); } //------------------------------------------------------------------------------------ diff --git a/mozilla/modules/plugin/samples/default/windows/plugin.cpp b/mozilla/modules/plugin/samples/default/windows/plugin.cpp index ef591c44aba..00ccdbcd536 100644 --- a/mozilla/modules/plugin/samples/default/windows/plugin.cpp +++ b/mozilla/modules/plugin/samples/default/windows/plugin.cpp @@ -118,6 +118,8 @@ CPlugin::CPlugin(HINSTANCE hInst, m_bSmartUpdate(TRUE), m_szURLString(NULL), m_szCommandMessage(NULL), + m_bWaitingStreamFromPFS(FALSE), + m_PFSStream(NULL), m_bHidden(bHidden) { dbgOut1("CPlugin::CPlugin()"); @@ -434,7 +436,8 @@ void CPlugin::getPluginRegular() dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL); - NPN_GetURL(m_pNPInstance, szURL, "_blank"); + NPN_GetURL(m_pNPInstance, szURL, NULL); + m_bWaitingStreamFromPFS = TRUE; } void CPlugin::getPluginSmart() @@ -554,6 +557,32 @@ void CPlugin::URLNotify(const char * szURL) NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE); } +NPError CPlugin::newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype) +{ + if (!m_bWaitingStreamFromPFS) + return NPERR_NO_ERROR; + + m_bWaitingStreamFromPFS = FALSE; + m_PFSStream = stream; + + if (stream) { + if (type && !strcmp(type, "application/x-xpinstall")) + NPN_GetURL(m_pNPInstance, stream->url, "_self"); + else + NPN_GetURL(m_pNPInstance, stream->url, "_blank"); + } + + return NPERR_NO_ERROR; +} + +NPError CPlugin::destroyStream(NPStream *stream, NPError reason) +{ + if (stream == m_PFSStream) + m_PFSStream = NULL; + + return NPERR_NO_ERROR; +} + BOOL CPlugin::readyToRefresh() { char szString[1024] = {'\0'}; diff --git a/mozilla/modules/plugin/samples/default/windows/plugin.h b/mozilla/modules/plugin/samples/default/windows/plugin.h index 672a133ec41..365ca827beb 100644 --- a/mozilla/modules/plugin/samples/default/windows/plugin.h +++ b/mozilla/modules/plugin/samples/default/windows/plugin.h @@ -44,22 +44,24 @@ class CPlugin { private: HINSTANCE m_hInst; - NPP m_pNPInstance; - WORD m_wMode; - HWND m_hWnd; - HWND m_hWndParent; - HICON m_hIcon; - char * m_szURLString; + NPP m_pNPInstance; + WORD m_wMode; + HWND m_hWnd; + HWND m_hWndParent; + HICON m_hIcon; + char* m_szURLString; - char * m_szCommandMessage; + char* m_szCommandMessage; + BOOL m_bWaitingStreamFromPFS; + NPStream* m_PFSStream; public: - BOOL m_bHidden; + BOOL m_bHidden; NPMIMEType m_pNPMIMEType; - LPSTR m_szPageURL; // Location of plug-in HTML page - LPSTR m_szFileURL; // Location of plug-in JAR file - LPSTR m_szFileExtension; // File extension associated with the of the unknown mimetype - HWND m_hWndDialog; + LPSTR m_szPageURL; // Location of plug-in HTML page + LPSTR m_szFileURL; // Location of plug-in JAR file + LPSTR m_szFileExtension; // File extension associated with the of the unknown mimetype + HWND m_hWndDialog; // environment BOOL m_bOnline; @@ -93,15 +95,18 @@ public: BOOL readyToRefresh(); // NP API handlers - void resize(); void print(NPPrint * pNPPrint); void URLNotify(const char * szURL); + NPError newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype); + NPError destroyStream(NPStream *stream, NPError reason); // Windows message handlers void onCreate(HWND hWnd); void onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags); void onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags); void onPaint(HWND hWnd); + + void resize(); };