diff --git a/webshell/embed/ActiveX/MozillaBrowser.cpp b/webshell/embed/ActiveX/MozillaBrowser.cpp index b15838d898ab..8d0a22119e35 100644 --- a/webshell/embed/ActiveX/MozillaBrowser.cpp +++ b/webshell/embed/ActiveX/MozillaBrowser.cpp @@ -3,6 +3,10 @@ #include "MozillaControl.h" #include "MozillaBrowser.h" + +#define NS_DEFAULT_PREFS "prefs.js" +#define NS_DEFAULT_PREFS_HOMEPAGE "browser.startup.homepage" + ///////////////////////////////////////////////////////////////////////////// // CMozillaBrowser @@ -13,11 +17,17 @@ CMozillaBrowser::CMozillaBrowser() m_bWindowOnly = TRUE; m_bWndLess = FALSE; + // Initialize layout interfaces m_pIWebShell = nsnull; +#ifdef USE_NGPREF + m_pIPref = nsnull; +#endif // Create the container that handles some things for us m_pWebShellContainer = NULL; + m_bBusy = FALSE; + PL_InitializeEventsLib(""); // Register everything NS_SetupRegistry(); @@ -33,7 +43,7 @@ STDMETHODIMP CMozillaBrowser::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { - &IID_IMozillaBrowser, + &IID_IWebBrowser, }; for (int i=0;iDestroy(); NS_RELEASE(m_pIWebShell); + } + + if (m_pWebShellContainer) + { m_pWebShellContainer->Release(); m_pWebShellContainer = NULL; } + +#ifdef USE_NGPREF + if (m_pIPref) + { + m_pIPref->Shutdown(); + NS_RELEASE(m_pIPref); + } +#endif + return 0; } @@ -81,6 +104,17 @@ LRESULT CMozillaBrowser::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b } +BOOL CMozillaBrowser::IsValid() +{ + if (m_pIWebShell == nsnull) + { + return FALSE; + } + + return TRUE; +} + + HRESULT CMozillaBrowser::OnDraw(ATL_DRAWINFO& di) { if (m_pIWebShell == nsnull) @@ -108,6 +142,15 @@ HRESULT CMozillaBrowser::CreateWebShell() nsresult rv; + // Load preferences +#ifdef USE_NGPREF + rv = nsRepository::CreateInstance(kPrefCID, NULL, kIPrefIID, (void **) &m_pIPref); + if (NS_OK != rv) { + return E_FAIL; + } + m_pIPref->Startup(NS_DEFAULT_PREFS); +#endif + rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&m_pIWebShell); @@ -115,7 +158,7 @@ HRESULT CMozillaBrowser::CreateWebShell() { return E_FAIL; } - + nsRect r; r.x = 0; r.y = 0; @@ -130,24 +173,16 @@ HRESULT CMozillaBrowser::CreateWebShell() nsScrollPreference_kAuto, aAllowPlugins); // Create the container object - m_pWebShellContainer = new CWebShellContainer; + m_pWebShellContainer = new CWebShellContainer(this); m_pWebShellContainer->AddRef(); m_pIWebShell->SetContainer((nsIWebShellContainer*) m_pWebShellContainer); -// m_pIWebShell->SetObserver((nsIStreamObserver*)this); -// m_pIWebShell->SetPrefs(aPrefs); + m_pIWebShell->SetObserver((nsIStreamObserver*) m_pWebShellContainer); +#ifdef USE_NGPREF + m_pIWebShell->SetPrefs(m_pIPref); +#endif m_pIWebShell->Show(); - // TODO - // -- remove - // Use the IWebBrowser::Navigate() method - USES_CONVERSION; - LPOLESTR pszUrl = T2OLE(_T("http://www.mozilla.org")); - BSTR bstrUrl = ::SysAllocString(pszUrl); - Navigate(bstrUrl, NULL, NULL, NULL, NULL); - ::SysFreeString(bstrUrl); - // -- remove - return S_OK; } @@ -156,12 +191,12 @@ HRESULT CMozillaBrowser::CreateWebShell() HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoBack(void) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - if (m_pIWebShell->CanBack()) + if (m_pIWebShell->CanBack() == NS_OK) { m_pIWebShell->Back(); } @@ -172,12 +207,12 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoBack(void) HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoForward(void) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - if (m_pIWebShell->CanForward()) + if (m_pIWebShell->CanForward() == NS_OK) { m_pIWebShell->Forward(); } @@ -188,14 +223,30 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoForward(void) HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoHome(void) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO find and navigate to the home page somehow USES_CONVERSION; - Navigate(T2OLE(_T("http://home.netscape.com")), NULL, NULL, NULL, NULL); + + // Find the home page stored in prefs + TCHAR * sUrl = _T("http://home.netscape.com"); +#ifdef USE_NGPREF + if (m_pIPref) + { + char szBuffer[512]; + nsresult rv; + memset(szBuffer, 0, sizeof(szBuffer); + rv = m_pIPref->GetCharPref(NS_DEFAULT_PREFS_HOMEPAGE, szBuffer, sizeof(szBuffer)); + if (rv == NS_OK) + { + sUrl = A2T(szBuffer); + } + } +#endif + // Navigate to the home page + Navigate(T2OLE(sUrl), NULL, NULL, NULL, NULL); return S_OK; } @@ -203,15 +254,18 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoHome(void) HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoSearch(void) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO find and navigate to the search page somehow + // TODO find and navigate to the search page stored in prefs + // and not this hard coded address + + TCHAR * sUrl = _T("http://search.netscape.com"); USES_CONVERSION; - Navigate(T2OLE(_T("http://search.netscape.com")), NULL, NULL, NULL, NULL); + Navigate(T2OLE(sUrl), NULL, NULL, NULL, NULL); return S_OK; } @@ -219,7 +273,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::GoSearch(void) HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR *Flags, VARIANT __RPC_FAR *TargetFrameName, VARIANT __RPC_FAR *PostData, VARIANT __RPC_FAR *Headers) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -228,7 +282,6 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR nsString sUrl; if (URL == NULL) { -// ASSERT(0); return E_INVALIDARG; } else @@ -252,28 +305,18 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR // Extract the target frame parameter nsString sTargetFrame; - if (TargetFrameName) + if (TargetFrameName && TargetFrameName->vt == VT_BSTR) { USES_CONVERSION; - CComVariant vTargetFrame; - if (VariantChangeType(TargetFrameName, &vTargetFrame, 0, VT_BSTR) != S_OK) - { - return E_INVALIDARG; - } - sTargetFrame = nsString(OLE2A(vTargetFrame.bstrVal)); + sTargetFrame = nsString(OLE2A(TargetFrameName->bstrVal)); } // Extract the post data parameter nsString sPostData; - if (PostData) + if (PostData && PostData->vt == VT_BSTR) { USES_CONVERSION; - CComVariant vPostData; - if (VariantChangeType(PostData, &vPostData, 0, VT_BSTR) != S_OK) - { - return E_INVALIDARG; - } - sPostData = nsString(OLE2A(vPostData.bstrVal)); + sPostData = nsString(OLE2A(PostData->bstrVal)); } @@ -314,7 +357,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Navigate(BSTR URL, VARIANT __RPC_FAR HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh(void) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -327,7 +370,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh(void) HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh2(VARIANT __RPC_FAR *Level) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -343,7 +386,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Refresh2(VARIANT __RPC_FAR *Level) HRESULT STDMETHODCALLTYPE CMozillaBrowser::Stop() { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -356,7 +399,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::Stop() HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Application(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -368,7 +411,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Application(IDispatch __RPC_FAR * HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Parent(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -380,7 +423,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Parent(IDispatch __RPC_FAR *__RPC HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Container(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -392,7 +435,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Container(IDispatch __RPC_FAR *__ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Document(IDispatch __RPC_FAR *__RPC_FAR *ppDisp) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -401,10 +444,9 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Document(IDispatch __RPC_FAR *__R return E_NOTIMPL; } - HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_TopLevelContainer(VARIANT_BOOL __RPC_FAR *pBool) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -416,7 +458,7 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_TopLevelContainer(VARIANT_BOOL __ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Type(BSTR __RPC_FAR *Type) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } @@ -428,132 +470,187 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Type(BSTR __RPC_FAR *Type) HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Left(long __RPC_FAR *pl) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO - return E_NOTIMPL; + if (pl == NULL) + { + return E_INVALIDARG; + } + *pl = 0; // TODO + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Left(long Left) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } // TODO - return E_NOTIMPL; + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Top(long __RPC_FAR *pl) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO + if (pl == NULL) + { + return E_INVALIDARG; + } + *pl = 0; // TODO return E_NOTIMPL; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Top(long Top) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } // TODO - return E_NOTIMPL; + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Width(long __RPC_FAR *pl) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO - return E_NOTIMPL; + if (pl == NULL) + { + return E_INVALIDARG; + } + *pl = 0; // TODO + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Width(long Width) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } // TODO - return E_NOTIMPL; + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Height(long __RPC_FAR *pl) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO - return E_NOTIMPL; + if (pl == NULL) + { + return E_INVALIDARG; + } + *pl = 0; // TODO + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::put_Height(long Height) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } // TODO - return E_NOTIMPL; + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_LocationName(BSTR __RPC_FAR *LocationName) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO - return E_NOTIMPL; + if (LocationName == NULL) + { + return E_INVALIDARG; + } + + // Get the url from the web shell + PRUnichar *pszLocationName = nsnull; + m_pIWebShell->GetTitle(&pszLocationName); + if (pszLocationName == nsnull) + { + return E_FAIL; + } + + // Convert the string to a BSTR + USES_CONVERSION; + LPOLESTR pszConvertedLocationName = W2OLE(pszLocationName); + *LocationName = SysAllocString(pszConvertedLocationName); + + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_LocationURL(BSTR __RPC_FAR *LocationURL) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO - return E_NOTIMPL; + if (LocationURL == NULL) + { + return E_INVALIDARG; + } + + // Get the url from the web shell + PRUnichar *pszUrl = nsnull; + m_pIWebShell->GetURL(0, &pszUrl); + if (pszUrl == nsnull) + { + return E_FAIL; + } + + // Convert the string to a BSTR + USES_CONVERSION; + LPOLESTR pszConvertedUrl = W2OLE(pszUrl); + *LocationURL = SysAllocString(pszConvertedUrl); + + return S_OK; } HRESULT STDMETHODCALLTYPE CMozillaBrowser::get_Busy(VARIANT_BOOL __RPC_FAR *pBool) { - if (m_pIWebShell == nsnull) + if (!IsValid()) { return E_UNEXPECTED; } - // TODO + if (!NgIsValidAddress(pBool, sizeof(*pBool))) + { + return E_INVALIDARG; + } - return E_NOTIMPL; + *pBool = (m_bBusy) ? VARIANT_TRUE : VARIANT_FALSE; + + return S_OK; } diff --git a/webshell/embed/ActiveX/MozillaBrowser.h b/webshell/embed/ActiveX/MozillaBrowser.h index e9d09f7a62b9..5ae251b91991 100644 --- a/webshell/embed/ActiveX/MozillaBrowser.h +++ b/webshell/embed/ActiveX/MozillaBrowser.h @@ -18,7 +18,7 @@ class ATL_NO_VTABLE CMozillaBrowser : public CComCoClass, public CComControl, public CProxyDWebBrowserEvents, - public CStockPropImpl, + public CStockPropImpl, public IProvideClassInfo2Impl<&CLSID_MozillaBrowser, &DIID_DWebBrowserEvents, &LIBID_MOZILLACONTROLLib>, public IPersistStreamInitImpl, public IPersistStorageImpl, @@ -31,10 +31,9 @@ class ATL_NO_VTABLE CMozillaBrowser : public IDataObjectImpl, public ISupportErrorInfo, public IConnectionPointContainerImpl, - public ISpecifyPropertyPagesImpl, - // Support for IE - public IDispatchImpl + public ISpecifyPropertyPagesImpl { + friend CWebShellContainer; public: CMozillaBrowser(); virtual ~CMozillaBrowser(); @@ -42,8 +41,10 @@ public: DECLARE_REGISTRY_RESOURCEID(IDR_MOZILLABROWSER) BEGIN_COM_MAP(CMozillaBrowser) - COM_INTERFACE_ENTRY(IMozillaBrowser) - COM_INTERFACE_ENTRY_IID(IID_IDispatch, IMozillaBrowser) + // IE web browser interface + COM_INTERFACE_ENTRY(IWebBrowser) +// COM_INTERFACE_ENTRY(IMozillaBrowser) + COM_INTERFACE_ENTRY_IID(IID_IDispatch, IWebBrowser) COM_INTERFACE_ENTRY_IMPL(IViewObjectEx) COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx) COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx) @@ -53,7 +54,7 @@ BEGIN_COM_MAP(CMozillaBrowser) COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject) COM_INTERFACE_ENTRY_IMPL(IOleControl) COM_INTERFACE_ENTRY_IMPL(IOleObject) - COM_INTERFACE_ENTRY_IMPL(IQuickActivate) +// COM_INTERFACE_ENTRY_IMPL(IQuickActivate) COM_INTERFACE_ENTRY_IMPL(IPersistStorage) COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit) COM_INTERFACE_ENTRY_IMPL(ISpecifyPropertyPages) @@ -62,8 +63,6 @@ BEGIN_COM_MAP(CMozillaBrowser) COM_INTERFACE_ENTRY(IProvideClassInfo2) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer) - // IE web browser interface - COM_INTERFACE_ENTRY(IWebBrowser) END_COM_MAP() BEGIN_PROPERTY_MAP(CMozillaBrowser) @@ -107,9 +106,16 @@ END_MSG_MAP() // Protected members protected: CWebShellContainer * m_pWebShellContainer; + + // Mozilla interfaces nsIWebShell * m_pIWebShell; + nsIPref * m_pIPref; + // Indicates the browser is busy doing something + BOOL m_bBusy; + virtual HRESULT CreateWebShell(); + virtual BOOL IsValid(); // IWebBrowser implementation public: @@ -139,7 +145,6 @@ public: virtual HRESULT STDMETHODCALLTYPE get_LocationURL(BSTR __RPC_FAR *LocationURL); virtual HRESULT STDMETHODCALLTYPE get_Busy(VARIANT_BOOL __RPC_FAR *pBool); -// IMozillaBrowser public: HRESULT OnDraw(ATL_DRAWINFO& di); diff --git a/webshell/embed/ActiveX/MozillaControl.h b/webshell/embed/ActiveX/MozillaControl.h index 28186a068a0b..49fd4f650074 100644 --- a/webshell/embed/ActiveX/MozillaControl.h +++ b/webshell/embed/ActiveX/MozillaControl.h @@ -2,7 +2,7 @@ /* File created by MIDL compiler version 3.03.0110 */ -/* at Sun Aug 23 21:54:29 1998 +/* at Sun Sep 20 22:13:10 1998 */ /* Compiler settings for MozillaControl.idl: Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext @@ -19,15 +19,6 @@ #include "rpc.h" #include "rpcndr.h" -#ifndef __RPCNDR_H_VERSION__ -#error this stub requires an updated version of -#endif // __RPCNDR_H_VERSION__ - -#ifndef COM_NO_WINDOWS_H -#include "windows.h" -#include "ole2.h" -#endif /*COM_NO_WINDOWS_H*/ - #ifndef __MozillaControl_h__ #define __MozillaControl_h__ @@ -37,12 +28,6 @@ extern "C"{ /* Forward Declarations */ -#ifndef __IMozillaBrowser_FWD_DEFINED__ -#define __IMozillaBrowser_FWD_DEFINED__ -typedef interface IMozillaBrowser IMozillaBrowser; -#endif /* __IMozillaBrowser_FWD_DEFINED__ */ - - #ifndef __IWebBrowser_FWD_DEFINED__ #define __IWebBrowser_FWD_DEFINED__ typedef interface IWebBrowser IWebBrowser; @@ -74,150 +59,13 @@ typedef struct MozillaBrowser MozillaBrowser; void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); void __RPC_USER MIDL_user_free( void __RPC_FAR * ); -#ifndef __IMozillaBrowser_INTERFACE_DEFINED__ -#define __IMozillaBrowser_INTERFACE_DEFINED__ - -/**************************************** - * Generated header for interface: IMozillaBrowser - * at Sun Aug 23 21:54:29 1998 - * using MIDL 3.03.0110 - ****************************************/ -/* [unique][helpstring][dual][uuid][object] */ - - - -EXTERN_C const IID IID_IMozillaBrowser; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("1339B54B-3453-11D2-93B9-000000000000") - IMozillaBrowser : public IDispatch - { - public: - virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_Window( - /* [retval][out] */ long __RPC_FAR *phwnd) = 0; - - }; - -#else /* C style interface */ - - typedef struct IMozillaBrowserVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IMozillaBrowser __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IMozillaBrowser __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IMozillaBrowser __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( - IMozillaBrowser __RPC_FAR * This, - /* [out] */ UINT __RPC_FAR *pctinfo); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( - IMozillaBrowser __RPC_FAR * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( - IMozillaBrowser __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( - IMozillaBrowser __RPC_FAR * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, - /* [out] */ VARIANT __RPC_FAR *pVarResult, - /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, - /* [out] */ UINT __RPC_FAR *puArgErr); - - /* [id][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Window )( - IMozillaBrowser __RPC_FAR * This, - /* [retval][out] */ long __RPC_FAR *phwnd); - - END_INTERFACE - } IMozillaBrowserVtbl; - - interface IMozillaBrowser - { - CONST_VTBL struct IMozillaBrowserVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IMozillaBrowser_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IMozillaBrowser_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IMozillaBrowser_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IMozillaBrowser_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define IMozillaBrowser_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define IMozillaBrowser_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define IMozillaBrowser_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define IMozillaBrowser_get_Window(This,phwnd) \ - (This)->lpVtbl -> get_Window(This,phwnd) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [id][propget] */ HRESULT STDMETHODCALLTYPE IMozillaBrowser_get_Window_Proxy( - IMozillaBrowser __RPC_FAR * This, - /* [retval][out] */ long __RPC_FAR *phwnd); - - -void __RPC_STUB IMozillaBrowser_get_Window_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IMozillaBrowser_INTERFACE_DEFINED__ */ - - #ifndef __MOZILLACONTROLLib_LIBRARY_DEFINED__ #define __MOZILLACONTROLLib_LIBRARY_DEFINED__ /**************************************** * Generated header for library: MOZILLACONTROLLib - * at Sun Aug 23 21:54:29 1998 + * at Sun Sep 20 22:13:10 1998 * using MIDL 3.03.0110 ****************************************/ /* [helpstring][version][uuid] */ @@ -231,7 +79,7 @@ EXTERN_C const IID LIBID_MOZILLACONTROLLib; /**************************************** * Generated header for interface: IWebBrowser - * at Sun Aug 23 21:54:29 1998 + * at Sun Sep 20 22:13:10 1998 * using MIDL 3.03.0110 ****************************************/ /* [object][oleautomation][dual][hidden][helpcontext][helpstring][uuid] */ @@ -907,7 +755,7 @@ void __RPC_STUB IWebBrowser_get_Busy_Stub( /**************************************** * Generated header for dispinterface: DWebBrowserEvents - * at Sun Aug 23 21:54:29 1998 + * at Sun Sep 20 22:13:10 1998 * using MIDL 3.03.0110 ****************************************/ /* [hidden][helpstring][uuid] */ diff --git a/webshell/embed/ActiveX/MozillaControl.idl b/webshell/embed/ActiveX/MozillaControl.idl index 67ceec2a407d..9cdbdff006a9 100644 --- a/webshell/embed/ActiveX/MozillaControl.idl +++ b/webshell/embed/ActiveX/MozillaControl.idl @@ -12,18 +12,6 @@ import "ocidl.idl"; // import "exdisp.idl"; #include "exdispid.h" - [ - object, - uuid(1339B54B-3453-11D2-93B9-000000000000), - dual, - helpstring("IMozillaBrowser Interface"), - pointer_default(unique) - ] - interface IMozillaBrowser : IDispatch - { - [propget, id(DISPID_HWND)] - HRESULT Window([out, retval]long* phwnd); - }; [ uuid(1339B53E-3453-11D2-93B9-000000000000), version(1.0), @@ -219,7 +207,7 @@ library MOZILLACONTROLLib coclass MozillaBrowser { [default] interface IWebBrowser; - interface IMozillaBrowser; + interface IDispatch; // [default, source] dispinterface DWebBrowserEvents2; [default, source] dispinterface DWebBrowserEvents; }; diff --git a/webshell/embed/ActiveX/MozillaControl.rc b/webshell/embed/ActiveX/MozillaControl.rc index 60f10b821ab5..ecce27b08e4a 100644 --- a/webshell/embed/ActiveX/MozillaControl.rc +++ b/webshell/embed/ActiveX/MozillaControl.rc @@ -97,6 +97,15 @@ END IDR_MOZILLABROWSER REGISTRY DISCARDABLE "MozillaBrowser.rgs" +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MOZILLABROWSER ICON DISCARDABLE "MozillaBrowser.ico" + ///////////////////////////////////////////////////////////////////////////// // // String Table diff --git a/webshell/embed/ActiveX/MozillaControl.tlb b/webshell/embed/ActiveX/MozillaControl.tlb index 9bee40567424..0cacb7eee27e 100644 Binary files a/webshell/embed/ActiveX/MozillaControl.tlb and b/webshell/embed/ActiveX/MozillaControl.tlb differ diff --git a/webshell/embed/ActiveX/MozillaControl_i.c b/webshell/embed/ActiveX/MozillaControl_i.c index e39f7c0550c8..cb94898f8d59 100644 --- a/webshell/embed/ActiveX/MozillaControl_i.c +++ b/webshell/embed/ActiveX/MozillaControl_i.c @@ -5,7 +5,7 @@ /* File created by MIDL compiler version 3.03.0110 */ -/* at Sun Aug 23 21:54:29 1998 +/* at Sun Sep 20 22:13:10 1998 */ /* Compiler settings for MozillaControl.idl: Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext @@ -35,9 +35,6 @@ typedef struct _IID typedef IID CLSID; #endif // CLSID_DEFINED -const IID IID_IMozillaBrowser = {0x1339B54B,0x3453,0x11D2,{0x93,0xB9,0x00,0x00,0x00,0x00,0x00,0x00}}; - - const IID LIBID_MOZILLACONTROLLib = {0x1339B53E,0x3453,0x11D2,{0x93,0xB9,0x00,0x00,0x00,0x00,0x00,0x00}}; diff --git a/webshell/embed/ActiveX/MozillaControl_p.c b/webshell/embed/ActiveX/MozillaControl_p.c index fab91406bb53..2019ad81015b 100644 --- a/webshell/embed/ActiveX/MozillaControl_p.c +++ b/webshell/embed/ActiveX/MozillaControl_p.c @@ -2,7 +2,7 @@ /* File created by MIDL compiler version 3.03.0110 */ -/* at Sun Aug 23 21:54:29 1998 +/* at Sun Sep 20 22:00:35 1998 */ /* Compiler settings for MozillaControl.idl: Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext @@ -162,7 +162,7 @@ CInterfaceStubVtbl _IMozillaBrowserStubVtbl = #if !(TARGET_IS_NT40_OR_LATER) #error You need a Windows NT 4.0 or later to run this stub because it uses these features: -#error -Oif or -Oicf. +#error -Oif or -Oicf, more than 32 methods in the interface. #error However, your C/C++ compilation flags indicate you intend to run this app on earlier systems. #error This app will die there with the RPC_X_WRONG_STUB_VERSION error. #endif diff --git a/webshell/embed/ActiveX/StdAfx.h b/webshell/embed/ActiveX/StdAfx.h index f3fb52558971..f8d88339399a 100644 --- a/webshell/embed/ActiveX/StdAfx.h +++ b/webshell/embed/ActiveX/StdAfx.h @@ -23,25 +23,37 @@ extern CComModule _Module; #include #include -/* Headers from NGLayout... */ -#include +#ifdef USE_NGPREF +#include "nsIPref.h" +#endif + +#include "prtypes.h" +#include "xp_core.h" +#include "jscompat.h" + +#include "prthread.h" +#include "prprf.h" +#include "plevent.h" +#include "nsRepository.h" +#include "nsWidgetsCID.h" +#include "nsGfxCIID.h" +#include "nsViewsCID.h" +#include "nsString.h" #include "nsGlobalVariables.h" #include "nsIWebShell.h" #include "nsIPresContext.h" #include "nsIDocument.h" #include "nsIDocumentObserver.h" +#include "nsIStreamListener.h" #include "nsUnitConversion.h" #include "nsVoidArray.h" #include "nsCRT.h" -#include "prthread.h" -#include "prprf.h" -#include "nsRepository.h" -#include "nsWidgetsCID.h" -#include "nsGfxCIID.h" -#include "nsViewsCID.h" -#include "nsString.h" -#include "plevent.h" + +#include "BrowserDiagnostics.h" +#include "MozillaControl.h" +#include "WebShellContainer.h" +#include "MozillaBrowser.h" //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. diff --git a/webshell/embed/ActiveX/WebShellContainer.cpp b/webshell/embed/ActiveX/WebShellContainer.cpp index e6203d540fdb..5a47586d731d 100644 --- a/webshell/embed/ActiveX/WebShellContainer.cpp +++ b/webshell/embed/ActiveX/WebShellContainer.cpp @@ -4,10 +4,12 @@ static NS_DEFINE_IID(kIWebShellContainerIID, NS_IWEB_SHELL_CONTAINER_IID); +static NS_DEFINE_IID(kIStreamObserverIID, NS_ISTREAMOBSERVER_IID); -CWebShellContainer::CWebShellContainer() +CWebShellContainer::CWebShellContainer(CMozillaBrowser *pOwner) { + m_pOwner = pOwner; } @@ -15,6 +17,10 @@ CWebShellContainer::~CWebShellContainer() { } + +/////////////////////////////////////////////////////////////////////////////// +// nsISupports implementation + NS_IMPL_ADDREF(CWebShellContainer) NS_IMPL_RELEASE(CWebShellContainer) @@ -31,13 +37,13 @@ nsresult CWebShellContainer::QueryInterface(const nsIID& aIID, void** aInstanceP *aInstancePtrResult = (void*) ((nsIBrowserWindow*)this); AddRef(); return NS_OK; - } + } */ if (aIID.Equals(kIStreamObserverIID)) { *aInstancePtrResult = (void*) ((nsIStreamObserver*)this); AddRef(); return NS_OK; } - */ + if (aIID.Equals(kIWebShellContainerIID)) { *aInstancePtrResult = (void*) ((nsIWebShellContainer*)this); AddRef(); @@ -57,47 +63,63 @@ nsresult CWebShellContainer::QueryInterface(const nsIID& aIID, void** aInstanceP return NS_NOINTERFACE; } +/////////////////////////////////////////////////////////////////////////////// +// nsIWebShellContainer implementation + NS_IMETHODIMP CWebShellContainer::WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason) { -// if (mStatus) { -// nsAutoString url("Connecting to "); -// url.Append(aURL); -// mStatus->SetText(url); -// } return NS_OK; } NS_IMETHODIMP CWebShellContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) { -// if (mThrobber) { -// mThrobber->Start(); -// mLocation->SetText(aURL); -// } + USES_CONVERSION; + OLECHAR *pszURL = W2OLE((WCHAR *)aURL); + BSTR bstrURL = SysAllocString(pszURL); + BSTR bstrTargetFrameName = NULL; + BSTR bstrHeaders = NULL; + VARIANT *pvPostData = NULL; + VARIANT_BOOL bCancel = VARIANT_FALSE; + long lFlags = 0; + + m_pOwner->Fire_BeforeNavigate(bstrURL, lFlags, bstrTargetFrameName, pvPostData, bstrHeaders, &bCancel); + if (bCancel == VARIANT_TRUE) + { + // TODO cancel browsing somehow + } + + SysFreeString(bstrURL); + SysFreeString(bstrTargetFrameName); + SysFreeString(bstrHeaders); + return NS_OK; } NS_IMETHODIMP CWebShellContainer::ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax) { + m_pOwner->Fire_ProgressChange(aProgress, aProgressMax); return NS_OK; } NS_IMETHODIMP CWebShellContainer::EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus) { -// if (mThrobber) { -// mThrobber->Stop(); -// } + USES_CONVERSION; + OLECHAR *pszURL = W2OLE((WCHAR *) aURL); + BSTR bstrURL = SysAllocString(pszURL); + m_pOwner->Fire_NavigateComplete(bstrURL); + SysFreeString(bstrURL); + return NS_OK; } NS_IMETHODIMP CWebShellContainer::NewWebShell(nsIWebShell *&aNewWebShell) { - nsresult rv = NS_OK; - rv = NS_ERROR_OUT_OF_MEMORY; + nsresult rv = NS_ERROR_OUT_OF_MEMORY; return rv; } @@ -106,3 +128,32 @@ CWebShellContainer::FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& a { return NS_ERROR_FAILURE; } + + +/////////////////////////////////////////////////////////////////////////////// +// nsIStreamObserver implementation + + +NS_IMETHODIMP +CWebShellContainer::OnStartBinding(nsIURL* aURL, const char *aContentType) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +CWebShellContainer::OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +CWebShellContainer::OnStatus(nsIURL* aURL, const nsString &aMsg) +{ + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP +CWebShellContainer::OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg) +{ + return NS_ERROR_FAILURE; +} diff --git a/webshell/embed/ActiveX/WebShellContainer.h b/webshell/embed/ActiveX/WebShellContainer.h index 9b28f509495b..9af83d9cd71a 100644 --- a/webshell/embed/ActiveX/WebShellContainer.h +++ b/webshell/embed/ActiveX/WebShellContainer.h @@ -1,17 +1,21 @@ #ifndef WEBSHELLCONTAINER_H #define WEBSHELLCONTAINER_H +class CMozillaBrowser; + class CWebShellContainer : - public nsIWebShellContainer + public nsIWebShellContainer, + public nsIStreamObserver { public: - CWebShellContainer(); + CWebShellContainer(CMozillaBrowser *pOwner); protected: virtual ~CWebShellContainer(); // Protected members protected: nsString m_sTitle; + CMozillaBrowser *m_pOwner; public: // nsISupports @@ -23,7 +27,13 @@ public: NS_IMETHOD ProgressLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aProgress, PRInt32 aProgressMax); NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, PRInt32 aStatus); NS_IMETHOD NewWebShell(nsIWebShell *&aNewWebShell); - NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult); + NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult); + + // nsIStreamObserver + NS_IMETHOD OnStartBinding(nsIURL* aURL, const char *aContentType); + NS_IMETHOD OnProgress(nsIURL* aURL, PRInt32 aProgress, PRInt32 aProgressMax); + NS_IMETHOD OnStatus(nsIURL* aURL, const nsString &aMsg); + NS_IMETHOD OnStopBinding(nsIURL* aURL, PRInt32 aStatus, const nsString &aMsg); }; #endif \ No newline at end of file diff --git a/webshell/embed/ActiveX/makefile.win b/webshell/embed/ActiveX/makefile.win index 522f801fd8b0..8090eaa85210 100644 --- a/webshell/embed/ActiveX/makefile.win +++ b/webshell/embed/ActiveX/makefile.win @@ -28,17 +28,17 @@ MAKE_OBJ_TYPE = DLL DLL=.\$(OBJDIR)\$(DLLNAME).dll RESFILE = $(DLLNAME).res DEFFILE = $(DLLNAME).def -OS_CFLAGS = /D "WIN32" +OS_CFLAGS = /D "WIN32" -OBJS = \ +OBJS = \ .\$(OBJDIR)\StdAfx.obj \ - .\$(OBJDIR)\nsSetupRegistry.obj \ + .\$(OBJDIR)\nsSetupRegistry.obj \ .\$(OBJDIR)\MozillaControl.obj \ .\$(OBJDIR)\MozillaBrowser.obj \ .\$(OBJDIR)\WebShellContainer.obj \ $(NULL) -LINCS= \ +LINCS= \ -I$(PUBLIC)\raptor \ -I$(PUBLIC)\xpcom \ -I$(PUBLIC)\dom \ @@ -82,7 +82,7 @@ MozillaControl_i.c MozillaControl.h: MozillaControl.idl MozillaControl.cpp \ MozillaBrowser.cpp \ WebShellContainer.cpp \ -StdAfx.cpp: StdAfx.h MozillaControl.h +StdAfx.cpp: StdAfx.h MozillaControl.h MozillaBrowser.h WebShellContainer.h clobber:: regsvr32 /s /c /u $(DIST)\bin\$(DLLNAME).dll diff --git a/webshell/embed/ActiveX/resource.h b/webshell/embed/ActiveX/resource.h index 160c771f833e..07933c74207a 100644 --- a/webshell/embed/ActiveX/resource.h +++ b/webshell/embed/ActiveX/resource.h @@ -4,12 +4,13 @@ // #define IDS_PROJNAME 100 #define IDR_MOZILLABROWSER 101 +#define IDI_MOZILLABROWSER 201 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_RESOURCE_VALUE 202 #define _APS_NEXT_COMMAND_VALUE 32768 #define _APS_NEXT_CONTROL_VALUE 201 #define _APS_NEXT_SYMED_VALUE 102