mshtml: Added IInternetHostSecurity::ProcessUrlAction implementation.
[wine] / dlls / mshtml / secmgr.c
1 /*
2  * Copyright 2009 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
38
39 #define HOSTSECMGR_THIS(iface) DEFINE_THIS(HTMLDocumentNode, IInternetHostSecurityManager, iface)
40
41 static HRESULT WINAPI InternetHostSecurityManager_QueryInterface(IInternetHostSecurityManager *iface, REFIID riid, void **ppv)
42 {
43     HTMLDocumentNode *This = HOSTSECMGR_THIS(iface);
44     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
45 }
46
47 static ULONG WINAPI InternetHostSecurityManager_AddRef(IInternetHostSecurityManager *iface)
48 {
49     HTMLDocumentNode *This = HOSTSECMGR_THIS(iface);
50     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
51 }
52
53 static ULONG WINAPI InternetHostSecurityManager_Release(IInternetHostSecurityManager *iface)
54 {
55     HTMLDocumentNode *This = HOSTSECMGR_THIS(iface);
56     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
57 }
58
59 static HRESULT WINAPI InternetHostSecurityManager_GetSecurityId(IInternetHostSecurityManager *iface,  BYTE *pbSecurityId,
60         DWORD *pcbSecurityId, DWORD_PTR dwReserved)
61 {
62     HTMLDocumentNode *This = HOSTSECMGR_THIS(iface);
63     FIXME("(%p)->(%p %p %lx)\n", This, pbSecurityId, pcbSecurityId, dwReserved);
64     return E_NOTIMPL;
65 }
66
67 static HRESULT WINAPI InternetHostSecurityManager_ProcessUrlAction(IInternetHostSecurityManager *iface, DWORD dwAction,
68         BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved)
69 {
70     HTMLDocumentNode *This = HOSTSECMGR_THIS(iface);
71     const WCHAR *url;
72
73     TRACE("%p)->(%d %p %d %p %d %x %x)\n", This, dwAction, pPolicy, cbPolicy, pContext, cbContext, dwFlags, dwReserved);
74
75     url = This->basedoc.doc_obj->url ? This->basedoc.doc_obj->url : about_blankW;
76
77     return IInternetSecurityManager_ProcessUrlAction(This->secmgr, url, dwAction, pPolicy, cbPolicy,
78             pContext, cbContext, dwFlags, dwReserved);
79 }
80
81 static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHostSecurityManager *iface, REFGUID guidKey,
82         BYTE **ppPolicy, DWORD *pcbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwReserved)
83 {
84     HTMLDocumentNode *This = HOSTSECMGR_THIS(iface);
85     FIXME("(%p)->(%s %p %p %p %d %x)\n", This, debugstr_guid(guidKey), ppPolicy, pcbPolicy, pContext, cbContext, dwReserved);
86     return E_NOTIMPL;
87 }
88
89 #undef HOSTSECMGR_THIS
90
91 static const IInternetHostSecurityManagerVtbl InternetHostSecurityManagerVtbl = {
92     InternetHostSecurityManager_QueryInterface,
93     InternetHostSecurityManager_AddRef,
94     InternetHostSecurityManager_Release,
95     InternetHostSecurityManager_GetSecurityId,
96     InternetHostSecurityManager_ProcessUrlAction,
97     InternetHostSecurityManager_QueryCustomPolicy
98 };
99
100 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode *This)
101 {
102     This->lpIInternetHostSecurityManagerVtbl = &InternetHostSecurityManagerVtbl;
103 }