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

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

Issue 1749153002: CORS-RFC1918: Teach ResourceRequest about "external" requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Jochen's feedback. Created 4 years, 9 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 "modules/fetch/FetchManager.h" 5 #include "modules/fetch/FetchManager.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8ThrowException.h" 10 #include "bindings/core/v8/V8ThrowException.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second)); 531 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second));
532 } 532 }
533 533
534 if (m_request->method() != HTTPNames::GET && m_request->method() != HTTPName s::HEAD) { 534 if (m_request->method() != HTTPNames::GET && m_request->method() != HTTPName s::HEAD) {
535 if (m_request->buffer()) { 535 if (m_request->buffer()) {
536 request.setHTTPBody(m_request->buffer()->drainAsFormData()); 536 request.setHTTPBody(m_request->buffer()->drainAsFormData());
537 } 537 }
538 } 538 }
539 request.setFetchRedirectMode(m_request->redirect()); 539 request.setFetchRedirectMode(m_request->redirect());
540 request.setUseStreamOnResponse(true); 540 request.setUseStreamOnResponse(true);
541 request.setExternalRequestStateFromRequestorAddressSpace(executionContext()- >securityContext().addressSpace());
541 542
542 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer| 543 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer|
543 // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8 544 // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8
544 // encoded, otherwise, to HTTPRequest's header list. 545 // encoded, otherwise, to HTTPRequest's header list.
545 // 546 //
546 // The following code also invokes "determine request's referrer" which is 547 // The following code also invokes "determine request's referrer" which is
547 // written in "Main fetch" operation. 548 // written in "Main fetch" operation.
548 ASSERT(m_request->getReferrerPolicy() == ReferrerPolicyDefault); 549 ASSERT(m_request->getReferrerPolicy() == ReferrerPolicyDefault);
549 // Request's referrer policy is always default, so use the client's one. 550 // Request's referrer policy is always default, so use the client's one.
550 // TODO(yhirano): Fix here when we introduce requet's referrer policy. 551 // TODO(yhirano): Fix here when we introduce requet's referrer policy.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 if (m_request->method() != HTTPNames::GET) { 627 if (m_request->method() != HTTPNames::GET) {
627 performNetworkError("Only 'GET' method is allowed for data URLs in Fetch API."); 628 performNetworkError("Only 'GET' method is allowed for data URLs in Fetch API.");
628 return; 629 return;
629 } 630 }
630 631
631 ResourceRequest request(m_request->url()); 632 ResourceRequest request(m_request->url());
632 request.setRequestContext(m_request->context()); 633 request.setRequestContext(m_request->context());
633 request.setUseStreamOnResponse(true); 634 request.setUseStreamOnResponse(true);
634 request.setHTTPMethod(m_request->method()); 635 request.setHTTPMethod(m_request->method());
635 request.setFetchRedirectMode(WebURLRequest::FetchRedirectModeError); 636 request.setFetchRedirectMode(WebURLRequest::FetchRedirectModeError);
637 // We intentionally skip 'setExternalRequestStateFromRequestorAddressSpace', as 'data:' can never be external.
636 638
637 ResourceLoaderOptions resourceLoaderOptions; 639 ResourceLoaderOptions resourceLoaderOptions;
638 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData; 640 resourceLoaderOptions.dataBufferingPolicy = DoNotBufferData;
639 resourceLoaderOptions.securityOrigin = m_request->origin().get(); 641 resourceLoaderOptions.securityOrigin = m_request->origin().get();
640 642
641 ThreadableLoaderOptions threadableLoaderOptions; 643 ThreadableLoaderOptions threadableLoaderOptions;
642 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol icy : EnforceContentSecurityPolicy; 644 threadableLoaderOptions.contentSecurityPolicyEnforcement = ContentSecurityPo licy::shouldBypassMainWorld(executionContext()) ? DoNotEnforceContentSecurityPol icy : EnforceContentSecurityPolicy;
643 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests; 645 threadableLoaderOptions.crossOriginRequestPolicy = AllowCrossOriginRequests;
644 646
645 InspectorInstrumentation::willStartFetch(executionContext(), this); 647 InspectorInstrumentation::willStartFetch(executionContext(), this);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 loader->dispose(); 714 loader->dispose();
713 } 715 }
714 716
715 DEFINE_TRACE(FetchManager) 717 DEFINE_TRACE(FetchManager)
716 { 718 {
717 visitor->trace(m_executionContext); 719 visitor->trace(m_executionContext);
718 visitor->trace(m_loaders); 720 visitor->trace(m_loaders);
719 } 721 }
720 722
721 } // namespace blink 723 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698