OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/fetch/RequestInit.h" | 5 #include "modules/fetch/RequestInit.h" |
6 | 6 |
7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
9 #include "bindings/core/v8/V8ArrayBufferView.h" | 9 #include "bindings/core/v8/V8ArrayBufferView.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } else { | 94 } else { |
95 exceptionState.throwTypeError("Invalid referrer policy"); | 95 exceptionState.throwTypeError("Invalid referrer policy"); |
96 return; | 96 return; |
97 } | 97 } |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 v8::Isolate* isolate = toIsolate(context); | 101 v8::Isolate* isolate = toIsolate(context); |
102 if (isCredentialSet) { | 102 if (isCredentialSet) { |
103 if (V8PasswordCredential::hasInstance(v8Credential, isolate)) { | 103 if (V8PasswordCredential::hasInstance(v8Credential, isolate)) { |
104 // TODO(mkwst): According to the spec, we'd serialize this once we touch t
he network. We're | 104 // TODO(mkwst): According to the spec, we'd serialize this once we touch |
105 // serializing it here, ahead of time, because lifetime issues around Reso
urceRequest make | 105 // the network. We're serializing it here, ahead of time, because lifetime |
106 // it pretty difficult to pass a PasswordCredential around at the platform
level, and the | 106 // issues around ResourceRequest make it pretty difficult to pass a |
107 // hop between the browser and renderer processes to deal with service wor
kers is equally | 107 // PasswordCredential around at the platform level, and the hop between |
108 // painful. There should be no developer-visible difference in behavior wi
th this option, | 108 // the browser and renderer processes to deal with service workers is |
109 // except that the `Content-Type` header will be set early. That seems rea
sonable. | 109 // equally painful. There should be no developer-visible difference in |
| 110 // behavior with this option, except that the `Content-Type` header will |
| 111 // be set early. That seems reasonable. |
110 PasswordCredential* credential = | 112 PasswordCredential* credential = |
111 V8PasswordCredential::toImpl(v8Credential.As<v8::Object>()); | 113 V8PasswordCredential::toImpl(v8Credential.As<v8::Object>()); |
112 attachedCredential = credential->encodeFormData(contentType); | 114 attachedCredential = credential->encodeFormData(contentType); |
113 credentials = "password"; | 115 credentials = "password"; |
114 } else if (v8Credential->IsString()) { | 116 } else if (v8Credential->IsString()) { |
115 credentials = toUSVString(isolate, v8Credential, exceptionState); | 117 credentials = toUSVString(isolate, v8Credential, exceptionState); |
116 } | 118 } |
117 } | 119 } |
118 | 120 |
119 if (attachedCredential.get() || !isBodySet || v8Body->IsUndefined() || | 121 if (attachedCredential.get() || !isBodySet || v8Body->IsUndefined() || |
(...skipping 26 matching lines...) Expand all Loading... |
146 AtomicString("application/x-www-form-urlencoded;charset=UTF-8"); | 148 AtomicString("application/x-www-form-urlencoded;charset=UTF-8"); |
147 body = new FormDataBytesConsumer(context, formData.release()); | 149 body = new FormDataBytesConsumer(context, formData.release()); |
148 } else if (v8Body->IsString()) { | 150 } else if (v8Body->IsString()) { |
149 contentType = "text/plain;charset=UTF-8"; | 151 contentType = "text/plain;charset=UTF-8"; |
150 body = | 152 body = |
151 new FormDataBytesConsumer(toUSVString(isolate, v8Body, exceptionState)); | 153 new FormDataBytesConsumer(toUSVString(isolate, v8Body, exceptionState)); |
152 } | 154 } |
153 } | 155 } |
154 | 156 |
155 } // namespace blink | 157 } // namespace blink |
OLD | NEW |