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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Request.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/Request.h" 6 #include "modules/fetch/Request.h"
7 7
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return nullptr; 155 return nullptr;
156 } else { 156 } else {
157 // 7. Set |request|'s referrer to |parsedReferrer|. 157 // 7. Set |request|'s referrer to |parsedReferrer|.
158 request->setReferrerString(AtomicString(parsedReferrer.string()) ); 158 request->setReferrerString(AtomicString(parsedReferrer.string()) );
159 } 159 }
160 } 160 }
161 request->setReferrerPolicy(init.referrer.referrerPolicy); 161 request->setReferrerPolicy(init.referrer.referrerPolicy);
162 } 162 }
163 163
164 164
165 // "17. Let |mode| be |init|'s mode member if it is present, and 165 // "16. Let |mode| be |init|'s mode member if it is present, and
166 // |fallbackMode| otherwise." 166 // |fallbackMode| otherwise."
167 // "17.If mode is "navigate", throw a TypeError.
167 // "18. If |mode| is non-null, set |request|'s mode to |mode|." 168 // "18. If |mode| is non-null, set |request|'s mode to |mode|."
169 if (init.mode == "navigate") {
170 exceptionState.throwTypeError("Cannot construct a Request with a Request mode as navigate.");
171 return nullptr;
172 }
168 if (init.mode == "same-origin") { 173 if (init.mode == "same-origin") {
169 request->setMode(WebURLRequest::FetchRequestModeSameOrigin); 174 request->setMode(WebURLRequest::FetchRequestModeSameOrigin);
170 } else if (init.mode == "no-cors") { 175 } else if (init.mode == "no-cors") {
171 request->setMode(WebURLRequest::FetchRequestModeNoCORS); 176 request->setMode(WebURLRequest::FetchRequestModeNoCORS);
172 } else if (init.mode == "cors") { 177 } else if (init.mode == "cors") {
173 request->setMode(WebURLRequest::FetchRequestModeCORS); 178 request->setMode(WebURLRequest::FetchRequestModeCORS);
174 } else { 179 } else {
175 if (!inputRequest) 180 if (!inputRequest)
176 request->setMode(WebURLRequest::FetchRequestModeCORS); 181 request->setMode(WebURLRequest::FetchRequestModeCORS);
177 } 182 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 ASSERT(FetchRequestData::noReferrerString() == AtomicString()); 488 ASSERT(FetchRequestData::noReferrerString() == AtomicString());
484 ASSERT(FetchRequestData::clientReferrerString() == AtomicString("about:clien t")); 489 ASSERT(FetchRequestData::clientReferrerString() == AtomicString("about:clien t"));
485 return m_request->referrerString(); 490 return m_request->referrerString();
486 } 491 }
487 492
488 String Request::mode() const 493 String Request::mode() const
489 { 494 {
490 // "The mode attribute's getter must return the value corresponding to the 495 // "The mode attribute's getter must return the value corresponding to the
491 // first matching statement, switching on request's mode:" 496 // first matching statement, switching on request's mode:"
492 switch (m_request->mode()) { 497 switch (m_request->mode()) {
498 case WebURLRequest::FetchRequestModeNavigate:
499 return "navigate";
493 case WebURLRequest::FetchRequestModeSameOrigin: 500 case WebURLRequest::FetchRequestModeSameOrigin:
494 return "same-origin"; 501 return "same-origin";
495 case WebURLRequest::FetchRequestModeNoCORS: 502 case WebURLRequest::FetchRequestModeNoCORS:
496 return "no-cors"; 503 return "no-cors";
497 case WebURLRequest::FetchRequestModeCORS: 504 case WebURLRequest::FetchRequestModeCORS:
498 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 505 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
499 return "cors"; 506 return "cors";
500 } 507 }
501 ASSERT_NOT_REACHED(); 508 ASSERT_NOT_REACHED();
502 return ""; 509 return "";
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 596 }
590 597
591 DEFINE_TRACE(Request) 598 DEFINE_TRACE(Request)
592 { 599 {
593 Body::trace(visitor); 600 Body::trace(visitor);
594 visitor->trace(m_request); 601 visitor->trace(m_request);
595 visitor->trace(m_headers); 602 visitor->trace(m_headers);
596 } 603 }
597 604
598 } // namespace blink 605 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698