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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 4630001: Implement Origin cookies. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 return false; 433 return false;
434 } 434 }
435 435
436 void URLRequestHttpJob::StopCaching() { 436 void URLRequestHttpJob::StopCaching() {
437 if (transaction_.get()) 437 if (transaction_.get())
438 transaction_->StopCaching(); 438 transaction_->StopCaching();
439 } 439 }
440 440
441 void URLRequestHttpJob::AddCookies(bool origin_cookies) {
442 net::CookieOptions options;
443 options.set_include_httponly();
444 options.set_read_origin(origin_cookies);
445
446 std::string cookies =
447 request_->context()->cookie_store()->GetCookiesWithOptions(
448 request_->url(), options);
449 if (cookies.empty())
450 return;
451 const std::string& header_name = origin_cookies ?
452 net::HttpRequestHeaders::kOriginCookie : net::HttpRequestHeaders::kCookie;
453 request_info_.extra_headers.SetHeader(header_name, cookies);
454 }
455
441 void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { 456 void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) {
442 // If the request was destroyed, then there is no more work to do. 457 // If the request was destroyed, then there is no more work to do.
443 if (request_ && request_->delegate()) { 458 if (request_ && request_->delegate()) {
444 if (policy == net::ERR_ACCESS_DENIED) { 459 if (policy == net::ERR_ACCESS_DENIED) {
445 request_->delegate()->OnGetCookies(request_, true); 460 request_->delegate()->OnGetCookies(request_, true);
446 } else if (policy == net::OK && request_->context()->cookie_store()) { 461 } else if (policy == net::OK && request_->context()->cookie_store()) {
447 request_->delegate()->OnGetCookies(request_, false); 462 request_->delegate()->OnGetCookies(request_, false);
448 net::CookieOptions options; 463 AddCookies(false);
449 options.set_include_httponly(); 464 AddCookies(true);
450 std::string cookies =
451 request_->context()->cookie_store()->GetCookiesWithOptions(
452 request_->url(), options);
453 if (!cookies.empty()) {
454 request_info_.extra_headers.SetHeader(
455 net::HttpRequestHeaders::kCookie, cookies);
456 }
457 } 465 }
458 // We may have been canceled within OnGetCookies. 466 // We may have been canceled within OnGetCookies.
459 if (GetStatus().is_success()) { 467 if (GetStatus().is_success()) {
460 StartTransaction(); 468 StartTransaction();
461 } else { 469 } else {
462 NotifyCanceled(); 470 NotifyCanceled();
463 } 471 }
464 } 472 }
465 Release(); // Balance AddRef taken in AddCookieHeaderAndStart 473 Release(); // Balance AddRef taken in AddCookieHeaderAndStart
466 } 474 }
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 HTTPSProberDelegate* delegate = 921 HTTPSProberDelegate* delegate =
914 new HTTPSProberDelegate(request_info_.url.host(), max_age, 922 new HTTPSProberDelegate(request_info_.url.host(), max_age,
915 include_subdomains, 923 include_subdomains,
916 ctx->transport_security_state()); 924 ctx->transport_security_state());
917 if (!prober->ProbeHost(request_info_.url.host(), request()->context(), 925 if (!prober->ProbeHost(request_info_.url.host(), request()->context(),
918 delegate)) { 926 delegate)) {
919 delete delegate; 927 delete delegate;
920 } 928 }
921 } 929 }
922 } 930 }
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698