summaryrefslogtreecommitdiffstats
path: root/net/ftp/ftp_network_transaction.cc
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 18:44:58 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 18:44:58 +0000
commitf3cf980ca36d5b557b626d1bba4db6ded3ab2b77 (patch)
tree74028618ccef405480ff6da6a9d0d8c80a8fda7f /net/ftp/ftp_network_transaction.cc
parent7f5969dda833a858bc946ca59ba0a9afbee2bc89 (diff)
downloadchromium_src-f3cf980ca36d5b557b626d1bba4db6ded3ab2b77.zip
chromium_src-f3cf980ca36d5b557b626d1bba4db6ded3ab2b77.tar.gz
chromium_src-f3cf980ca36d5b557b626d1bba4db6ded3ab2b77.tar.bz2
Use AuthCredentials throughout the network stack instead of username/password.
This is a refactor only - no behavior change should happen. Review URL: http://codereview.chromium.org/8340026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/ftp/ftp_network_transaction.cc')
-rw-r--r--net/ftp/ftp_network_transaction.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index d448ad3..24ab0f9 100644
--- a/net/ftp/ftp_network_transaction.cc
+++ b/net/ftp/ftp_network_transaction.cc
@@ -248,10 +248,13 @@ int FtpNetworkTransaction::Start(const FtpRequestInfo* request_info,
request_ = request_info;
if (request_->url.has_username()) {
- GetIdentityFromURL(request_->url, &username_, &password_);
+ string16 username;
+ string16 password;
+ GetIdentityFromURL(request_->url, &username, &password);
+ credentials_.Set(username, password);
} else {
- username_ = ASCIIToUTF16("anonymous");
- password_ = ASCIIToUTF16("chrome@example.com");
+ credentials_.Set(ASCIIToUTF16("anonymous"),
+ ASCIIToUTF16("chrome@example.com"));
}
DetectTypecode();
@@ -263,13 +266,11 @@ int FtpNetworkTransaction::Start(const FtpRequestInfo* request_info,
return rv;
}
-int FtpNetworkTransaction::RestartWithAuth(const string16& username,
- const string16& password,
+int FtpNetworkTransaction::RestartWithAuth(const AuthCredentials& credentials,
OldCompletionCallback* callback) {
ResetStateForRestart();
- username_ = username;
- password_ = password;
+ credentials_ = credentials;
next_state_ = STATE_CTRL_RESOLVE_HOST;
int rv = DoLoop(OK);
@@ -668,8 +669,10 @@ int FtpNetworkTransaction::DoCtrlReadComplete(int result) {
// Some servers (for example Pure-FTPd) apparently close the control
// connection when anonymous login is not permitted. For more details
// see http://crbug.com/25023.
- if (command_sent_ == COMMAND_USER && username_ == ASCIIToUTF16("anonymous"))
+ if (command_sent_ == COMMAND_USER &&
+ credentials_.username() == ASCIIToUTF16("anonymous")) {
response_.needs_auth = true;
+ }
return Stop(ERR_EMPTY_RESPONSE);
}
if (result < 0)
@@ -715,7 +718,7 @@ int FtpNetworkTransaction::DoCtrlWriteComplete(int result) {
// USER Command.
int FtpNetworkTransaction::DoCtrlWriteUSER() {
- std::string command = "USER " + UTF16ToUTF8(username_);
+ std::string command = "USER " + UTF16ToUTF8(credentials_.username());
if (!IsValidFTPCommandString(command))
return Stop(ERR_MALFORMED_IDENTITY);
@@ -746,7 +749,7 @@ int FtpNetworkTransaction::ProcessResponseUSER(
// PASS command.
int FtpNetworkTransaction::DoCtrlWritePASS() {
- std::string command = "PASS " + UTF16ToUTF8(password_);
+ std::string command = "PASS " + UTF16ToUTF8(credentials_.password());
if (!IsValidFTPCommandString(command))
return Stop(ERR_MALFORMED_IDENTITY);