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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/FetchManager.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/FetchManager.h" 6 #include "modules/fetch/FetchManager.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo nse& response, PassOwnPtr<WebDataConsumerHandle> handle) 202 void FetchManager::Loader::didReceiveResponse(unsigned long, const ResourceRespo nse& response, PassOwnPtr<WebDataConsumerHandle> handle)
203 { 203 {
204 ASSERT(handle); 204 ASSERT(handle);
205 205
206 m_responseHttpStatusCode = response.httpStatusCode(); 206 m_responseHttpStatusCode = response.httpStatusCode();
207 207
208 // Recompute the tainting if the request was redirected to a different 208 // Recompute the tainting if the request was redirected to a different
209 // origin. 209 // origin.
210 if (!SecurityOrigin::create(response.url())->isSameSchemeHostPort(m_request- >origin().get())) { 210 if (!SecurityOrigin::create(response.url())->isSameSchemeHostPort(m_request- >origin().get())) {
211 switch (m_request->mode()) { 211 switch (m_request->mode()) {
212 case WebURLRequest::FetchRequestModeNavigate:
213 m_request->setResponseTainting(FetchRequestData::OpaqueTainting);
horo 2015/10/14 10:05:31 I think this should be "ASSERT_NOT_REACHED();". T
shiva.jm 2015/10/14 10:59:06 Done, had same opinion in patchset2, but miss read
hiroshige 2015/10/15 06:37:03 horo@, What poses this limitation? The current Fet
horo 2015/10/15 11:43:05 "navigate" request is created only while "Navigati
214 break;
212 case WebURLRequest::FetchRequestModeSameOrigin: 215 case WebURLRequest::FetchRequestModeSameOrigin:
213 ASSERT_NOT_REACHED(); 216 ASSERT_NOT_REACHED();
214 break; 217 break;
215 case WebURLRequest::FetchRequestModeNoCORS: 218 case WebURLRequest::FetchRequestModeNoCORS:
216 m_request->setResponseTainting(FetchRequestData::OpaqueTainting); 219 m_request->setResponseTainting(FetchRequestData::OpaqueTainting);
217 break; 220 break;
218 case WebURLRequest::FetchRequestModeCORS: 221 case WebURLRequest::FetchRequestModeCORS:
219 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 222 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
220 m_request->setResponseTainting(FetchRequestData::CORSTainting); 223 m_request->setResponseTainting(FetchRequestData::CORSTainting);
221 break; 224 break;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // "- |request|'s url's scheme is 'about'" 377 // "- |request|'s url's scheme is 'about'"
375 // Note we don't support to call this method with |CORS flag|. 378 // Note we don't support to call this method with |CORS flag|.
376 if ((SecurityOrigin::create(m_request->url())->isSameSchemeHostPortAndSubori gin(m_request->origin().get())) 379 if ((SecurityOrigin::create(m_request->url())->isSameSchemeHostPortAndSubori gin(m_request->origin().get()))
377 || (m_request->url().protocolIsData() && m_request->sameOriginDataURLFla g()) 380 || (m_request->url().protocolIsData() && m_request->sameOriginDataURLFla g())
378 || (m_request->url().protocolIsAbout())) { 381 || (m_request->url().protocolIsAbout())) {
379 // "The result of performing a basic fetch using request." 382 // "The result of performing a basic fetch using request."
380 performBasicFetch(); 383 performBasicFetch();
381 return; 384 return;
382 } 385 }
383 386
387 // "- |request|'s mode is |navigate|"
388 if (m_request->mode() == WebURLRequest::FetchRequestModeNavigate) {
389 // "The result of performing a basic fetch using |request|."
390 performBasicFetch();
391 return;
392 }
393
384 // "- |request|'s mode is |same-origin|" 394 // "- |request|'s mode is |same-origin|"
385 if (m_request->mode() == WebURLRequest::FetchRequestModeSameOrigin) { 395 if (m_request->mode() == WebURLRequest::FetchRequestModeSameOrigin) {
386 // "A network error." 396 // "A network error."
387 performNetworkError("Fetch API cannot load " + m_request->url().string() + ". Request mode is \"same-origin\" but the URL\'s origin is not same as the r equest origin " + m_request->origin()->toString() + "."); 397 performNetworkError("Fetch API cannot load " + m_request->url().string() + ". Request mode is \"same-origin\" but the URL\'s origin is not same as the r equest origin " + m_request->origin()->toString() + ".");
388 return; 398 return;
389 } 399 }
390 400
391 // "- |request|'s mode is |no CORS|" 401 // "- |request|'s mode is |no CORS|"
392 if (m_request->mode() == WebURLRequest::FetchRequestModeNoCORS) { 402 if (m_request->mode() == WebURLRequest::FetchRequestModeNoCORS) {
393 // "Set |request|'s response tainting to |opaque|." 403 // "Set |request|'s response tainting to |opaque|."
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 538 }
529 if (m_request->credentials() == WebURLRequest::FetchCredentialsModeInclude) 539 if (m_request->credentials() == WebURLRequest::FetchCredentialsModeInclude)
530 resourceLoaderOptions.credentialsRequested = ClientRequestedCredentials; 540 resourceLoaderOptions.credentialsRequested = ClientRequestedCredentials;
531 resourceLoaderOptions.securityOrigin = m_request->origin().get(); 541 resourceLoaderOptions.securityOrigin = m_request->origin().get();
532 542
533 ThreadableLoaderOptions threadableLoaderOptions; 543 ThreadableLoaderOptions threadableLoaderOptions;
534 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol icy : EnforceConnectSrcDirective; 544 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol icy : EnforceConnectSrcDirective;
535 if (corsPreflightFlag) 545 if (corsPreflightFlag)
536 threadableLoaderOptions.preflightPolicy = ForcePreflight; 546 threadableLoaderOptions.preflightPolicy = ForcePreflight;
537 switch (m_request->mode()) { 547 switch (m_request->mode()) {
548 case WebURLRequest::FetchRequestModeNavigate:
549 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque sts;
horo 2015/10/14 10:05:31 We don't need to allow cross origin requests. This
shiva.jm 2015/10/14 10:59:06 Done, had same opinion in patchset2, but miss read
hiroshige 2015/10/15 06:37:03 horo@, I want to clarify why this should be DenyCr
horo 2015/10/15 11:43:05 "navigate" request is only available in ServiceWor
yhirano 2015/10/16 18:15:53 (to: horo@) I feel it confusing. How about - usin
horo 2015/10/19 04:08:13 Yes, we should have comments. But I think we shoul
550 break;
538 case WebURLRequest::FetchRequestModeSameOrigin: 551 case WebURLRequest::FetchRequestModeSameOrigin:
539 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques ts; 552 threadableLoaderOptions.crossOriginRequestPolicy = DenyCrossOriginReques ts;
540 break; 553 break;
541 case WebURLRequest::FetchRequestModeNoCORS: 554 case WebURLRequest::FetchRequestModeNoCORS:
542 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque sts; 555 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginReque sts;
543 break; 556 break;
544 case WebURLRequest::FetchRequestModeCORS: 557 case WebURLRequest::FetchRequestModeCORS:
545 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight: 558 case WebURLRequest::FetchRequestModeCORSWithForcedPreflight:
546 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl; 559 threadableLoaderOptions.crossOriginRequestPolicy = UseAccessControl;
547 break; 560 break;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 loader->dispose(); 630 loader->dispose();
618 } 631 }
619 632
620 DEFINE_TRACE(FetchManager) 633 DEFINE_TRACE(FetchManager)
621 { 634 {
622 visitor->trace(m_executionContext); 635 visitor->trace(m_executionContext);
623 visitor->trace(m_loaders); 636 visitor->trace(m_loaders);
624 } 637 }
625 638
626 } // namespace blink 639 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698