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

Unified Diff: net/ftp/ftp_network_transaction.cc

Issue 8340026: Use AuthCredentials throughout the network stack instead of username/password. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/ftp/ftp_network_transaction.h ('k') | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_network_transaction.cc
diff --git a/net/ftp/ftp_network_transaction.cc b/net/ftp/ftp_network_transaction.cc
index d448ad370676b8a5e776c9d12a89753847a0bd43..24ab0f97687373866d500a761f6478550a26de8f 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);
« no previous file with comments | « net/ftp/ftp_network_transaction.h ('k') | net/ftp/ftp_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698