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

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

Issue 1411813003: Teach URLRequest about initiator checks for First-Party-Only cookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke Created 5 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
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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 weak_factory_.GetWeakPtr())); 652 weak_factory_.GetWeakPtr()));
653 } else { 653 } else {
654 DoStartTransaction(); 654 DoStartTransaction();
655 } 655 }
656 } 656 }
657 657
658 void URLRequestHttpJob::DoLoadCookies() { 658 void URLRequestHttpJob::DoLoadCookies() {
659 CookieOptions options; 659 CookieOptions options;
660 options.set_include_httponly(); 660 options.set_include_httponly();
661 661
662 // TODO(mkwst): Drop this `if` once we decide whether or not to ship 662 url::Origin origin(request_->url());
663 // first-party cookies: https://crbug.com/459154 663 if (origin.IsSameOriginWith(
664 if (network_delegate() && 664 url::Origin(request_->first_party_for_cookies())) &&
665 network_delegate()->AreExperimentalCookieFeaturesEnabled()) 665 (request_->IsMethodSafe() ||
666 options.set_first_party(url::Origin(request_->first_party_for_cookies())); 666 origin.IsSameOriginWith(request_->initiator()))) {
667 else 667 options.set_include_first_party_only_cookies();
mmenke 2015/10/22 19:57:21 What about requests that don't set either of these
Mike West 2016/01/13 08:10:21 If requests aren't being made in a web context, it
668 options.set_include_first_party_only(); 668 }
669
670 // TODO(mkwst): If first-party-only cookies aren't enabled, pretend the
671 // request is first-party regardless, in order to include all cookies. Drop
672 // this check once we decide whether or not we're shipping this feature:
673 // https://crbug.com/459154
674 if (!network_delegate() ||
675 !network_delegate()->AreExperimentalCookieFeaturesEnabled()) {
676 options.set_include_first_party_only_cookies();
677 }
mmenke 2015/10/22 19:57:21 Think this is clearer as: if (!network_delegate()
Mike West 2016/01/13 08:10:21 My goal was to have something that I could just de
669 678
670 request_->context()->cookie_store()->GetCookiesWithOptionsAsync( 679 request_->context()->cookie_store()->GetCookiesWithOptionsAsync(
671 request_->url(), options, base::Bind(&URLRequestHttpJob::OnCookiesLoaded, 680 request_->url(), options, base::Bind(&URLRequestHttpJob::OnCookiesLoaded,
672 weak_factory_.GetWeakPtr())); 681 weak_factory_.GetWeakPtr()));
673 } 682 }
674 683
675 void URLRequestHttpJob::CheckCookiePolicyAndLoad( 684 void URLRequestHttpJob::CheckCookiePolicyAndLoad(
676 const CookieList& cookie_list) { 685 const CookieList& cookie_list) {
677 if (CanGetCookies(cookie_list)) 686 if (CanGetCookies(cookie_list))
678 DoLoadCookies(); 687 DoLoadCookies();
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 return override_response_headers_.get() ? 1587 return override_response_headers_.get() ?
1579 override_response_headers_.get() : 1588 override_response_headers_.get() :
1580 transaction_->GetResponseInfo()->headers.get(); 1589 transaction_->GetResponseInfo()->headers.get();
1581 } 1590 }
1582 1591
1583 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1592 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1584 awaiting_callback_ = false; 1593 awaiting_callback_ = false;
1585 } 1594 }
1586 1595
1587 } // namespace net 1596 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698