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

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 1847383003: CREDENTIAL: Rework the integration with Fetch (2/2) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-serialized
Patch Set: unittest Created 4 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
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 "content/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 request_info.fetch_redirect_mode = 532 request_info.fetch_redirect_mode =
533 GetFetchRedirectModeForWebURLRequest(request); 533 GetFetchRedirectModeForWebURLRequest(request);
534 request_info.fetch_request_context_type = 534 request_info.fetch_request_context_type =
535 GetRequestContextTypeForWebURLRequest(request); 535 GetRequestContextTypeForWebURLRequest(request);
536 request_info.fetch_frame_type = 536 request_info.fetch_frame_type =
537 GetRequestContextFrameTypeForWebURLRequest(request); 537 GetRequestContextFrameTypeForWebURLRequest(request);
538 request_info.extra_data = request.getExtraData(); 538 request_info.extra_data = request.getExtraData();
539 request_info.report_raw_headers = request.reportRawHeaders(); 539 request_info.report_raw_headers = request.reportRawHeaders();
540 request_info.loading_web_task_runner.reset(web_task_runner_->clone()); 540 request_info.loading_web_task_runner.reset(web_task_runner_->clone());
541 541
542 scoped_refptr<ResourceRequestBody> request_body = 542 // If the request has an attached credential, then use it as the
543 GetRequestBodyForWebURLRequest(request).get(); 543 // |request_body| and ensure that the service worker will be presented
544 // with a Request whose body is empty.
545 //
546 // This doesn't line up with the way the spec is written (see
547 // https://w3c.github.io/webappsec-credential-management/#monkey-patching)
548 // but it has the advantage of actually working with our architechture.
549 scoped_refptr<ResourceRequestBody> request_body;
550 if (!request.attachedCredentialBody().isNull()) {
551 request_body =
552 GetRequestBodyForWebURLRequest(request, CREDENTIAL_BODY).get();
553 request_info.empty_body_in_service_worker = true;
554 } else {
555 request_body = GetRequestBodyForWebURLRequest(request, HTTP_BODY).get();
556 request_info.empty_body_in_service_worker = false;
557 }
544 558
545 // PlzNavigate: during navigation, the renderer should request a stream which 559 // PlzNavigate: during navigation, the renderer should request a stream which
546 // contains the body of the response. The network request has already been 560 // contains the body of the response. The network request has already been
547 // made by the browser. 561 // made by the browser.
548 if (stream_override_.get()) { 562 if (stream_override_.get()) {
549 CHECK(IsBrowserSideNavigationEnabled()); 563 CHECK(IsBrowserSideNavigationEnabled());
550 DCHECK(!sync_load_response); 564 DCHECK(!sync_load_response);
551 DCHECK_NE(WebURLRequest::FrameTypeNone, request.getFrameType()); 565 DCHECK_NE(WebURLRequest::FrameTypeNone, request.getFrameType());
552 request_info.resource_body_stream_url = stream_override_->stream_url; 566 request_info.resource_body_stream_url = stream_override_->stream_url;
553 } 567 }
554 568
555 if (sync_load_response) { 569 if (sync_load_response) {
556 resource_dispatcher_->StartSync( 570 resource_dispatcher_->StartSync(request_info, request_body.get(),
557 request_info, request_body.get(), sync_load_response); 571 sync_load_response);
558 return; 572 return;
559 } 573 }
560 574
561 request_id_ = resource_dispatcher_->StartAsync( 575 request_id_ = resource_dispatcher_->StartAsync(
562 request_info, request_body.get(), 576 request_info, request_body.get(),
563 make_scoped_ptr(new WebURLLoaderImpl::RequestPeerImpl(this))); 577 make_scoped_ptr(new WebURLLoaderImpl::RequestPeerImpl(this)));
564 } 578 }
565 579
566 void WebURLLoaderImpl::Context::SetWebTaskRunner( 580 void WebURLLoaderImpl::Context::SetWebTaskRunner(
567 scoped_ptr<blink::WebTaskRunner> web_task_runner) { 581 scoped_ptr<blink::WebTaskRunner> web_task_runner) {
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 response->clearHTTPHeaderField(webStringName); 1186 response->clearHTTPHeaderField(webStringName);
1173 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1187 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1174 response->addHTTPHeaderField(webStringName, 1188 response->addHTTPHeaderField(webStringName,
1175 WebString::fromLatin1(value)); 1189 WebString::fromLatin1(value));
1176 } 1190 }
1177 } 1191 }
1178 return true; 1192 return true;
1179 } 1193 }
1180 1194
1181 } // namespace content 1195 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698