mshtml: Use global security manager.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-03-11 14:24:09 +01:00 committed by Alexandre Julliard
parent 067e982b3c
commit 0ebbceddaa
7 changed files with 31 additions and 16 deletions

View File

@ -5446,6 +5446,10 @@ static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID rii
return E_INVALIDARG;
}
/* ensure that security manager is initialized */
if(!get_security_manager())
return E_OUTOFMEMORY;
doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
if(!doc)
return E_OUTOFMEMORY;

View File

@ -228,9 +228,6 @@ static void release_outer_window(HTMLOuterWindow *This)
if(This->base.inner_window)
detach_inner_window(This->base.inner_window);
if(This->secmgr)
IInternetSecurityManager_Release(This->secmgr);
if(This->frame_element)
This->frame_element->content_window = NULL;
@ -3574,12 +3571,6 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
return hres;
}
hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
if(FAILED(hres)) {
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
return hres;
}
if(parent) {
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);

View File

@ -54,6 +54,7 @@ DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
static HINSTANCE shdoclc = NULL;
static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
static IMultiLanguage2 *mlang;
static IInternetSecurityManager *security_manager;
static unsigned global_max_compat_mode = COMPAT_MODE_IE11;
static struct list compat_config = LIST_INIT(compat_config);
@ -118,6 +119,23 @@ BSTR charset_string_from_cp(UINT cp)
return SysAllocString(info.wszWebCharset);
}
IInternetSecurityManager *get_security_manager(void)
{
if(!security_manager) {
IInternetSecurityManager *manager;
HRESULT hres;
hres = CoInternetCreateSecurityManager(NULL, &manager, 0);
if(FAILED(hres))
return NULL;
if(InterlockedCompareExchangePointer((void**)&security_manager, manager, NULL))
IInternetSecurityManager_Release(manager);
}
return security_manager;
}
static BOOL read_compat_mode(HKEY key, compat_mode_t *r)
{
WCHAR version[32];
@ -266,6 +284,8 @@ static void process_detach(void)
TlsFree(mshtml_tls);
if(mlang)
IMultiLanguage2_Release(mlang);
if(security_manager)
IInternetSecurityManager_Release(security_manager);
free_strings();
}

View File

@ -499,8 +499,6 @@ struct HTMLOuterWindow {
SCRIPTMODE scriptmode;
IInternetSecurityManager *secmgr;
struct list sibling_entry;
struct wine_rb_entry entry;
};
@ -1330,5 +1328,6 @@ UINT cp_from_charset_string(BSTR) DECLSPEC_HIDDEN;
BSTR charset_string_from_cp(UINT) DECLSPEC_HIDDEN;
HINSTANCE get_shdoclc(void) DECLSPEC_HIDDEN;
void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN;
IInternetSecurityManager *get_security_manager(void) DECLSPEC_HIDDEN;
extern HINSTANCE hInst DECLSPEC_HIDDEN;

View File

@ -818,6 +818,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
if(This->document_mode == COMPAT_MODE_QUIRKS) {
nsIDOMDocumentType *nsdoctype;
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
if(NS_SUCCEEDED(nsres)) {
compat_mode_t mode = COMPAT_MODE_IE7;
@ -835,7 +836,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
* X-UA-Compatible version, allow configuration and default to higher version
* (once it's well supported).
*/
hres = IInternetSecurityManager_MapUrlToZone(window->secmgr, window->url, &zone, 0);
hres = IInternetSecurityManager_MapUrlToZone(get_security_manager(), window->url, &zone, 0);
if(SUCCEEDED(hres) && zone == URLZONE_INTERNET)
mode = COMPAT_MODE_IE8;
}

View File

@ -62,7 +62,7 @@ static BOOL use_gecko_script(HTMLOuterWindow *window)
DWORD zone;
HRESULT hres;
hres = IInternetSecurityManager_MapUrlToZone(window->secmgr, window->url, &zone, 0);
hres = IInternetSecurityManager_MapUrlToZone(get_security_manager(), window->url, &zone, 0);
if(FAILED(hres)) {
WARN("Could not map %s to zone: %08x\n", debugstr_w(window->url), hres);
return TRUE;

View File

@ -86,7 +86,7 @@ static HRESULT WINAPI InternetHostSecurityManager_ProcessUrlAction(IInternetHost
url = This->basedoc.window->url ? This->basedoc.window->url : about_blankW;
return IInternetSecurityManager_ProcessUrlAction(This->basedoc.window->secmgr, url, dwAction, pPolicy, cbPolicy,
return IInternetSecurityManager_ProcessUrlAction(get_security_manager(), url, dwAction, pPolicy, cbPolicy,
pContext, cbContext, dwFlags, dwReserved);
}
@ -122,7 +122,7 @@ static HRESULT confirm_safety(HTMLDocumentNode *This, const WCHAR *url, struct C
/* FIXME: Check URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY */
hres = IInternetSecurityManager_ProcessUrlAction(This->basedoc.window->secmgr, url, URLACTION_SCRIPT_SAFE_ACTIVEX,
hres = IInternetSecurityManager_ProcessUrlAction(get_security_manager(), url, URLACTION_SCRIPT_SAFE_ACTIVEX,
(BYTE*)&policy, sizeof(policy), NULL, 0, 0, 0);
if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
*ret = URLPOLICY_DISALLOW;
@ -191,7 +191,7 @@ static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHos
url = This->basedoc.window->url ? This->basedoc.window->url : about_blankW;
hres = IInternetSecurityManager_QueryCustomPolicy(This->basedoc.window->secmgr, url, guidKey, ppPolicy, pcbPolicy,
hres = IInternetSecurityManager_QueryCustomPolicy(get_security_manager(), url, guidKey, ppPolicy, pcbPolicy,
pContext, cbContext, dwReserved);
if(hres != HRESULT_FROM_WIN32(ERROR_NOT_FOUND))
return hres;