| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
| 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
| 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
| 6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 m_loader->start(m_xhr->getExecutionContext(), std::move(handle)); | 198 m_loader->start(m_xhr->getExecutionContext(), std::move(handle)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 Member<XMLHttpRequest> m_xhr; | 201 Member<XMLHttpRequest> m_xhr; |
| 202 std::unique_ptr<FileReaderLoader> m_loader; | 202 std::unique_ptr<FileReaderLoader> m_loader; |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 XMLHttpRequest* XMLHttpRequest::create(ScriptState* scriptState) { | 205 XMLHttpRequest* XMLHttpRequest::create(ScriptState* scriptState) { |
| 206 ExecutionContext* context = scriptState->getExecutionContext(); | 206 ExecutionContext* context = scriptState->getExecutionContext(); |
| 207 DOMWrapperWorld& world = scriptState->world(); | 207 DOMWrapperWorld& world = scriptState->world(); |
| 208 RefPtr<SecurityOrigin> isolatedWorldSecurityOrigin = | 208 if (!world.isIsolatedWorld()) |
| 209 world.isIsolatedWorld() ? world.isolatedWorldSecurityOrigin() : nullptr; | 209 return create(context); |
| 210 |
| 210 XMLHttpRequest* xmlHttpRequest = | 211 XMLHttpRequest* xmlHttpRequest = |
| 211 new XMLHttpRequest(context, isolatedWorldSecurityOrigin); | 212 new XMLHttpRequest(context, true, world.isolatedWorldSecurityOrigin()); |
| 212 xmlHttpRequest->suspendIfNeeded(); | 213 xmlHttpRequest->suspendIfNeeded(); |
| 213 | 214 |
| 214 return xmlHttpRequest; | 215 return xmlHttpRequest; |
| 215 } | 216 } |
| 216 | 217 |
| 217 XMLHttpRequest* XMLHttpRequest::create(ExecutionContext* context) { | 218 XMLHttpRequest* XMLHttpRequest::create(ExecutionContext* context) { |
| 218 XMLHttpRequest* xmlHttpRequest = new XMLHttpRequest(context, nullptr); | 219 XMLHttpRequest* xmlHttpRequest = new XMLHttpRequest(context, false, nullptr); |
| 219 xmlHttpRequest->suspendIfNeeded(); | 220 xmlHttpRequest->suspendIfNeeded(); |
| 220 | 221 |
| 221 return xmlHttpRequest; | 222 return xmlHttpRequest; |
| 222 } | 223 } |
| 223 | 224 |
| 224 XMLHttpRequest::XMLHttpRequest( | 225 XMLHttpRequest::XMLHttpRequest( |
| 225 ExecutionContext* context, | 226 ExecutionContext* context, |
| 227 bool isIsolatedWorld, |
| 226 PassRefPtr<SecurityOrigin> isolatedWorldSecurityOrigin) | 228 PassRefPtr<SecurityOrigin> isolatedWorldSecurityOrigin) |
| 227 : SuspendableObject(context), | 229 : SuspendableObject(context), |
| 228 m_timeoutMilliseconds(0), | 230 m_timeoutMilliseconds(0), |
| 229 m_responseBlob(this, nullptr), | 231 m_responseBlob(this, nullptr), |
| 230 m_state(kUnsent), | 232 m_state(kUnsent), |
| 231 m_responseDocument(this, nullptr), | 233 m_responseDocument(this, nullptr), |
| 232 m_lengthDownloadedToFile(0), | 234 m_lengthDownloadedToFile(0), |
| 233 m_responseArrayBuffer(this, nullptr), | 235 m_responseArrayBuffer(this, nullptr), |
| 234 m_receivedLength(0), | 236 m_receivedLength(0), |
| 235 m_exceptionCode(0), | 237 m_exceptionCode(0), |
| 236 m_progressEventThrottle( | 238 m_progressEventThrottle( |
| 237 XMLHttpRequestProgressEventThrottle::create(this)), | 239 XMLHttpRequestProgressEventThrottle::create(this)), |
| 238 m_responseTypeCode(ResponseTypeDefault), | 240 m_responseTypeCode(ResponseTypeDefault), |
| 241 m_isIsolatedWorld(isIsolatedWorld), |
| 239 m_isolatedWorldSecurityOrigin(isolatedWorldSecurityOrigin), | 242 m_isolatedWorldSecurityOrigin(isolatedWorldSecurityOrigin), |
| 240 m_eventDispatchRecursionLevel(0), | 243 m_eventDispatchRecursionLevel(0), |
| 241 m_async(true), | 244 m_async(true), |
| 242 m_includeCredentials(false), | 245 m_includeCredentials(false), |
| 243 m_parsedResponse(false), | 246 m_parsedResponse(false), |
| 244 m_error(false), | 247 m_error(false), |
| 245 m_uploadEventsAllowed(true), | 248 m_uploadEventsAllowed(true), |
| 246 m_uploadComplete(false), | 249 m_uploadComplete(false), |
| 247 m_sameOriginRequest(true), | 250 m_sameOriginRequest(true), |
| 248 m_downloadingToFile(false), | 251 m_downloadingToFile(false), |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 m_uploadEventsAllowed = | 983 m_uploadEventsAllowed = |
| 981 m_sameOriginRequest || uploadEvents || | 984 m_sameOriginRequest || uploadEvents || |
| 982 !FetchUtils::isSimpleRequest(m_method, m_requestHeaders); | 985 !FetchUtils::isSimpleRequest(m_method, m_requestHeaders); |
| 983 | 986 |
| 984 ResourceRequest request(m_url); | 987 ResourceRequest request(m_url); |
| 985 request.setHTTPMethod(m_method); | 988 request.setHTTPMethod(m_method); |
| 986 request.setRequestContext(WebURLRequest::RequestContextXMLHttpRequest); | 989 request.setRequestContext(WebURLRequest::RequestContextXMLHttpRequest); |
| 987 request.setFetchCredentialsMode( | 990 request.setFetchCredentialsMode( |
| 988 includeCredentials ? WebURLRequest::FetchCredentialsModeInclude | 991 includeCredentials ? WebURLRequest::FetchCredentialsModeInclude |
| 989 : WebURLRequest::FetchCredentialsModeSameOrigin); | 992 : WebURLRequest::FetchCredentialsModeSameOrigin); |
| 990 request.setSkipServiceWorker(m_isolatedWorldSecurityOrigin.get() | 993 request.setSkipServiceWorker(m_isIsolatedWorld |
| 991 ? WebURLRequest::SkipServiceWorker::All | 994 ? WebURLRequest::SkipServiceWorker::All |
| 992 : WebURLRequest::SkipServiceWorker::None); | 995 : WebURLRequest::SkipServiceWorker::None); |
| 993 request.setExternalRequestStateFromRequestorAddressSpace( | 996 request.setExternalRequestStateFromRequestorAddressSpace( |
| 994 executionContext.securityContext().addressSpace()); | 997 executionContext.securityContext().addressSpace()); |
| 995 | 998 |
| 996 InspectorInstrumentation::willLoadXHR( | 999 InspectorInstrumentation::willLoadXHR( |
| 997 &executionContext, this, this, m_method, m_url, m_async, | 1000 &executionContext, this, this, m_method, m_url, m_async, |
| 998 httpBody ? httpBody->deepCopy() : nullptr, m_requestHeaders, | 1001 httpBody ? httpBody->deepCopy() : nullptr, m_requestHeaders, |
| 999 includeCredentials); | 1002 includeCredentials); |
| 1000 | 1003 |
| (...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 visitor->traceWrappers(m_responseDocument); | 1859 visitor->traceWrappers(m_responseDocument); |
| 1857 visitor->traceWrappers(m_responseArrayBuffer); | 1860 visitor->traceWrappers(m_responseArrayBuffer); |
| 1858 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1861 XMLHttpRequestEventTarget::traceWrappers(visitor); |
| 1859 } | 1862 } |
| 1860 | 1863 |
| 1861 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1864 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
| 1862 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1865 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
| 1863 } | 1866 } |
| 1864 | 1867 |
| 1865 } // namespace blink | 1868 } // namespace blink |
| OLD | NEW |