OLD | NEW |
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 Loading... |
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
| 411 // TODO(horo): Check credentials flag is unset when credentials mode is omit. |
| 412 // Check credentials flag is set when credentials mode is include. |
| 413 |
400 RequestInfo request_info; | 414 RequestInfo request_info; |
401 request_info.method = method; | 415 request_info.method = method; |
402 request_info.url = url; | 416 request_info.url = url; |
403 request_info.first_party_for_cookies = request.firstPartyForCookies(); | 417 request_info.first_party_for_cookies = request.firstPartyForCookies(); |
404 request_info.referrer = referrer_url; | 418 request_info.referrer = referrer_url; |
405 request_info.headers = flattener.GetBuffer(); | 419 request_info.headers = flattener.GetBuffer(); |
406 request_info.load_flags = load_flags; | 420 request_info.load_flags = load_flags; |
407 request_info.enable_load_timing = true; | 421 request_info.enable_load_timing = true; |
408 // requestor_pid only needs to be non-zero if the request originates outside | 422 // 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 | 423 // the render process, so we can use requestorProcessID even for requests |
410 // from in-process plugins. | 424 // from in-process plugins. |
411 request_info.requestor_pid = request.requestorProcessID(); | 425 request_info.requestor_pid = request.requestorProcessID(); |
412 request_info.request_type = WebURLRequestToResourceType(request); | 426 request_info.request_type = WebURLRequestToResourceType(request); |
413 request_info.priority = | 427 request_info.priority = |
414 ConvertWebKitPriorityToNetPriority(request.priority()); | 428 ConvertWebKitPriorityToNetPriority(request.priority()); |
415 request_info.appcache_host_id = request.appCacheHostID(); | 429 request_info.appcache_host_id = request.appCacheHostID(); |
416 request_info.routing_id = request.requestorID(); | 430 request_info.routing_id = request.requestorID(); |
417 request_info.download_to_file = request.downloadToFile(); | 431 request_info.download_to_file = request.downloadToFile(); |
418 request_info.has_user_gesture = request.hasUserGesture(); | 432 request_info.has_user_gesture = request.hasUserGesture(); |
419 request_info.skip_service_worker = request.skipServiceWorker(); | 433 request_info.skip_service_worker = request.skipServiceWorker(); |
420 request_info.fetch_request_mode = GetFetchRequestMode(request); | 434 request_info.fetch_request_mode = GetFetchRequestMode(request); |
| 435 request_info.fetch_credentials_mode = GetFetchCredentialsMode(request); |
421 request_info.extra_data = request.extraData(); | 436 request_info.extra_data = request.extraData(); |
422 referrer_policy_ = request.referrerPolicy(); | 437 referrer_policy_ = request.referrerPolicy(); |
423 request_info.referrer_policy = request.referrerPolicy(); | 438 request_info.referrer_policy = request.referrerPolicy(); |
424 bridge_.reset(resource_dispatcher_->CreateBridge(request_info)); | 439 bridge_.reset(resource_dispatcher_->CreateBridge(request_info)); |
425 | 440 |
426 if (!request.httpBody().isNull()) { | 441 if (!request.httpBody().isNull()) { |
427 // GET and HEAD requests shouldn't have http bodies. | 442 // GET and HEAD requests shouldn't have http bodies. |
428 DCHECK(method != "GET" && method != "HEAD"); | 443 DCHECK(method != "GET" && method != "HEAD"); |
429 const WebHTTPBody& httpBody = request.httpBody(); | 444 const WebHTTPBody& httpBody = request.httpBody(); |
430 size_t i = 0; | 445 size_t i = 0; |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 int intra_priority_value) { | 943 int intra_priority_value) { |
929 context_->DidChangePriority(new_priority, intra_priority_value); | 944 context_->DidChangePriority(new_priority, intra_priority_value); |
930 } | 945 } |
931 | 946 |
932 bool WebURLLoaderImpl::attachThreadedDataReceiver( | 947 bool WebURLLoaderImpl::attachThreadedDataReceiver( |
933 blink::WebThreadedDataReceiver* threaded_data_receiver) { | 948 blink::WebThreadedDataReceiver* threaded_data_receiver) { |
934 return context_->AttachThreadedDataReceiver(threaded_data_receiver); | 949 return context_->AttachThreadedDataReceiver(threaded_data_receiver); |
935 } | 950 } |
936 | 951 |
937 } // namespace content | 952 } // namespace content |
OLD | NEW |