OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 434 |
435 void URLRequestHttpJob::StopCaching() { | 435 void URLRequestHttpJob::StopCaching() { |
436 if (transaction_.get()) | 436 if (transaction_.get()) |
437 transaction_->StopCaching(); | 437 transaction_->StopCaching(); |
438 } | 438 } |
439 | 439 |
440 void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { | 440 void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { |
441 // If the request was destroyed, then there is no more work to do. | 441 // If the request was destroyed, then there is no more work to do. |
442 if (request_ && request_->delegate()) { | 442 if (request_ && request_->delegate()) { |
443 if (policy == net::ERR_ACCESS_DENIED) { | 443 if (policy == net::ERR_ACCESS_DENIED) { |
444 request_->delegate()->OnGetCookiesBlocked(request_); | 444 request_->delegate()->OnGetCookies(request_, true); |
445 } else if (policy == net::OK && request_->context()->cookie_store()) { | 445 } else if (policy == net::OK && request_->context()->cookie_store()) { |
| 446 request_->delegate()->OnGetCookies(request_, false); |
446 net::CookieOptions options; | 447 net::CookieOptions options; |
447 options.set_include_httponly(); | 448 options.set_include_httponly(); |
448 std::string cookies = | 449 std::string cookies = |
449 request_->context()->cookie_store()->GetCookiesWithOptions( | 450 request_->context()->cookie_store()->GetCookiesWithOptions( |
450 request_->url(), options); | 451 request_->url(), options); |
451 if (request_->context()->InterceptRequestCookies(request_, cookies) && | 452 if (request_->context()->InterceptRequestCookies(request_, cookies) && |
452 !cookies.empty()) { | 453 !cookies.empty()) { |
453 request_info_.extra_headers.SetHeader( | 454 request_info_.extra_headers.SetHeader( |
454 net::HttpRequestHeaders::kCookie, cookies); | 455 net::HttpRequestHeaders::kCookie, cookies); |
455 } | 456 } |
456 } | 457 } |
457 // We may have been canceled within OnGetCookiesBlocked. | 458 // We may have been canceled within OnGetCookies. |
458 if (GetStatus().is_success()) { | 459 if (GetStatus().is_success()) { |
459 StartTransaction(); | 460 StartTransaction(); |
460 } else { | 461 } else { |
461 NotifyCanceled(); | 462 NotifyCanceled(); |
462 } | 463 } |
463 } | 464 } |
464 Release(); // Balance AddRef taken in AddCookieHeaderAndStart | 465 Release(); // Balance AddRef taken in AddCookieHeaderAndStart |
465 } | 466 } |
466 | 467 |
467 void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) { | 468 void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) { |
468 // If the request was destroyed, then there is no more work to do. | 469 // If the request was destroyed, then there is no more work to do. |
469 if (request_ && request_->delegate()) { | 470 if (request_ && request_->delegate()) { |
470 if (policy == net::ERR_ACCESS_DENIED) { | 471 if (policy == net::ERR_ACCESS_DENIED) { |
471 request_->delegate()->OnSetCookieBlocked(request_); | 472 request_->delegate()->OnSetCookie( |
| 473 request_, |
| 474 response_cookies_[response_cookies_save_index_], |
| 475 true); |
472 } else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) && | 476 } else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) && |
473 request_->context()->cookie_store()) { | 477 request_->context()->cookie_store()) { |
474 // OK to save the current response cookie now. | 478 // OK to save the current response cookie now. |
475 net::CookieOptions options; | 479 net::CookieOptions options; |
476 options.set_include_httponly(); | 480 options.set_include_httponly(); |
477 if (policy == net::OK_FOR_SESSION_ONLY) | 481 if (policy == net::OK_FOR_SESSION_ONLY) |
478 options.set_force_session(); | 482 options.set_force_session(); |
479 request_->context()->cookie_store()->SetCookieWithOptions( | 483 request_->context()->cookie_store()->SetCookieWithOptions( |
480 request_->url(), response_cookies_[response_cookies_save_index_], | 484 request_->url(), response_cookies_[response_cookies_save_index_], |
481 options); | 485 options); |
| 486 request_->delegate()->OnSetCookie( |
| 487 request_, |
| 488 response_cookies_[response_cookies_save_index_], |
| 489 false); |
482 } | 490 } |
483 response_cookies_save_index_++; | 491 response_cookies_save_index_++; |
484 // We may have been canceled within OnSetCookieBlocked. | 492 // We may have been canceled within OnSetCookie. |
485 if (GetStatus().is_success()) { | 493 if (GetStatus().is_success()) { |
486 SaveNextCookie(); | 494 SaveNextCookie(); |
487 } else { | 495 } else { |
488 NotifyCanceled(); | 496 NotifyCanceled(); |
489 } | 497 } |
490 } | 498 } |
491 Release(); // Balance AddRef taken in SaveNextCookie | 499 Release(); // Balance AddRef taken in SaveNextCookie |
492 } | 500 } |
493 | 501 |
494 void URLRequestHttpJob::OnStartCompleted(int result) { | 502 void URLRequestHttpJob::OnStartCompleted(int result) { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 HTTPSProberDelegate* delegate = | 913 HTTPSProberDelegate* delegate = |
906 new HTTPSProberDelegate(request_info_.url.host(), max_age, | 914 new HTTPSProberDelegate(request_info_.url.host(), max_age, |
907 include_subdomains, | 915 include_subdomains, |
908 ctx->transport_security_state()); | 916 ctx->transport_security_state()); |
909 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), | 917 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), |
910 delegate)) { | 918 delegate)) { |
911 delete delegate; | 919 delete delegate; |
912 } | 920 } |
913 } | 921 } |
914 } | 922 } |
OLD | NEW |