/** * @file XTPWebBrowserControlSite.cpp * * @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 * */ #include "stdafx.h" #include "Common/XTPTypeId.h" #include "Common/XTPCasting.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "Common/XTPSynchro.h" #include "Common/XTPApplication.h" #include "Controls/WebBrowser/XTPWebBrowserAbstract.h" #include "Controls/WebBrowser/Providers/XTPWebBrowserProvider.h" #include "Controls/WebBrowser/Providers/XTPWebBrowserControlSite.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif /////////////////////////////////////////////////////////////////////////////// // CXTPWebBrowserAggregate class CXTPWebBrowserAggregate : IUnknown { CXTPWebBrowserProvider* m_pProvider; ULONG m_nRefs; public: CXTPWebBrowserAggregate(CXTPWebBrowserProvider* pProvider) : m_pProvider(pProvider) , m_nRefs(1) { _ASSERTE(NULL != m_pProvider); } virtual ~CXTPWebBrowserAggregate() { } virtual HRESULT STDMETHODCALLTYPE QueryInterface( /* [in] */ REFIID riid, /* [iid_is][out] */ void** ppvObject) { LPUNKNOWN pUnk = m_pProvider->GetClientInterface(riid); if (NULL != pUnk) { *ppvObject = pUnk; pUnk->AddRef(); return S_OK; } return static_cast(m_pProvider->ExternalQueryInterface(&riid, ppvObject)); } virtual ULONG STDMETHODCALLTYPE AddRef(void) { m_pProvider->ExternalAddRef(); return ++m_nRefs; } virtual ULONG STDMETHODCALLTYPE Release(void) { if (0 == --m_nRefs) { delete this; return 0; } m_pProvider->ExternalRelease(); return m_nRefs; } }; /////////////////////////////////////////////////////////////////////////////// // CXTPWebBrowserControlSite CXTPWebBrowserControlSite::CXTPWebBrowserControlSite(COleControlContainer* pCtrlCont, CXTPWebBrowserProvider* pProvider) : COleControlSite(pCtrlCont) , m_pProvider(pProvider) , m_pAggregate(NULL) { EnableAggregation(); OnCreateAggregates(); } CXTPWebBrowserControlSite::~CXTPWebBrowserControlSite() { SAFE_RELEASE(m_pAggregate); } BOOL CXTPWebBrowserControlSite::OnCreateAggregates() { _ASSERTE(NULL == m_pAggregate); m_pAggregate = new CXTPWebBrowserAggregate(m_pProvider); return TRUE; } #include "Common/Base/Diagnostic/XTPBeginAfxMap.h" BEGIN_INTERFACE_MAP(CXTPWebBrowserControlSite, COleControlSite) INTERFACE_AGGREGATE(CXTPWebBrowserControlSite, m_pAggregate) END_INTERFACE_MAP() #include "Common/Base/Diagnostic/XTPEndAfxMap.h" #include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"