【发布时间】:2011-03-30 15:23:23
【问题描述】:
我似乎无法理解如何将 IHttpSecurity::OnSecurityProblem 的实现提供给 IWebBrowser2 对象。
我知道我需要实现一个类似这样的类:
class CServiceProvider : public IServiceProvider
{
public:
CServiceProvider();
~CServiceProvider();
// IUnknown
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
STDMETHODIMP QueryInterface(REFIID iid, void ** ppvObject);
//QueryService
STDMETHODIMP QueryService(REFGUID guidService,REFIID riid,void **ppv);
private:
ULONG m_ulRefCnt;
};
并且在 QueryService 函数中,当它请求 IID_IHttpSecurity 时,我会返回 IHttpSecurity 接口的实现。
但我的问题是我如何在 IWebBrowser2 对象上设置我的服务提供者实现以及何时?
我的代码是这样的:
IWebBrowser2 *_Browser;
IServiceProvider* pServiceProvider = NULL;
_Browser->QueryInterface(
IID_IServiceProvider,
(void**)&pServiceProvider);
IHttpSecurity* pi;
pServiceProvider->QueryService(IID_IHttpSecurity, &pi);
_Browser->Navigate(url.AllocSysString(),
&flags,
&target_frame_name,
&post_data,
&headers);
这个问题就像我在想如果是,那么我该怎么做,如果不是,你能解释一下它是如何工作的并且可以设置吗?
PS:我只想实现IID_IHttpSecurity接口,QueryService上请求的所有其他接口都应该做系统提供的默认实现...
谢谢
【问题讨论】: