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

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

Issue 615493003: [ServiceWorker] Plumbing the request credentials mode to the ServiceWorker. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix GetFetchCredentialsMode Created 6 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge.
6 6
7 #include "content/child/web_url_loader_impl.h" 7 #include "content/child/web_url_loader_impl.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_CORS, 212 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_REQUEST_MODE_CORS,
213 WebURLRequest::FetchRequestModeCORS); 213 WebURLRequest::FetchRequestModeCORS);
214 COMPILE_ASSERT_MATCHING_ENUMS( 214 COMPILE_ASSERT_MATCHING_ENUMS(
215 FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT, 215 FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT,
216 WebURLRequest::FetchRequestModeCORSWithForcedPreflight); 216 WebURLRequest::FetchRequestModeCORSWithForcedPreflight);
217 217
218 FetchRequestMode GetFetchRequestMode(const WebURLRequest& request) { 218 FetchRequestMode GetFetchRequestMode(const WebURLRequest& request) {
219 return static_cast<FetchRequestMode>(request.fetchRequestMode()); 219 return static_cast<FetchRequestMode>(request.fetchRequestMode());
220 } 220 }
221 221
222 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_OMIT,
223 WebURLRequest::FetchCredentialsModeOmit);
224 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
225 WebURLRequest::FetchCredentialsModeSameOrigin);
226 COMPILE_ASSERT_MATCHING_ENUMS(FETCH_CREDENTIALS_MODE_INCLUDE,
227 WebURLRequest::FetchCredentialsModeInclude);
228
229 FetchCredentialsMode GetFetchCredentialsMode(const WebURLRequest& request) {
230 return static_cast<FetchCredentialsMode>(request.fetchCredentialsMode());
231 }
232
222 } // namespace 233 } // namespace
223 234
224 // WebURLLoaderImpl::Context -------------------------------------------------- 235 // WebURLLoaderImpl::Context --------------------------------------------------
225 236
226 // This inner class exists since the WebURLLoader may be deleted while inside a 237 // This inner class exists since the WebURLLoader may be deleted while inside a
227 // call to WebURLLoaderClient. Refcounting is to keep the context from being 238 // call to WebURLLoaderClient. Refcounting is to keep the context from being
228 // deleted if it may have work to do after calling into the client. 239 // deleted if it may have work to do after calling into the client.
229 class WebURLLoaderImpl::Context : public base::RefCounted<Context>, 240 class WebURLLoaderImpl::Context : public base::RefCounted<Context>,
230 public RequestPeer { 241 public RequestPeer {
231 public: 242 public:
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 if (request.requestContext() == WebURLRequest::RequestContextXMLHttpRequest && 400 if (request.requestContext() == WebURLRequest::RequestContextXMLHttpRequest &&
390 (url.has_username() || url.has_password())) { 401 (url.has_username() || url.has_password())) {
391 load_flags |= net::LOAD_DO_NOT_PROMPT_FOR_LOGIN; 402 load_flags |= net::LOAD_DO_NOT_PROMPT_FOR_LOGIN;
392 } 403 }
393 404
394 HeaderFlattener flattener; 405 HeaderFlattener flattener;
395 request.visitHTTPHeaderFields(&flattener); 406 request.visitHTTPHeaderFields(&flattener);
396 407
397 // TODO(brettw) this should take parameter encoding into account when 408 // TODO(brettw) this should take parameter encoding into account when
398 // creating the GURLs. 409 // creating the GURLs.
399 410
yhirano 2014/10/01 06:41:12 How about placing assertions here? credentials mod
horo 2014/10/01 06:57:34 Currently we can't add these assertions because cr
Mike West 2014/10/01 08:27:20 Can you add a TODO comment here to that effect?
horo 2014/10/01 08:36:02 Done.
400 RequestInfo request_info; 411 RequestInfo request_info;
401 request_info.method = method; 412 request_info.method = method;
402 request_info.url = url; 413 request_info.url = url;
403 request_info.first_party_for_cookies = request.firstPartyForCookies(); 414 request_info.first_party_for_cookies = request.firstPartyForCookies();
404 request_info.referrer = referrer_url; 415 request_info.referrer = referrer_url;
405 request_info.headers = flattener.GetBuffer(); 416 request_info.headers = flattener.GetBuffer();
406 request_info.load_flags = load_flags; 417 request_info.load_flags = load_flags;
407 request_info.enable_load_timing = true; 418 request_info.enable_load_timing = true;
408 // requestor_pid only needs to be non-zero if the request originates outside 419 // requestor_pid only needs to be non-zero if the request originates outside
409 // the render process, so we can use requestorProcessID even for requests 420 // the render process, so we can use requestorProcessID even for requests
410 // from in-process plugins. 421 // from in-process plugins.
411 request_info.requestor_pid = request.requestorProcessID(); 422 request_info.requestor_pid = request.requestorProcessID();
412 request_info.request_type = WebURLRequestToResourceType(request); 423 request_info.request_type = WebURLRequestToResourceType(request);
413 request_info.priority = 424 request_info.priority =
414 ConvertWebKitPriorityToNetPriority(request.priority()); 425 ConvertWebKitPriorityToNetPriority(request.priority());
415 request_info.appcache_host_id = request.appCacheHostID(); 426 request_info.appcache_host_id = request.appCacheHostID();
416 request_info.routing_id = request.requestorID(); 427 request_info.routing_id = request.requestorID();
417 request_info.download_to_file = request.downloadToFile(); 428 request_info.download_to_file = request.downloadToFile();
418 request_info.has_user_gesture = request.hasUserGesture(); 429 request_info.has_user_gesture = request.hasUserGesture();
419 request_info.skip_service_worker = request.skipServiceWorker(); 430 request_info.skip_service_worker = request.skipServiceWorker();
420 request_info.fetch_request_mode = GetFetchRequestMode(request); 431 request_info.fetch_request_mode = GetFetchRequestMode(request);
432 request_info.fetch_credentials_mode = GetFetchCredentialsMode(request);
421 request_info.extra_data = request.extraData(); 433 request_info.extra_data = request.extraData();
422 referrer_policy_ = request.referrerPolicy(); 434 referrer_policy_ = request.referrerPolicy();
423 request_info.referrer_policy = request.referrerPolicy(); 435 request_info.referrer_policy = request.referrerPolicy();
424 bridge_.reset(resource_dispatcher_->CreateBridge(request_info)); 436 bridge_.reset(resource_dispatcher_->CreateBridge(request_info));
425 437
426 if (!request.httpBody().isNull()) { 438 if (!request.httpBody().isNull()) {
427 // GET and HEAD requests shouldn't have http bodies. 439 // GET and HEAD requests shouldn't have http bodies.
428 DCHECK(method != "GET" && method != "HEAD"); 440 DCHECK(method != "GET" && method != "HEAD");
429 const WebHTTPBody& httpBody = request.httpBody(); 441 const WebHTTPBody& httpBody = request.httpBody();
430 size_t i = 0; 442 size_t i = 0;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 int intra_priority_value) { 938 int intra_priority_value) {
927 context_->DidChangePriority(new_priority, intra_priority_value); 939 context_->DidChangePriority(new_priority, intra_priority_value);
928 } 940 }
929 941
930 bool WebURLLoaderImpl::attachThreadedDataReceiver( 942 bool WebURLLoaderImpl::attachThreadedDataReceiver(
931 blink::WebThreadedDataReceiver* threaded_data_receiver) { 943 blink::WebThreadedDataReceiver* threaded_data_receiver) {
932 return context_->AttachThreadedDataReceiver(threaded_data_receiver); 944 return context_->AttachThreadedDataReceiver(threaded_data_receiver);
933 } 945 }
934 946
935 } // namespace content 947 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698