Commit deb884a6 authored by Zhenbo Li's avatar Zhenbo Li Committed by Alexandre Julliard

mshtml: Add IHTMLXMLHttpRequestFactory::create() method implementation.

parent bfafef4e
...@@ -256,8 +256,9 @@ static void release_inner_window(HTMLInnerWindow *This) ...@@ -256,8 +256,9 @@ static void release_inner_window(HTMLInnerWindow *This)
IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface); IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
} }
if(This->xml_factory) { if(This->xhr_factory) {
IHTMLXMLHttpRequestFactory_Release(&This->xml_factory->IHTMLXMLHttpRequestFactory_iface); This->xhr_factory->window = NULL;
IHTMLXMLHttpRequestFactory_Release(&This->xhr_factory->IHTMLXMLHttpRequestFactory_iface);
} }
if(This->screen) if(This->screen)
...@@ -1973,16 +1974,17 @@ static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIAN ...@@ -1973,16 +1974,17 @@ static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIAN
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(!window->xml_factory) { if(!window->xhr_factory) {
HRESULT hres; HRESULT hres;
hres = HTMLXMLHttpRequestFactory_Create(window, &window->xml_factory); hres = HTMLXMLHttpRequestFactory_Create(window, &window->xhr_factory);
if(FAILED(hres)) if(FAILED(hres)) {
return hres; return hres;
} }
}
V_VT(p) = VT_DISPATCH; V_VT(p) = VT_DISPATCH;
V_DISPATCH(p) = (IDispatch*)&window->xml_factory->IHTMLXMLHttpRequestFactory_iface; V_DISPATCH(p) = (IDispatch*)&window->xhr_factory->IHTMLXMLHttpRequestFactory_iface;
IDispatch_AddRef(V_DISPATCH(p)); IDispatch_AddRef(V_DISPATCH(p));
return S_OK; return S_OK;
......
...@@ -359,6 +359,8 @@ typedef struct { ...@@ -359,6 +359,8 @@ typedef struct {
IHTMLXMLHttpRequestFactory IHTMLXMLHttpRequestFactory_iface; IHTMLXMLHttpRequestFactory IHTMLXMLHttpRequestFactory_iface;
LONG ref; LONG ref;
HTMLInnerWindow *window;
} HTMLXMLHttpRequestFactory; } HTMLXMLHttpRequestFactory;
struct HTMLLocation { struct HTMLLocation {
...@@ -447,7 +449,7 @@ struct HTMLInnerWindow { ...@@ -447,7 +449,7 @@ struct HTMLInnerWindow {
HTMLImageElementFactory *image_factory; HTMLImageElementFactory *image_factory;
HTMLOptionElementFactory *option_factory; HTMLOptionElementFactory *option_factory;
HTMLXMLHttpRequestFactory *xml_factory; HTMLXMLHttpRequestFactory *xhr_factory;
IHTMLScreen *screen; IHTMLScreen *screen;
OmHistory *history; OmHistory *history;
IHTMLStorage *session_storage; IHTMLStorage *session_storage;
...@@ -876,6 +878,7 @@ HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*) DECLSPEC_HIDDEN; ...@@ -876,6 +878,7 @@ HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*) DECLSPEC_HIDDEN;
void get_editor_controller(NSContainer*) DECLSPEC_HIDDEN; void get_editor_controller(NSContainer*) DECLSPEC_HIDDEN;
nsresult get_nsinterface(nsISupports*,REFIID,void**) DECLSPEC_HIDDEN; nsresult get_nsinterface(nsISupports*,REFIID,void**) DECLSPEC_HIDDEN;
nsIWritableVariant *create_nsvariant(void) DECLSPEC_HIDDEN; nsIWritableVariant *create_nsvariant(void) DECLSPEC_HIDDEN;
nsIXMLHttpRequest *create_nsxhr(nsIDOMWindow *nswindow) DECLSPEC_HIDDEN;
nsresult create_nsfile(const PRUnichar*,nsIFile**) DECLSPEC_HIDDEN; nsresult create_nsfile(const PRUnichar*,nsIFile**) DECLSPEC_HIDDEN;
char *get_nscategory_entry(const char*,const char*) DECLSPEC_HIDDEN; char *get_nscategory_entry(const char*,const char*) DECLSPEC_HIDDEN;
......
...@@ -48,6 +48,8 @@ WINE_DECLARE_DEBUG_CHANNEL(gecko); ...@@ -48,6 +48,8 @@ WINE_DECLARE_DEBUG_CHANNEL(gecko);
#define NS_PREFERENCES_CONTRACTID "@mozilla.org/preferences;1" #define NS_PREFERENCES_CONTRACTID "@mozilla.org/preferences;1"
#define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1" #define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1"
#define NS_CATEGORYMANAGER_CONTRACTID "@mozilla.org/categorymanager;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 #define PR_UINT32_MAX 0xffffffff
...@@ -2160,3 +2162,51 @@ void NSContainer_Release(NSContainer *This) ...@@ -2160,3 +2162,51 @@ void NSContainer_Release(NSContainer *This)
nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface); nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
} }
nsIXMLHttpRequest *create_nsxhr(nsIDOMWindow *nswindow)
{
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_QueryInterface(nswindow, &IID_nsIGlobalObject, (void **)&nsglo);
assert(nsres == NS_OK);
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;
}
nsres = nsIXMLHttpRequest_Init(nsxhr, nspri, NULL, nsglo, NULL);
nsISupports_Release(nspri);
nsIGlobalObject_Release(nsglo);
if(NS_FAILED(nsres)) {
ERR("nsIXMLHttpRequest_Init failed: %08x\n", nsres);
nsIXMLHttpRequest_Release(nsxhr);
return NULL;
}
return nsxhr;
}
...@@ -196,6 +196,14 @@ typedef nsISupports nsIDOMPkcs11; ...@@ -196,6 +196,14 @@ typedef nsISupports nsIDOMPkcs11;
typedef nsISupports nsIDocShellTreeOwner; typedef nsISupports nsIDocShellTreeOwner;
typedef nsISupports nsIArray; typedef nsISupports nsIArray;
typedef nsISupports nsILoadInfo; typedef nsISupports nsILoadInfo;
typedef nsISupports nsIContentSecurityPolicy;
typedef nsISupports nsIXMLHttpRequestUpload;
typedef nsISupports nsIClassInfo;
typedef nsISupports nsILoadContext;
typedef nsISupports nsIDomainPolicy;
typedef nsISupports nsIScriptContext;
typedef nsISupports nsIObjectInputStream;
typedef nsISupports nsIObjectOutputStream;
typedef void *JSContext; typedef void *JSContext;
typedef void *JSObject; typedef void *JSObject;
...@@ -4015,4 +4023,81 @@ interface nsIPluginInstance : nsISupports ...@@ -4015,4 +4023,81 @@ interface nsIPluginInstance : nsISupports
nsresult GetDOMElement(nsIDOMElement **aDOMElement); nsresult GetDOMElement(nsIDOMElement **aDOMElement);
} }
[
object,
uuid(e2538ded-13ef-4f4d-946b-65d333b4f03c),
local
]
interface nsIGlobalObject : nsISupports
{
}
[
object,
uuid(2e91e088-e9fa-4ba4-9887-2a0b7cf27a3e),
local
]
interface nsIXMLHttpRequest : nsISupports
{
nsresult GetChannel(nsIChannel **aChannel);
nsresult GetResponseXML(nsIDOMDocument **aResponseXML);
nsresult GetResponseText(nsAString *aResponseText);
nsresult GetResponseType(nsAString *aResponseType);
nsresult SetResponseType(const nsAString *aResponseType);
nsresult GetResponse(JSContext*cx, int /*JS::MutableHandleValue*/ aResponse);
nsresult GetStatus(uint32_t *aStatus);
nsresult GetStatusText(nsACString *aStatusText);
nsresult SlowAbort();
nsresult GetAllResponseHeaders(nsACString *_retval);
nsresult GetResponseHeader(const nsACString *header, nsACString *_retval);
nsresult Open(const nsACString *method, const nsACString *url, bool async, const nsAString *user, const nsAString *password, uint8_t _argc);
nsresult Send(nsIVariant *body);
nsresult SendAsBinary(const nsAString *body);
nsresult SetRequestHeader(const nsACString *header, const nsACString *value);
nsresult GetTimeout(uint32_t *aTimeout);
nsresult SetTimeout(uint32_t aTimeout);
nsresult GetReadyState(uint16_t *aReadyState);
nsresult SlowOverrideMimeType(const nsAString *mimetype);
nsresult GetMozBackgroundRequest(bool *aMozBackgroundRequest);
nsresult SetMozBackgroundRequest(bool aMozBackgroundRequest);
nsresult GetWithCredentials(bool *aWithCredentials);
nsresult SetWithCredentials(bool aWithCredentials);
nsresult Init(nsIPrincipal *principal, nsIScriptContext *scriptContext, nsIGlobalObject *globalObject, nsIURI *baseURI);
nsresult GetUpload(nsIXMLHttpRequestUpload **aUpload);
nsresult GetOnreadystatechange(JSContext*cx, int /*JS::MutableHandleValue*/ aOnreadystatechange);
nsresult SetOnreadystatechange(JSContext*cx, int /*JS::HandleValue*/ aOnreadystatechange);
nsresult GetMozAnon(bool *aMozAnon);
nsresult GetMozSystem(bool *aMozSystem);
}
[
object,
uuid(f649959d-dae3-4027-83fd-5b7f8c8a8815),
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);
nsresult 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 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 PolicyAllowsScript(nsIURI *aDomain, bool *_retval);
}
cpp_quote("DEFINE_GUID(IID_nsCycleCollectionISupports, 0xc61eac14,0x5f7a,0x4481,0x96,0x5e,0x7e,0xaa,0x6e,0xff,0xa8,0x5f);") cpp_quote("DEFINE_GUID(IID_nsCycleCollectionISupports, 0xc61eac14,0x5f7a,0x4481,0x96,0x5e,0x7e,0xaa,0x6e,0xff,0xa8,0x5f);")
...@@ -38,6 +38,7 @@ typedef struct { ...@@ -38,6 +38,7 @@ typedef struct {
EventTarget event_target; EventTarget event_target;
IHTMLXMLHttpRequest IHTMLXMLHttpRequest_iface; IHTMLXMLHttpRequest IHTMLXMLHttpRequest_iface;
LONG ref; LONG ref;
nsIXMLHttpRequest *nsxhr;
} HTMLXMLHttpRequest; } HTMLXMLHttpRequest;
static inline HTMLXMLHttpRequest *impl_from_IHTMLXMLHttpRequest(IHTMLXMLHttpRequest *iface) static inline HTMLXMLHttpRequest *impl_from_IHTMLXMLHttpRequest(IHTMLXMLHttpRequest *iface)
...@@ -88,6 +89,7 @@ static ULONG WINAPI HTMLXMLHttpRequest_Release(IHTMLXMLHttpRequest *iface) ...@@ -88,6 +89,7 @@ static ULONG WINAPI HTMLXMLHttpRequest_Release(IHTMLXMLHttpRequest *iface)
if(!ref) { if(!ref) {
release_dispex(&This->event_target.dispex); release_dispex(&This->event_target.dispex);
nsIXMLHttpRequest_Release(This->nsxhr);
heap_free(This); heap_free(This);
} }
...@@ -378,12 +380,20 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor ...@@ -378,12 +380,20 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor
{ {
HTMLXMLHttpRequestFactory *This = impl_from_IHTMLXMLHttpRequestFactory(iface); HTMLXMLHttpRequestFactory *This = impl_from_IHTMLXMLHttpRequestFactory(iface);
HTMLXMLHttpRequest *ret; HTMLXMLHttpRequest *ret;
nsIXMLHttpRequest *nsxhr;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsxhr = create_nsxhr(This->window->base.outer_window->nswindow);
if(!nsxhr)
return E_FAIL;
ret = heap_alloc_zero(sizeof(*ret)); ret = heap_alloc_zero(sizeof(*ret));
if(!ret) if(!ret) {
nsIXMLHttpRequest_Release(nsxhr);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
ret->nsxhr = nsxhr;
ret->IHTMLXMLHttpRequest_iface.lpVtbl = &HTMLXMLHttpRequestVtbl; ret->IHTMLXMLHttpRequest_iface.lpVtbl = &HTMLXMLHttpRequestVtbl;
init_dispex(&ret->event_target.dispex, (IUnknown*)&ret->IHTMLXMLHttpRequest_iface, init_dispex(&ret->event_target.dispex, (IUnknown*)&ret->IHTMLXMLHttpRequest_iface,
...@@ -426,6 +436,7 @@ HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow* window, HTMLXMLHttpReq ...@@ -426,6 +436,7 @@ HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow* window, HTMLXMLHttpReq
ret->IHTMLXMLHttpRequestFactory_iface.lpVtbl = &HTMLXMLHttpRequestFactoryVtbl; ret->IHTMLXMLHttpRequestFactory_iface.lpVtbl = &HTMLXMLHttpRequestFactoryVtbl;
ret->ref = 1; ret->ref = 1;
ret->window = window;
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLXMLHttpRequestFactory_iface, init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLXMLHttpRequestFactory_iface,
&HTMLXMLHttpRequestFactory_dispex); &HTMLXMLHttpRequestFactory_dispex);
......
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