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

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

Issue 1393193005: Implement $Secure- cookie prefix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add another test Created 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 DoStartTransaction(); 653 DoStartTransaction();
654 } 654 }
655 } 655 }
656 656
657 void URLRequestHttpJob::DoLoadCookies() { 657 void URLRequestHttpJob::DoLoadCookies() {
658 CookieOptions options; 658 CookieOptions options;
659 options.set_include_httponly(); 659 options.set_include_httponly();
660 660
661 // TODO(mkwst): Drop this `if` once we decide whether or not to ship 661 // TODO(mkwst): Drop this `if` once we decide whether or not to ship
662 // first-party cookies: https://crbug.com/459154 662 // first-party cookies: https://crbug.com/459154
663 if (network_delegate() && 663 if (network_delegate() && network_delegate()->ExperimentalFeaturesEnabled())
664 network_delegate()->FirstPartyOnlyCookieExperimentEnabled())
665 options.set_first_party_url(request_->first_party_for_cookies()); 664 options.set_first_party_url(request_->first_party_for_cookies());
666 else 665 else
667 options.set_include_first_party_only(); 666 options.set_include_first_party_only();
668 667
669 request_->context()->cookie_store()->GetCookiesWithOptionsAsync( 668 request_->context()->cookie_store()->GetCookiesWithOptionsAsync(
670 request_->url(), options, base::Bind(&URLRequestHttpJob::OnCookiesLoaded, 669 request_->url(), options, base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
671 weak_factory_.GetWeakPtr())); 670 weak_factory_.GetWeakPtr()));
672 } 671 }
673 672
674 void URLRequestHttpJob::CheckCookiePolicyAndLoad( 673 void URLRequestHttpJob::CheckCookiePolicyAndLoad(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // OnCookieSaved. 741 // OnCookieSaved.
743 scoped_refptr<SharedBoolean> callback_pending = new SharedBoolean(false); 742 scoped_refptr<SharedBoolean> callback_pending = new SharedBoolean(false);
744 scoped_refptr<SharedBoolean> save_next_cookie_running = 743 scoped_refptr<SharedBoolean> save_next_cookie_running =
745 new SharedBoolean(true); 744 new SharedBoolean(true);
746 745
747 if (!(request_info_.load_flags & LOAD_DO_NOT_SAVE_COOKIES) && 746 if (!(request_info_.load_flags & LOAD_DO_NOT_SAVE_COOKIES) &&
748 request_->context()->cookie_store() && response_cookies_.size() > 0) { 747 request_->context()->cookie_store() && response_cookies_.size() > 0) {
749 CookieOptions options; 748 CookieOptions options;
750 options.set_include_httponly(); 749 options.set_include_httponly();
751 options.set_server_time(response_date_); 750 options.set_server_time(response_date_);
751 if (network_delegate()->ExperimentalFeaturesEnabled())
752 options.set_enforce_prefixes();
752 753
753 CookieStore::SetCookiesCallback callback(base::Bind( 754 CookieStore::SetCookiesCallback callback(base::Bind(
754 &URLRequestHttpJob::OnCookieSaved, weak_factory_.GetWeakPtr(), 755 &URLRequestHttpJob::OnCookieSaved, weak_factory_.GetWeakPtr(),
755 save_next_cookie_running, callback_pending)); 756 save_next_cookie_running, callback_pending));
756 757
757 // Loop through the cookies as long as SetCookieWithOptionsAsync completes 758 // Loop through the cookies as long as SetCookieWithOptionsAsync completes
758 // synchronously. 759 // synchronously.
759 while (!callback_pending->data && 760 while (!callback_pending->data &&
760 response_cookies_save_index_ < response_cookies_.size()) { 761 response_cookies_save_index_ < response_cookies_.size()) {
761 if (CanSetCookie( 762 if (CanSetCookie(
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 return override_response_headers_.get() ? 1576 return override_response_headers_.get() ?
1576 override_response_headers_.get() : 1577 override_response_headers_.get() :
1577 transaction_->GetResponseInfo()->headers.get(); 1578 transaction_->GetResponseInfo()->headers.get();
1578 } 1579 }
1579 1580
1580 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1581 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1581 awaiting_callback_ = false; 1582 awaiting_callback_ = false;
1582 } 1583 }
1583 1584
1584 } // namespace net 1585 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698