diff options
author | ddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-29 22:24:18 +0000 |
---|---|---|
committer | ddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-29 22:24:18 +0000 |
commit | 83e875da32de6614774f976b49bc2fd42997f433 (patch) | |
tree | ae8dbb8ab3541837fb480d62844d8b4c4f6b25f8 /net/url_request/url_request.cc | |
parent | 94fb7aec260bbb23ec2c63561289c933c8ea7eb2 (diff) | |
download | chromium_src-83e875da32de6614774f976b49bc2fd42997f433.zip chromium_src-83e875da32de6614774f976b49bc2fd42997f433.tar.gz chromium_src-83e875da32de6614774f976b49bc2fd42997f433.tar.bz2 |
Revert 103360 - NetworkDelegate::OnAuthRequired can set authentication or cancel, in addition to observing.
TBR=ananta@chromium.org
BUG=32056
TEST=net_unittests
Review URL: http://codereview.chromium.org/8037038
TBR=cbentzel@chromium.org
Review URL: http://codereview.chromium.org/8082010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/url_request.cc')
-rw-r--r-- | net/url_request/url_request.cc | 71 |
1 files changed, 15 insertions, 56 deletions
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index acc085e..41d2362 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -4,14 +4,11 @@ #include "net/url_request/url_request.h" -#include "base/bind.h" -#include "base/callback.h" #include "base/compiler_specific.h" #include "base/memory/singleton.h" #include "base/message_loop.h" #include "base/metrics/stats_counters.h" #include "base/synchronization/lock.h" -#include "net/base/auth.h" #include "net/base/host_port_pair.h" #include "net/base/load_flags.h" #include "net/base/net_errors.h" @@ -433,7 +430,8 @@ void URLRequest::BeforeRequestComplete(int error) { DCHECK(!job_); DCHECK_NE(ERR_IO_PENDING, error); - SetUnblockedOnDelegate(); + if (blocked_on_delegate_) + SetUnblockedOnDelegate(); if (error != OK) { net_log_.AddEvent(NetLog::TYPE_CANCELLED, make_scoped_refptr(new NetLogStringParameter("source", "delegate"))); @@ -768,57 +766,20 @@ void URLRequest::SetUserData(const void* key, UserData* data) { } void URLRequest::NotifyAuthRequired(AuthChallengeInfo* auth_info) { - NetworkDelegate::AuthRequiredResponse rv = - NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; - auth_info_ = auth_info; - if (context_ && context_->network_delegate()) { - rv = context_->network_delegate()->NotifyAuthRequired( - this, - *auth_info, - base::Bind(&URLRequest::NotifyAuthRequiredComplete, - base::Unretained(this)), - &auth_credentials_); - } - - if (rv == NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING) { - SetBlockedOnDelegate(); - } else { - NotifyAuthRequiredComplete(rv); - } -} + // TODO(battre): We could simulate a redirection there as follows: + // if (context_ && context_->network_delegate()) { + // // We simulate a redirection. + // context_->network_delegate()->NotifyBeforeRedirect(this, url()); + //} + // This fixes URLRequestTestHTTP.BasicAuth but not + // URLRequestTestHTTP.BasicAuthWithCookies. In both cases we observe a + // call sequence of OnBeforeSendHeaders -> OnSendHeaders -> + // OnBeforeSendHeaders. + if (context_ && context_->network_delegate()) + context_->network_delegate()->NotifyAuthRequired(this, *auth_info); -void URLRequest::NotifyAuthRequiredComplete( - NetworkDelegate::AuthRequiredResponse result) { - SetUnblockedOnDelegate(); - - // NotifyAuthRequired may be called multiple times, such as - // when an authentication attempt fails. Clear out the data - // so it can be reset on another round. - AuthCredentials credentials = auth_credentials_; - auth_credentials_ = AuthCredentials(); - scoped_refptr<AuthChallengeInfo> auth_info; - auth_info.swap(auth_info_); - - switch (result) { - case NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION: - // Defer to the URLRequest::Delegate, since the NetworkDelegate - // didn't take an action. - if (delegate_) - delegate_->OnAuthRequired(this, auth_info.get()); - break; - - case NetworkDelegate::AUTH_REQUIRED_RESPONSE_SET_AUTH: - SetAuth(credentials.username, credentials.password); - break; - - case NetworkDelegate::AUTH_REQUIRED_RESPONSE_CANCEL_AUTH: - CancelAuth(); - break; - - case NetworkDelegate::AUTH_REQUIRED_RESPONSE_IO_PENDING: - NOTREACHED(); - break; - } + if (delegate_) + delegate_->OnAuthRequired(this, auth_info); } void URLRequest::NotifyCertificateRequested( @@ -876,8 +837,6 @@ void URLRequest::SetBlockedOnDelegate() { } void URLRequest::SetUnblockedOnDelegate() { - if (!blocked_on_delegate_) - return; blocked_on_delegate_ = false; load_state_param_.clear(); net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |