Commit 3d4dbd3c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use correct principal to create in create_nsxhr.

parent 0ff1b0c3
......@@ -49,7 +49,6 @@ WINE_DECLARE_DEBUG_CHANNEL(gecko);
#define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1"
#define NS_CATEGORYMANAGER_CONTRACTID "@mozilla.org/categorymanager;1"
#define NS_XMLHTTPREQUEST_CONTRACTID "@mozilla.org/xmlextras/xmlhttprequest;1"
#define NS_SCRIPTSECURITYMANAGER_CONTRACTID "@mozilla.org/scriptsecuritymanager;1"
#define PR_UINT32_MAX 0xffffffff
......@@ -2159,34 +2158,33 @@ void NSContainer_Release(NSContainer *This)
nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
}
/*
* FIXME: nsIScriptObjectPrincipal uses thiscall calling convention, so we need this hack on i386.
* This will be removed after the next Gecko update, that will change calling convention on Gecko side.
*/
#ifdef __i386__
extern void *call_thiscall_func;
__ASM_GLOBAL_FUNC(call_thiscall_func,
"popl %eax\n\t"
"popl %edx\n\t"
"popl %ecx\n\t"
"pushl %eax\n\t"
"jmp *%edx\n\t")
#define nsIScriptObjectPrincipal_GetPrincipal(this) ((void* (WINAPI*)(void*,void*))&call_thiscall_func)((this)->lpVtbl->GetPrincipal,this)
#endif
nsIXMLHttpRequest *create_nsxhr(nsIDOMWindow *nswindow)
{
nsIScriptObjectPrincipal *sop;
mozIDOMWindow *inner_window;
nsIScriptSecurityManager *secman;
nsIPrincipal *nspri;
nsIGlobalObject *nsglo;
nsIXMLHttpRequest *nsxhr;
nsresult nsres;
nsres = nsIServiceManager_GetServiceByContractID(pServMgr,
NS_SCRIPTSECURITYMANAGER_CONTRACTID,
&IID_nsIScriptSecurityManager, (void**)&secman);
if(NS_FAILED(nsres)) {
ERR("Could not get sec manager service: %08x\n", nsres);
return NULL;
}
nsres = nsIScriptSecurityManager_GetSystemPrincipal(secman, &nspri);
nsIScriptSecurityManager_Release(secman);
if(NS_FAILED(nsres)) {
ERR("GetSystemPrincipal failed: %08x\n", nsres);
return NULL;
}
nsres = nsIDOMWindow_GetInnerWindow(nswindow, &inner_window);
if(NS_FAILED(nsres)) {
ERR("Could not get inner window: %08x\n", nsres);
nsISupports_Release(nspri);
return NULL;
}
......@@ -2194,24 +2192,26 @@ nsIXMLHttpRequest *create_nsxhr(nsIDOMWindow *nswindow)
mozIDOMWindow_Release(inner_window);
assert(nsres == NS_OK);
nsres = nsIGlobalObject_QueryInterface(nsglo, &IID_nsIScriptObjectPrincipal, (void**)&sop);
assert(nsres == NS_OK);
nspri = nsIScriptObjectPrincipal_GetPrincipal(sop);
nsIScriptObjectPrincipal_Release(sop);
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
NS_XMLHTTPREQUEST_CONTRACTID, NULL, &IID_nsIXMLHttpRequest,
(void**)&nsxhr);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIXMLHttpRequest: %08x\n", nsres);
nsISupports_Release(nspri);
nsIGlobalObject_Release(nsglo);
return NULL;
}
if(NS_SUCCEEDED(nsres)) {
nsres = nsIXMLHttpRequest_Init(nsxhr, nspri, NULL, nsglo, NULL, NULL);
if(NS_FAILED(nsres))
nsIXMLHttpRequest_Release(nsxhr);
}
nsISupports_Release(nspri);
nsIGlobalObject_Release(nsglo);
if(NS_FAILED(nsres)) {
ERR("nsIXMLHttpRequest_Init failed: %08x\n", nsres);
nsIXMLHttpRequest_Release(nsxhr);
return NULL;
}
return nsxhr;
}
......@@ -4146,6 +4146,16 @@ interface nsIGlobalObject : nsISupports
[
object,
uuid(3eedba38-8d22-41e1-817a-0e43e165b664),
local
]
interface nsIScriptObjectPrincipal : nsISupports
{
nsIPrincipal* /* thiscall */ GetPrincipal();
}
[
object,
uuid(6f54214c-7175-498d-9d2d-0429e38c2869),
local
]
......@@ -4181,40 +4191,4 @@ interface nsIXMLHttpRequest : nsISupports
nsresult GetMozSystem(bool *aMozSystem);
}
[
object,
uuid(b7ae2310-576e-11e5-a837-0800200c9a66),
local
]
interface nsIScriptSecurityManager : nsISupports {
nsresult CanCreateWrapper(JSContext *aJSContext, const nsIID *aIID, nsISupports *aObj, nsIClassInfo *aClassInfo);
nsresult CanCreateInstance(JSContext *aJSContext, const nsCID *aCID);
nsresult CanGetService(JSContext *aJSContext, const nsCID *aCID);
nsresult CheckLoadURIFromScript(JSContext *cx, nsIURI *uri);
nsresult CheckLoadURIWithPrincipal(nsIPrincipal *aPrincipal, nsIURI *uri, uint32_t flags);
nsresult CheckLoadURIStrWithPrincipal(nsIPrincipal *aPrincipal, const nsACString *uri, uint32_t flags);
bool ScriptAllowed(JSObject *aGlobal);
nsresult GetSystemPrincipal(nsIPrincipal **_retval);
nsresult GetSimpleCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval);
nsresult GetAppCodebasePrincipal(nsIURI *uri, uint32_t appId, bool inMozBrowser, nsIPrincipal **_retval);
nsresult GetLoadContextCodebasePrincipal(nsIURI *uri, nsILoadContext *loadContext, nsIPrincipal **_retval);
nsresult GetDocShellCodebasePrincipal(nsIURI *uri, nsIDocShell *docShell, nsIPrincipal **_retval);
nsresult GetNoAppCodebasePrincipal(nsIURI *uri, nsIPrincipal **_retval);
nsresult GetCodebasePrincipal(nsIURI *uri, nsIPrincipal **_retval);
nsresult CreateCodebasePrincipal(nsIURI *uri, int /*JS::HandleValue*/ originAttributes, JSContext* cx, nsIPrincipal **_retval);
nsresult CreateCodebasePrincipalFromOrigin(const nsACString *origin, nsIPrincipal **_retval);
nsresult CreateNullPrincipal(int /*JS::HandleValue*/ originAttributes, JSContext *cx, nsIPrincipal **_retval);
nsresult CreateExpandedPrincipal(nsIPrincipal **aPrincipalArray, uint32_t aLength, nsIPrincipal **_retval);
nsresult CheckSameOriginURI(nsIURI *aSourceURI, nsIURI *aTargetURI, bool reportError);
nsresult GetChannelResultPrincipal(nsIChannel *aChannel, nsIPrincipal **_retval);
nsresult GetChannelURIPrincipal(nsIChannel *aChannel, nsIPrincipal **_retval);
nsresult IsSystemPrincipal(nsIPrincipal *aPrincipal, bool *_retval);
nsresult GetJarPrefix(uint32_t appId, bool inMozBrowser, nsACString *_retval);
nsresult ActivateDomainPolicy(nsIDomainPolicy **_retval);
nsresult GetDomainPolicyActive(bool *aDomainPolicyActive);
nsresult ActivateDomainPolicyInternal(nsIDomainPolicy **_retval);
void CloneDomainPolicy(int /*mozilla::dom::DomainPolicyClone*/ *aClone);
nsresult PolicyAllowsScript(nsIURI *aDomain, bool *_retval);
}
cpp_quote("DEFINE_GUID(IID_nsCycleCollectionISupports, 0xc61eac14,0x5f7a,0x4481,0x96,0x5e,0x7e,0xaa,0x6e,0xff,0xa8,0x5f);")
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