如何处理具有 IWebBrowser2 对象的 IHttpSecurity::OnSecurityProblem
我似乎无法理解如何将 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 上请求的所有其他接口都应该执行系统提供的默认实现...
谢谢
I can't seem to understand how i give my implementation of the IHttpSecurity::OnSecurityProblem to my IWebBrowser2 object.
I know that i need to implement a class something like this:
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;
};
And in the QueryService function when it requests the IID_IHttpSecurity i return my implementation of the IHttpSecurity interface.
But my problem is how i set the my service provider implementation on the IWebBrowser2 object and when?
My code is something like this:
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);
The question this works like i'm thinking if yes how i do this then, and if not can you explain how this works and can be setted?
PS: i only whant to implement the IID_IHttpSecurity interface, all other interfaces requested on the QueryService should do the default implementation provided by the system...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经弄清楚这是如何完成的。
使用 MFC,我们只需要实现 CCustomOccManager,它实现 COccManager,而 CreateSite 函数的实现返回 COleControlSite 的实现(例如 CCustomControlSite)。在此类中,您将需要至少重写 IServiceProvider 接口的 QueryService 函数,并在此实现中提供您的 IHttpSecurity 实现(当接口需要时)。
最后,我们使用 MFC 函数 AfxEnableControlContainer 在 App InitInstance 中注册所有这些。
代码:
在 App InitInstance 中,对我们的实现简单调用 AfxEnableControlContainer:
如果有人了解如何在不使用 MFC 的情况下完成此操作,请告诉我。
谢谢
I already figure out how this is done.
Using MFC we only need to implement CCustomOccManager that implements the COccManager in witch the implementation of CreateSite function returns an implementation of our COleControlSite (example CCustomControlSite). In this class you will need to override at least the QueryService function of IServiceProvider interface and in this implementation supply yours IHttpSecurity implementation (when required by the interface).
In the end the we register all this in the App InitInstance using the MFC function AfxEnableControlContainer.
Code:
In the App InitInstance simple call AfxEnableControlContainer on our implementation:
If someone has the knowledge on how this is done without using MFC please let me know.
Thanks
从 IServiceProvider 的 文档 中的注释来看,您的IOleClientSite 对象需要实现 IServiceProvider。
Judging by the remarks in the documentation for IServiceProvider, it seems like your IOleClientSite object needs to implement IServiceProvider.