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

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

Issue 2772013002: Fetch API: Fix behavior when Request constructor is passed an undefined referrer (Closed)
Patch Set: nits Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/Dictionary.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 10 matching lines...) Expand all
21 #include "platform/RuntimeEnabledFeatures.h" 21 #include "platform/RuntimeEnabledFeatures.h"
22 #include "platform/blob/BlobData.h" 22 #include "platform/blob/BlobData.h"
23 #include "platform/network/EncodedFormData.h" 23 #include "platform/network/EncodedFormData.h"
24 #include "platform/weborigin/ReferrerPolicy.h" 24 #include "platform/weborigin/ReferrerPolicy.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 RequestInit::RequestInit(ExecutionContext* context, 28 RequestInit::RequestInit(ExecutionContext* context,
29 const Dictionary& options, 29 const Dictionary& options,
30 ExceptionState& exceptionState) 30 ExceptionState& exceptionState)
31 : areAnyMembersSet(false) { 31 : areAnyMembersSet(false) {
yhirano 2017/03/27 10:38:51 Can you put a TODO to use getWithUndefinedCheck in
yiyix 2017/03/28 02:34:06 good call, I can check specs and work on these lat
32 areAnyMembersSet |= DictionaryHelper::get(options, "method", method); 32 areAnyMembersSet |= DictionaryHelper::get(options, "method", method);
33 areAnyMembersSet |= DictionaryHelper::get(options, "headers", headers); 33 areAnyMembersSet |= DictionaryHelper::get(options, "headers", headers);
34 if (!headers) { 34 if (!headers) {
35 Vector<Vector<String>> headersVector; 35 Vector<Vector<String>> headersVector;
36 if (DictionaryHelper::get(options, "headers", headersVector, 36 if (DictionaryHelper::get(options, "headers", headersVector,
37 exceptionState)) { 37 exceptionState)) {
38 headers = Headers::create(headersVector, exceptionState); 38 headers = Headers::create(headersVector, exceptionState);
39 areAnyMembersSet = true; 39 areAnyMembersSet = true;
40 } else { 40 } else {
41 areAnyMembersSet |= 41 areAnyMembersSet |=
42 DictionaryHelper::get(options, "headers", headersDictionary); 42 DictionaryHelper::get(options, "headers", headersDictionary);
43 } 43 }
44 } 44 }
45 areAnyMembersSet |= DictionaryHelper::get(options, "mode", mode); 45 areAnyMembersSet |= DictionaryHelper::get(options, "mode", mode);
46 areAnyMembersSet |= DictionaryHelper::get(options, "redirect", redirect); 46 areAnyMembersSet |= DictionaryHelper::get(options, "redirect", redirect);
47 AtomicString referrerString; 47 AtomicString referrerString;
48 bool isReferrerStringSet = 48 bool isReferrerStringSet = DictionaryHelper::getWithUndefinedCheck(
49 DictionaryHelper::get(options, "referrer", referrerString); 49 options, "referrer", referrerString);
50 areAnyMembersSet |= isReferrerStringSet; 50 areAnyMembersSet |= isReferrerStringSet;
51 areAnyMembersSet |= DictionaryHelper::get(options, "integrity", integrity); 51 areAnyMembersSet |= DictionaryHelper::get(options, "integrity", integrity);
52 AtomicString referrerPolicyString; 52 AtomicString referrerPolicyString;
53 bool isReferrerPolicySet = 53 bool isReferrerPolicySet =
54 DictionaryHelper::get(options, "referrerPolicy", referrerPolicyString); 54 DictionaryHelper::get(options, "referrerPolicy", referrerPolicyString);
55 areAnyMembersSet |= isReferrerPolicySet; 55 areAnyMembersSet |= isReferrerPolicySet;
56 56
57 v8::Local<v8::Value> v8Body; 57 v8::Local<v8::Value> v8Body;
58 bool isBodySet = DictionaryHelper::get(options, "body", v8Body); 58 bool isBodySet = DictionaryHelper::get(options, "body", v8Body);
59 areAnyMembersSet |= isBodySet; 59 areAnyMembersSet |= isBodySet;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 AtomicString("application/x-www-form-urlencoded;charset=UTF-8"); 148 AtomicString("application/x-www-form-urlencoded;charset=UTF-8");
149 body = new FormDataBytesConsumer(context, formData.release()); 149 body = new FormDataBytesConsumer(context, formData.release());
150 } else if (v8Body->IsString()) { 150 } else if (v8Body->IsString()) {
151 contentType = "text/plain;charset=UTF-8"; 151 contentType = "text/plain;charset=UTF-8";
152 body = 152 body =
153 new FormDataBytesConsumer(toUSVString(isolate, v8Body, exceptionState)); 153 new FormDataBytesConsumer(toUSVString(isolate, v8Body, exceptionState));
154 } 154 }
155 } 155 }
156 156
157 } // namespace blink 157 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/Dictionary.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698