Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/RequestInit.cpp

Issue 1391583002: Introduce "navigate" mode in Requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "modules/fetch/RequestInit.h" 6 #include "modules/fetch/RequestInit.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/V8ArrayBuffer.h" 9 #include "bindings/core/v8/V8ArrayBuffer.h"
10 #include "bindings/core/v8/V8ArrayBufferView.h" 10 #include "bindings/core/v8/V8ArrayBufferView.h"
11 #include "bindings/core/v8/V8Binding.h" 11 #include "bindings/core/v8/V8Binding.h"
12 #include "bindings/core/v8/V8Blob.h" 12 #include "bindings/core/v8/V8Blob.h"
13 #include "bindings/core/v8/V8FormData.h" 13 #include "bindings/core/v8/V8FormData.h"
14 #include "core/fileapi/Blob.h" 14 #include "core/fileapi/Blob.h"
15 #include "core/html/FormData.h" 15 #include "core/html/FormData.h"
16 #include "modules/fetch/FetchBlobDataConsumerHandle.h" 16 #include "modules/fetch/FetchBlobDataConsumerHandle.h"
17 #include "modules/fetch/FetchFormDataConsumerHandle.h" 17 #include "modules/fetch/FetchFormDataConsumerHandle.h"
18 #include "modules/fetch/Headers.h" 18 #include "modules/fetch/Headers.h"
19 #include "platform/blob/BlobData.h" 19 #include "platform/blob/BlobData.h"
20 #include "platform/network/EncodedFormData.h" 20 #include "platform/network/EncodedFormData.h"
21 #include "platform/weborigin/ReferrerPolicy.h" 21 #include "platform/weborigin/ReferrerPolicy.h"
22 22
23 namespace blink { 23 namespace blink {
24 24
25 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E xceptionState& exceptionState) 25 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E xceptionState& exceptionState)
26 : opaque(false), isReferrerSet(false) 26 : opaque(false), areAnyMembersSet(false)
27 { 27 {
28 bool areAnyMembersSet = false;
29
30 areAnyMembersSet = DictionaryHelper::get(options, "method", method) || areAn yMembersSet; 28 areAnyMembersSet = DictionaryHelper::get(options, "method", method) || areAn yMembersSet;
Mike West 2015/10/20 07:27:04 Nit: here and elsewhere, `|=` would be clearer.
shiva.jm 2015/10/21 08:34:59 only at these line(30), it holds good, but for oth
hiroshige 2015/10/30 12:31:30 Anyway, if we want to do that change, I think it i
shiva.jm 2015/11/02 12:06:20 Thanks for more detailed inputs, i misunderstand t
31 areAnyMembersSet = DictionaryHelper::get(options, "headers", headers) || are AnyMembersSet; 29 areAnyMembersSet = DictionaryHelper::get(options, "headers", headers) || are AnyMembersSet;
32 if (!headers) { 30 if (!headers) {
33 Vector<Vector<String>> headersVector; 31 Vector<Vector<String>> headersVector;
34 if (DictionaryHelper::get(options, "headers", headersVector, exceptionSt ate)) { 32 if (DictionaryHelper::get(options, "headers", headersVector, exceptionSt ate)) {
35 headers = Headers::create(headersVector, exceptionState); 33 headers = Headers::create(headersVector, exceptionState);
36 areAnyMembersSet = true; 34 areAnyMembersSet = true;
37 } else { 35 } else {
38 areAnyMembersSet = DictionaryHelper::get(options, "headers", headers Dictionary) || areAnyMembersSet; 36 areAnyMembersSet = DictionaryHelper::get(options, "headers", headers Dictionary) || areAnyMembersSet;
39 } 37 }
40 } 38 }
(...skipping 13 matching lines...) Expand all
54 // If any of init's members are present, unset request's 52 // If any of init's members are present, unset request's
55 // omit-Origin-header flag, set request's referrer to "client", 53 // omit-Origin-header flag, set request's referrer to "client",
56 // and request's referrer policy to the empty string. 54 // and request's referrer policy to the empty string.
57 // 55 //
58 // We need to use "about:client" instead of |clientReferrerString|, 56 // We need to use "about:client" instead of |clientReferrerString|,
59 // because "about:client" => |clientReferrerString| conversion is done 57 // because "about:client" => |clientReferrerString| conversion is done
60 // in Request::createRequestWithRequestOrString. 58 // in Request::createRequestWithRequestOrString.
61 referrer = Referrer("about:client", ReferrerPolicyDefault); 59 referrer = Referrer("about:client", ReferrerPolicyDefault);
62 if (isReferrerStringSet) 60 if (isReferrerStringSet)
63 referrer.referrer = referrerString; 61 referrer.referrer = referrerString;
64 isReferrerSet = true;
65 } 62 }
66 63
67 if (!isBodySet || v8Body->IsUndefined() || v8Body->IsNull()) 64 if (!isBodySet || v8Body->IsUndefined() || v8Body->IsNull())
68 return; 65 return;
69 v8::Isolate* isolate = toIsolate(context); 66 v8::Isolate* isolate = toIsolate(context);
70 if (v8Body->IsArrayBuffer()) { 67 if (v8Body->IsArrayBuffer()) {
71 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc al<v8::Object>::Cast(v8Body))); 68 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc al<v8::Object>::Cast(v8Body)));
72 } else if (v8Body->IsArrayBufferView()) { 69 } else if (v8Body->IsArrayBufferView()) {
73 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8: :Local<v8::Object>::Cast(v8Body))); 70 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8: :Local<v8::Object>::Cast(v8Body)));
74 } else if (V8Blob::hasInstance(v8Body, isolate)) { 71 } else if (V8Blob::hasInstance(v8Body, isolate)) {
75 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj ect>::Cast(v8Body))->blobDataHandle(); 72 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj ect>::Cast(v8Body))->blobDataHandle();
76 contentType = blobDataHandle->type(); 73 contentType = blobDataHandle->type();
77 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea se()); 74 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea se());
78 } else if (V8FormData::hasInstance(v8Body, isolate)) { 75 } else if (V8FormData::hasInstance(v8Body, isolate)) {
79 FormData* domFormData = V8FormData::toImpl(v8::Local<v8::Object>::Cast(v 8Body)); 76 FormData* domFormData = V8FormData::toImpl(v8::Local<v8::Object>::Cast(v 8Body));
80 opaque = domFormData->opaque(); 77 opaque = domFormData->opaque();
81 78
82 RefPtr<EncodedFormData> formData = domFormData->encodeMultiPartFormData( ); 79 RefPtr<EncodedFormData> formData = domFormData->encodeMultiPartFormData( );
83 // Here we handle formData->boundary() as a C-style string. See 80 // Here we handle formData->boundary() as a C-style string. See
84 // FormDataEncoder::generateUniqueBoundaryString. 81 // FormDataEncoder::generateUniqueBoundaryString.
85 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin g::ConstructFromLiteral) + formData->boundary().data(); 82 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin g::ConstructFromLiteral) + formData->boundary().data();
86 body = FetchFormDataConsumerHandle::create(context, formData.release()); 83 body = FetchFormDataConsumerHandle::create(context, formData.release());
87 } else if (v8Body->IsString()) { 84 } else if (v8Body->IsString()) {
88 contentType = "text/plain;charset=UTF-8"; 85 contentType = "text/plain;charset=UTF-8";
89 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState)); 86 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState));
90 } 87 }
91 } 88 }
92 89
93 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698