| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, secu
rityOrigin); | 65 RefPtr<XMLHttpRequest> xmlHttpRequest = XMLHttpRequest::create(context, secu
rityOrigin); |
| 66 | 66 |
| 67 v8::Handle<v8::Object> wrapper = info.Holder(); | 67 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 68 V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.re
lease(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep
endent); | 68 V8DOMWrapper::associateObjectWithWrapper<V8XMLHttpRequest>(xmlHttpRequest.re
lease(), &wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep
endent); |
| 69 info.GetReturnValue().Set(wrapper); | 69 info.GetReturnValue().Set(wrapper); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallb
ackInfo<v8::Value>& info) | 72 void V8XMLHttpRequest::responseTextAttributeGetterCustom(const v8::PropertyCallb
ackInfo<v8::Value>& info) |
| 73 { | 73 { |
| 74 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); | 74 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); |
| 75 ExceptionState es(info.GetIsolate()); | 75 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 76 ScriptValue text = xmlHttpRequest->responseText(es); | 76 ScriptValue text = xmlHttpRequest->responseText(es); |
| 77 if (es.throwIfNeeded()) | 77 if (es.throwIfNeeded()) |
| 78 return; | 78 return; |
| 79 if (text.hasNoValue()) { | 79 if (text.hasNoValue()) { |
| 80 v8SetReturnValueString(info, emptyString(), info.GetIsolate()); | 80 v8SetReturnValueString(info, emptyString(), info.GetIsolate()); |
| 81 return; | 81 return; |
| 82 } | 82 } |
| 83 v8SetReturnValue(info, text.v8Value()); | 83 v8SetReturnValue(info, text.v8Value()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackI
nfo<v8::Value>& info) | 86 void V8XMLHttpRequest::responseAttributeGetterCustom(const v8::PropertyCallbackI
nfo<v8::Value>& info) |
| 87 { | 87 { |
| 88 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); | 88 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); |
| 89 | 89 |
| 90 switch (xmlHttpRequest->responseTypeCode()) { | 90 switch (xmlHttpRequest->responseTypeCode()) { |
| 91 case XMLHttpRequest::ResponseTypeDefault: | 91 case XMLHttpRequest::ResponseTypeDefault: |
| 92 case XMLHttpRequest::ResponseTypeText: | 92 case XMLHttpRequest::ResponseTypeText: |
| 93 responseTextAttributeGetterCustom(info); | 93 responseTextAttributeGetterCustom(info); |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 case XMLHttpRequest::ResponseTypeJSON: | 96 case XMLHttpRequest::ResponseTypeJSON: |
| 97 { | 97 { |
| 98 v8::Isolate* isolate = info.GetIsolate(); | 98 v8::Isolate* isolate = info.GetIsolate(); |
| 99 | 99 |
| 100 ExceptionState es(isolate); | 100 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 101 ScriptString jsonSource = xmlHttpRequest->responseJSONSource(); | 101 ScriptString jsonSource = xmlHttpRequest->responseJSONSource(); |
| 102 if (es.throwIfNeeded()) | 102 if (es.throwIfNeeded()) |
| 103 return; | 103 return; |
| 104 | 104 |
| 105 if (jsonSource.hasNoValue() || !jsonSource.v8Value()->IsString()) { | 105 if (jsonSource.hasNoValue() || !jsonSource.v8Value()->IsString()) { |
| 106 v8SetReturnValue(info, v8NullWithCheck(isolate)); | 106 v8SetReturnValue(info, v8NullWithCheck(isolate)); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Catch syntax error. | 110 // Catch syntax error. |
| 111 v8::TryCatch exceptionCatcher; | 111 v8::TryCatch exceptionCatcher; |
| 112 | 112 |
| 113 v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value().As
<v8::String>()); | 113 v8::Handle<v8::Value> json = v8::JSON::Parse(jsonSource.v8Value().As
<v8::String>()); |
| 114 | 114 |
| 115 if (exceptionCatcher.HasCaught() || json.IsEmpty()) | 115 if (exceptionCatcher.HasCaught() || json.IsEmpty()) |
| 116 v8SetReturnValue(info, v8NullWithCheck(isolate)); | 116 v8SetReturnValue(info, v8NullWithCheck(isolate)); |
| 117 else | 117 else |
| 118 v8SetReturnValue(info, json); | 118 v8SetReturnValue(info, json); |
| 119 | 119 |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 case XMLHttpRequest::ResponseTypeDocument: | 123 case XMLHttpRequest::ResponseTypeDocument: |
| 124 { | 124 { |
| 125 ExceptionState es(info.GetIsolate()); | 125 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 126 Document* document = xmlHttpRequest->responseXML(es); | 126 Document* document = xmlHttpRequest->responseXML(es); |
| 127 if (es.throwIfNeeded()) | 127 if (es.throwIfNeeded()) |
| 128 return; | 128 return; |
| 129 v8SetReturnValueFast(info, document, xmlHttpRequest); | 129 v8SetReturnValueFast(info, document, xmlHttpRequest); |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 | 132 |
| 133 case XMLHttpRequest::ResponseTypeBlob: | 133 case XMLHttpRequest::ResponseTypeBlob: |
| 134 { | 134 { |
| 135 Blob* blob = xmlHttpRequest->responseBlob(); | 135 Blob* blob = xmlHttpRequest->responseBlob(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 | 171 |
| 172 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); | 172 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); |
| 173 | 173 |
| 174 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]); | 174 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, method, info[0]); |
| 175 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1])
; | 175 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, urlstring, info[1])
; |
| 176 | 176 |
| 177 ExecutionContext* context = getExecutionContext(); | 177 ExecutionContext* context = getExecutionContext(); |
| 178 KURL url = context->completeURL(urlstring); | 178 KURL url = context->completeURL(urlstring); |
| 179 | 179 |
| 180 ExceptionState es(info.GetIsolate()); | 180 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 181 | 181 |
| 182 if (info.Length() >= 3) { | 182 if (info.Length() >= 3) { |
| 183 bool async = info[2]->BooleanValue(); | 183 bool async = info[2]->BooleanValue(); |
| 184 | 184 |
| 185 if (info.Length() >= 4 && !info[3]->IsUndefined()) { | 185 if (info.Length() >= 4 && !info[3]->IsUndefined()) { |
| 186 String user = toWebCoreStringWithNullCheck(info[3]); | 186 String user = toWebCoreStringWithNullCheck(info[3]); |
| 187 | 187 |
| 188 if (info.Length() >= 5 && !info[4]->IsUndefined()) { | 188 if (info.Length() >= 5 && !info[4]->IsUndefined()) { |
| 189 String passwd = toWebCoreStringWithNullCheck(info[4]); | 189 String passwd = toWebCoreStringWithNullCheck(info[4]); |
| 190 xmlHttpRequest->open(method, url, async, user, passwd, es); | 190 xmlHttpRequest->open(method, url, async, user, passwd, es); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 206 // FIXME: add other document types. | 206 // FIXME: add other document types. |
| 207 return V8Document::HasInstance(value, isolate, currentWorldType) || V8HTMLDo
cument::HasInstance(value, isolate, currentWorldType); | 207 return V8Document::HasInstance(value, isolate, currentWorldType) || V8HTMLDo
cument::HasInstance(value, isolate, currentWorldType); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value
>& info) | 210 void V8XMLHttpRequest::sendMethodCustom(const v8::FunctionCallbackInfo<v8::Value
>& info) |
| 211 { | 211 { |
| 212 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); | 212 XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(info.Holder()); |
| 213 | 213 |
| 214 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo
ntext(), xmlHttpRequest->url()); | 214 InspectorInstrumentation::willSendXMLHttpRequest(xmlHttpRequest->executionCo
ntext(), xmlHttpRequest->url()); |
| 215 | 215 |
| 216 ExceptionState es(info.GetIsolate()); | 216 ExceptionState es(info.Holder(), info.GetIsolate()); |
| 217 if (info.Length() < 1) | 217 if (info.Length() < 1) |
| 218 xmlHttpRequest->send(es); | 218 xmlHttpRequest->send(es); |
| 219 else { | 219 else { |
| 220 v8::Handle<v8::Value> arg = info[0]; | 220 v8::Handle<v8::Value> arg = info[0]; |
| 221 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); | 221 WrapperWorldType currentWorldType = worldType(info.GetIsolate()); |
| 222 if (isUndefinedOrNull(arg)) { | 222 if (isUndefinedOrNull(arg)) { |
| 223 xmlHttpRequest->send(es); | 223 xmlHttpRequest->send(es); |
| 224 } else if (isDocumentType(arg, info.GetIsolate(), currentWorldType)) { | 224 } else if (isDocumentType(arg, info.GetIsolate(), currentWorldType)) { |
| 225 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); | 225 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(arg); |
| 226 Document* document = V8Document::toNative(object); | 226 Document* document = V8Document::toNative(object); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 248 xmlHttpRequest->send(arrayBufferView, es); | 248 xmlHttpRequest->send(arrayBufferView, es); |
| 249 } else { | 249 } else { |
| 250 xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), es); | 250 xmlHttpRequest->send(toWebCoreStringWithNullCheck(arg), es); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 es.throwIfNeeded(); | 254 es.throwIfNeeded(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace WebCore | 257 } // namespace WebCore |
| OLD | NEW |