OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/weburlloader_impl.h" | 7 #include "webkit/glue/weburlloader_impl.h" |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 load_flags |= net::LOAD_REPORT_RAW_HEADERS; | 396 load_flags |= net::LOAD_REPORT_RAW_HEADERS; |
397 | 397 |
398 if (!request.allowCookies() || !request.allowStoredCredentials()) { | 398 if (!request.allowCookies() || !request.allowStoredCredentials()) { |
399 load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; | 399 load_flags |= net::LOAD_DO_NOT_SAVE_COOKIES; |
400 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; | 400 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES; |
401 } | 401 } |
402 | 402 |
403 if (!request.allowStoredCredentials()) | 403 if (!request.allowStoredCredentials()) |
404 load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA; | 404 load_flags |= net::LOAD_DO_NOT_SEND_AUTH_DATA; |
405 | 405 |
406 // TODO(jcampan): in the non out-of-process plugin case the request does not | |
407 // have a requestor_pid. Find a better place to set this. | |
408 int requestor_pid = request.requestorProcessID(); | |
409 if (requestor_pid == 0) | |
410 requestor_pid = base::GetCurrentProcId(); | |
411 | |
412 HeaderFlattener flattener(load_flags); | 406 HeaderFlattener flattener(load_flags); |
413 request.visitHTTPHeaderFields(&flattener); | 407 request.visitHTTPHeaderFields(&flattener); |
414 | 408 |
415 // TODO(abarth): These are wrong! I need to figure out how to get the right | 409 // TODO(abarth): These are wrong! I need to figure out how to get the right |
416 // strings here. See: http://crbug.com/8706 | 410 // strings here. See: http://crbug.com/8706 |
417 std::string frame_origin = request.firstPartyForCookies().spec(); | 411 std::string frame_origin = request.firstPartyForCookies().spec(); |
418 std::string main_frame_origin = request.firstPartyForCookies().spec(); | 412 std::string main_frame_origin = request.firstPartyForCookies().spec(); |
419 | 413 |
420 // TODO(brettw) this should take parameter encoding into account when | 414 // TODO(brettw) this should take parameter encoding into account when |
421 // creating the GURLs. | 415 // creating the GURLs. |
422 | 416 |
423 ResourceLoaderBridge::RequestInfo request_info; | 417 ResourceLoaderBridge::RequestInfo request_info; |
424 request_info.method = method; | 418 request_info.method = method; |
425 request_info.url = url; | 419 request_info.url = url; |
426 request_info.first_party_for_cookies = request.firstPartyForCookies(); | 420 request_info.first_party_for_cookies = request.firstPartyForCookies(); |
427 request_info.referrer = referrer_url; | 421 request_info.referrer = referrer_url; |
428 request_info.frame_origin = frame_origin; | 422 request_info.frame_origin = frame_origin; |
429 request_info.main_frame_origin = main_frame_origin; | 423 request_info.main_frame_origin = main_frame_origin; |
430 request_info.headers = flattener.GetBuffer(); | 424 request_info.headers = flattener.GetBuffer(); |
431 request_info.load_flags = load_flags; | 425 request_info.load_flags = load_flags; |
432 request_info.requestor_pid = requestor_pid; | 426 // requestor_pid only needs to be non-zero if the request originates outside |
| 427 // the render process, so we can use requestorProcessID even for requests |
| 428 // from in-process plugins. |
| 429 request_info.requestor_pid = request.requestorProcessID(); |
433 request_info.request_type = FromTargetType(request.targetType()); | 430 request_info.request_type = FromTargetType(request.targetType()); |
434 request_info.appcache_host_id = request.appCacheHostID(); | 431 request_info.appcache_host_id = request.appCacheHostID(); |
435 request_info.routing_id = request.requestorID(); | 432 request_info.routing_id = request.requestorID(); |
436 request_info.download_to_file = request.downloadToFile(); | 433 request_info.download_to_file = request.downloadToFile(); |
437 request_info.has_user_gesture = request.hasUserGesture(); | 434 request_info.has_user_gesture = request.hasUserGesture(); |
438 bridge_.reset(ResourceLoaderBridge::Create(request_info)); | 435 bridge_.reset(ResourceLoaderBridge::Create(request_info)); |
439 | 436 |
440 if (!request.httpBody().isNull()) { | 437 if (!request.httpBody().isNull()) { |
441 // GET and HEAD requests shouldn't have http bodies. | 438 // GET and HEAD requests shouldn't have http bodies. |
442 DCHECK(method != "GET" && method != "HEAD"); | 439 DCHECK(method != "GET" && method != "HEAD"); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 747 |
751 void WebURLLoaderImpl::cancel() { | 748 void WebURLLoaderImpl::cancel() { |
752 context_->Cancel(); | 749 context_->Cancel(); |
753 } | 750 } |
754 | 751 |
755 void WebURLLoaderImpl::setDefersLoading(bool value) { | 752 void WebURLLoaderImpl::setDefersLoading(bool value) { |
756 context_->SetDefersLoading(value); | 753 context_->SetDefersLoading(value); |
757 } | 754 } |
758 | 755 |
759 } // namespace webkit_glue | 756 } // namespace webkit_glue |
OLD | NEW |