Commit 0ebbcedd authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use global security manager.

parent 067e982b
...@@ -5446,6 +5446,10 @@ static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID rii ...@@ -5446,6 +5446,10 @@ static HRESULT create_document_object(BOOL is_mhtml, IUnknown *outer, REFIID rii
return E_INVALIDARG; return E_INVALIDARG;
} }
/* ensure that security manager is initialized */
if(!get_security_manager())
return E_OUTOFMEMORY;
doc = heap_alloc_zero(sizeof(HTMLDocumentObj)); doc = heap_alloc_zero(sizeof(HTMLDocumentObj));
if(!doc) if(!doc)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
......
...@@ -228,9 +228,6 @@ static void release_outer_window(HTMLOuterWindow *This) ...@@ -228,9 +228,6 @@ static void release_outer_window(HTMLOuterWindow *This)
if(This->base.inner_window) if(This->base.inner_window)
detach_inner_window(This->base.inner_window); detach_inner_window(This->base.inner_window);
if(This->secmgr)
IInternetSecurityManager_Release(This->secmgr);
if(This->frame_element) if(This->frame_element)
This->frame_element->content_window = NULL; This->frame_element->content_window = NULL;
...@@ -3574,12 +3571,6 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, ...@@ -3574,12 +3571,6 @@ HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
return hres; return hres;
} }
hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
if(FAILED(hres)) {
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
return hres;
}
if(parent) { if(parent) {
IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface); IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
......
...@@ -54,6 +54,7 @@ DWORD mshtml_tls = TLS_OUT_OF_INDEXES; ...@@ -54,6 +54,7 @@ DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
static HINSTANCE shdoclc = NULL; static HINSTANCE shdoclc = NULL;
static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1]; static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
static IMultiLanguage2 *mlang; static IMultiLanguage2 *mlang;
static IInternetSecurityManager *security_manager;
static unsigned global_max_compat_mode = COMPAT_MODE_IE11; static unsigned global_max_compat_mode = COMPAT_MODE_IE11;
static struct list compat_config = LIST_INIT(compat_config); static struct list compat_config = LIST_INIT(compat_config);
...@@ -118,6 +119,23 @@ BSTR charset_string_from_cp(UINT cp) ...@@ -118,6 +119,23 @@ BSTR charset_string_from_cp(UINT cp)
return SysAllocString(info.wszWebCharset); 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) static BOOL read_compat_mode(HKEY key, compat_mode_t *r)
{ {
WCHAR version[32]; WCHAR version[32];
...@@ -266,6 +284,8 @@ static void process_detach(void) ...@@ -266,6 +284,8 @@ static void process_detach(void)
TlsFree(mshtml_tls); TlsFree(mshtml_tls);
if(mlang) if(mlang)
IMultiLanguage2_Release(mlang); IMultiLanguage2_Release(mlang);
if(security_manager)
IInternetSecurityManager_Release(security_manager);
free_strings(); free_strings();
} }
......
...@@ -499,8 +499,6 @@ struct HTMLOuterWindow { ...@@ -499,8 +499,6 @@ struct HTMLOuterWindow {
SCRIPTMODE scriptmode; SCRIPTMODE scriptmode;
IInternetSecurityManager *secmgr;
struct list sibling_entry; struct list sibling_entry;
struct wine_rb_entry entry; struct wine_rb_entry entry;
}; };
...@@ -1330,5 +1328,6 @@ UINT cp_from_charset_string(BSTR) DECLSPEC_HIDDEN; ...@@ -1330,5 +1328,6 @@ UINT cp_from_charset_string(BSTR) DECLSPEC_HIDDEN;
BSTR charset_string_from_cp(UINT) DECLSPEC_HIDDEN; BSTR charset_string_from_cp(UINT) DECLSPEC_HIDDEN;
HINSTANCE get_shdoclc(void) DECLSPEC_HIDDEN; HINSTANCE get_shdoclc(void) DECLSPEC_HIDDEN;
void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN; void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN;
IInternetSecurityManager *get_security_manager(void) DECLSPEC_HIDDEN;
extern HINSTANCE hInst DECLSPEC_HIDDEN; extern HINSTANCE hInst DECLSPEC_HIDDEN;
...@@ -818,6 +818,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface, ...@@ -818,6 +818,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
if(This->document_mode == COMPAT_MODE_QUIRKS) { if(This->document_mode == COMPAT_MODE_QUIRKS) {
nsIDOMDocumentType *nsdoctype; nsIDOMDocumentType *nsdoctype;
nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMDocumentType, (void**)&nsdoctype); nsres = nsIContent_QueryInterface(aContent, &IID_nsIDOMDocumentType, (void**)&nsdoctype);
if(NS_SUCCEEDED(nsres)) { if(NS_SUCCEEDED(nsres)) {
compat_mode_t mode = COMPAT_MODE_IE7; compat_mode_t mode = COMPAT_MODE_IE7;
...@@ -835,7 +836,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface, ...@@ -835,7 +836,7 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
* X-UA-Compatible version, allow configuration and default to higher version * X-UA-Compatible version, allow configuration and default to higher version
* (once it's well supported). * (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) if(SUCCEEDED(hres) && zone == URLZONE_INTERNET)
mode = COMPAT_MODE_IE8; mode = COMPAT_MODE_IE8;
} }
......
...@@ -62,7 +62,7 @@ static BOOL use_gecko_script(HTMLOuterWindow *window) ...@@ -62,7 +62,7 @@ static BOOL use_gecko_script(HTMLOuterWindow *window)
DWORD zone; DWORD zone;
HRESULT hres; HRESULT hres;
hres = IInternetSecurityManager_MapUrlToZone(window->secmgr, window->url, &zone, 0); hres = IInternetSecurityManager_MapUrlToZone(get_security_manager(), window->url, &zone, 0);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("Could not map %s to zone: %08x\n", debugstr_w(window->url), hres); WARN("Could not map %s to zone: %08x\n", debugstr_w(window->url), hres);
return TRUE; return TRUE;
......
...@@ -86,7 +86,7 @@ static HRESULT WINAPI InternetHostSecurityManager_ProcessUrlAction(IInternetHost ...@@ -86,7 +86,7 @@ static HRESULT WINAPI InternetHostSecurityManager_ProcessUrlAction(IInternetHost
url = This->basedoc.window->url ? This->basedoc.window->url : about_blankW; 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); pContext, cbContext, dwFlags, dwReserved);
} }
...@@ -122,7 +122,7 @@ static HRESULT confirm_safety(HTMLDocumentNode *This, const WCHAR *url, struct C ...@@ -122,7 +122,7 @@ static HRESULT confirm_safety(HTMLDocumentNode *This, const WCHAR *url, struct C
/* FIXME: Check URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY */ /* 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); (BYTE*)&policy, sizeof(policy), NULL, 0, 0, 0);
if(FAILED(hres) || policy != URLPOLICY_ALLOW) { if(FAILED(hres) || policy != URLPOLICY_ALLOW) {
*ret = URLPOLICY_DISALLOW; *ret = URLPOLICY_DISALLOW;
...@@ -191,7 +191,7 @@ static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHos ...@@ -191,7 +191,7 @@ static HRESULT WINAPI InternetHostSecurityManager_QueryCustomPolicy(IInternetHos
url = This->basedoc.window->url ? This->basedoc.window->url : about_blankW; 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); pContext, cbContext, dwReserved);
if(hres != HRESULT_FROM_WIN32(ERROR_NOT_FOUND)) if(hres != HRESULT_FROM_WIN32(ERROR_NOT_FOUND))
return hres; return hres;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment