diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 05:02:13 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 05:02:13 +0000 |
commit | abf03a02e78533b36aa1a878ee1a2f1bfba13867 (patch) | |
tree | a2093c74713cd37aaf901bc18c9704dac6a89f06 /net | |
parent | 450bf05cbcbaa12b5bfbed1e34799a8867e504a4 (diff) | |
download | chromium_src-abf03a02e78533b36aa1a878ee1a2f1bfba13867.zip chromium_src-abf03a02e78533b36aa1a878ee1a2f1bfba13867.tar.gz chromium_src-abf03a02e78533b36aa1a878ee1a2f1bfba13867.tar.bz2 |
Do not call OnGetCookiesBlocked or OnSetCookieBlocked when cookies are
restricted by load flags. Only issue those callbacks in response to the
CookiePolicy's CanGetCookies / CanSetCookie methods.
R=eroman
BUG=37922
TEST=covered by url_request_unittest.cc
Review URL: http://codereview.chromium.org/893004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41393 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/url_request/url_request_http_job.cc | 14 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.cc | 7 |
2 files changed, 12 insertions, 9 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc index 15dafe6..8f2412e 100644 --- a/net/url_request/url_request_http_job.cc +++ b/net/url_request/url_request_http_job.cc @@ -437,9 +437,9 @@ void URLRequestHttpJob::StopCaching() { void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { // If the request was destroyed, then there is no more work to do. if (request_ && request_->delegate()) { - if (policy != net::OK) { + if (policy == net::ERR_ACCESS_DENIED) { request_->delegate()->OnGetCookiesBlocked(request_); - } else if (request_->context()->cookie_store()) { + } else if (policy == net::OK && request_->context()->cookie_store()) { net::CookieOptions options; options.set_include_httponly(); std::string cookies = @@ -462,10 +462,10 @@ void URLRequestHttpJob::OnCanGetCookiesCompleted(int policy) { void URLRequestHttpJob::OnCanSetCookieCompleted(int policy) { // If the request was destroyed, then there is no more work to do. if (request_ && request_->delegate()) { - if (policy != net::OK && - policy != net::OK_FOR_SESSION_ONLY) { + if (policy == net::ERR_ACCESS_DENIED) { request_->delegate()->OnSetCookieBlocked(request_); - } else if (request_->context()->cookie_store()) { + } else if ((policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) && + request_->context()->cookie_store()) { // OK to save the current response cookie now. net::CookieOptions options; options.set_include_httponly(); @@ -705,7 +705,7 @@ void URLRequestHttpJob::AddCookieHeaderAndStart() { int policy = net::OK; if (request_info_.load_flags & net::LOAD_DO_NOT_SEND_COOKIES) { - policy = net::ERR_ACCESS_DENIED; + policy = net::ERR_FAILED; } else if (request_->context()->cookie_policy()) { policy = request_->context()->cookie_policy()->CanGetCookies( request_->url(), @@ -751,7 +751,7 @@ void URLRequestHttpJob::SaveNextCookie() { int policy = net::OK; if (request_info_.load_flags & net::LOAD_DO_NOT_SAVE_COOKIES) { - policy = net::ERR_ACCESS_DENIED; + policy = net::ERR_FAILED; } else if (request_->context()->cookie_policy()) { policy = request_->context()->cookie_policy()->CanSetCookie( request_->url(), diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 16f4b3f..a1f0cf5e 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -1270,7 +1270,9 @@ TEST_F(URLRequestTest, DoNotSendCookies) { EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") == std::string::npos); - EXPECT_EQ(1, d.blocked_get_cookies_count()); + + // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookiesBlocked. + EXPECT_EQ(0, d.blocked_get_cookies_count()); EXPECT_EQ(0, d.blocked_set_cookie_count()); } } @@ -1305,8 +1307,9 @@ TEST_F(URLRequestTest, DoNotSaveCookies) { MessageLoop::current()->Run(); + // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookieBlocked. EXPECT_EQ(0, d.blocked_get_cookies_count()); - EXPECT_EQ(2, d.blocked_set_cookie_count()); + EXPECT_EQ(0, d.blocked_set_cookie_count()); } // Verify the cookies weren't saved or updated. |