/** * @file XTPWebBrowserProvider.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #if !defined(__XTPWEBBROWSERPROVIDER_H__) /** @cond */ # define __XTPWEBBROWSERPROVIDER_H__ /** @endcond */ /** @cond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" # include # include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.h" class CXTPWebBrowserCtrl; struct IXTPWebBrowserHost; class CXTPWebBrowserControlSite; # define XTP_WEBBROWSER_RESOLVE_USERAGENT(pv) \ (NULL != (pv) && VT_BSTR == (pv)->vt && NULL != (pv)->bstrVal \ && 0 < ::SysStringLen((pv)->bstrVal) \ ? (pv)->bstrVal \ : NULL) # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** @endcond */ /** * @brief * Implements the base class for a WebBrowser provider. */ class _XTP_EXT_CLASS CXTPWebBrowserProvider : public CXTPCmdTarget { /** @cond */ DECLARE_DYNAMIC(CXTPWebBrowserProvider) /** @endcond */ friend class CXTPWebBrowserCtrl; protected: /** * @brief * Handles provider construction. * @param host The host object. */ CXTPWebBrowserProvider(IXTPWebBrowserHost& host); public: /** * @brief * Handles provider destruction. */ virtual ~CXTPWebBrowserProvider(); /** * @brief * Obtains the native WebBrowser provider object or NULL if no provider is activated or the * current provider does not provide access to its core object via IUnknown. * @return * Obtains the native WebBrowser provider object. */ IUnknown* GetBrowserObject() const; /** * @brief * Gets the client interface. * @param riid Client interface IID. * @return * Client interface pointer or NULL if no requested interface is added. * @details * If a provider supports client site, the client interface provided * may be requested by the provider at any moment thus making it possible * to customize and extend WebBrowser functionality by adding provider * specific client interfaces implemented by the user code. */ IUnknown* GetClientInterface(REFIID riid) const; /** * @brief * Sets the client interface. * @param riid Client interface IID. * @param pUnk Client interface pointer. * @details * If a provider supports client site, the client interface provided * may be requested by the provider at any moment thus making it possible * to customize and extend WebBrowser functionality by adding provider * specific client interfaces implemented by the user code. */ void SetClientInterface(REFIID riid, IUnknown* pUnk); /** * @brief * Removes the client interface. * @param riid Client interface IID. * @details * If a provider supports client site, the client interface provided * may be requested by the provider at any moment thus making it possible * to customize and extend WebBrowser functionality by adding provider * specific client interfaces implemented by the user code. */ void RemoveClientInterface(REFIID riid); /** * @brief * Executes a script by the active WebBrowser provider. * @param pText Script code text. * @param pvtResult The optional pointer to the variant object that is supposed to receive the * result of the executed script. * @return * S_OK if script execution or its attempt are successful or an error code otherwise. * @details * The language of the script code is provider specific. Currently each provider supports * JavaScript by default. */ virtual HRESULT ExecuteScript(LPCWSTR pText, CComVariant* pvtResult = NULL) = 0; /** @cond */ IXTPWebBrowserHost& GetHost() const; virtual HRESULT Initialize() = 0; virtual HRESULT Navigate(LPCTSTR pUrl) = 0; virtual HRESULT LoadHtml(LPCTSTR pHtml) = 0; virtual HRESULT WaitUntilReady() = 0; virtual void ReleaseBrowser() = 0; virtual BOOL OnHostWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) = 0; /** @endcond */ protected: /** @cond */ const CString& GetUrl() const; void SetUrl(CString strUrl); virtual void OnCreateBrowser(IUnknown* pObject); virtual void OnDestroyBrowser(); virtual CXTPWebBrowserControlSite* CreateControlSite(COleControlContainer* pCtrlContainer); virtual void UpdateExternal(); /** @endcond */ private: void ReleaseSite(); protected: IXTPWebBrowserHost& m_Host; /**< The host control interface */ private: CXTPWebBrowserProvider(const CXTPWebBrowserProvider&); CXTPWebBrowserProvider& operator=(const CXTPWebBrowserProvider&); COleControlContainer* m_pCtrlContainer; IUnknown* m_pBrowserObject; CXTPWebBrowserControlSite* m_pSite; CString m_strUrl; struct ClientInterface { IID iid; LPUNKNOWN pUnk; }; typedef CArray ClientInterfaceArray; ClientInterfaceArray* m_parrClientInterfaces; }; /** @cond */ AFX_INLINE IXTPWebBrowserHost& CXTPWebBrowserProvider::GetHost() const { return m_Host; } AFX_INLINE IUnknown* CXTPWebBrowserProvider::GetBrowserObject() const { return m_pBrowserObject; } AFX_INLINE const CString& CXTPWebBrowserProvider::GetUrl() const { return m_strUrl; } AFX_INLINE void CXTPWebBrowserProvider::SetUrl(CString strUrl) { m_strUrl = strUrl; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif /** @endcond */