| OLD | NEW |
| 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/ftp_protocol_handler.h" | 5 #include "net/url_request/ftp_protocol_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
| 11 #include "net/url_request/url_request_error_job.h" | 11 #include "net/url_request/url_request_error_job.h" |
| 12 #include "net/url_request/url_request_ftp_job.h" | 12 #include "net/url_request/url_request_ftp_job.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 FtpProtocolHandler::FtpProtocolHandler( | 17 FtpProtocolHandler::FtpProtocolHandler( |
| 18 FtpTransactionFactory* ftp_transaction_factory) | 18 FtpTransactionFactory* ftp_transaction_factory, |
| 19 : ftp_transaction_factory_(ftp_transaction_factory) { | 19 FtpAuthCache* ftp_auth_cache) |
| 20 : ftp_transaction_factory_(ftp_transaction_factory), |
| 21 ftp_auth_cache_(ftp_auth_cache) { |
| 20 DCHECK(ftp_transaction_factory_); | 22 DCHECK(ftp_transaction_factory_); |
| 23 DCHECK(ftp_auth_cache_); |
| 21 } | 24 } |
| 22 | 25 |
| 23 URLRequestJob* FtpProtocolHandler::MaybeCreateJob( | 26 URLRequestJob* FtpProtocolHandler::MaybeCreateJob( |
| 24 URLRequest* request, NetworkDelegate* network_delegate) const { | 27 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 25 int port = request->url().IntPort(); | 28 int port = request->url().IntPort(); |
| 26 if (request->url().has_port() && | 29 if (request->url().has_port() && |
| 27 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { | 30 !IsPortAllowedByFtp(port) && !IsPortAllowedByOverride(port)) { |
| 28 return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT); | 31 return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT); |
| 29 } | 32 } |
| 30 | 33 |
| 31 return new URLRequestFtpJob(request, | 34 return new URLRequestFtpJob(request, |
| 32 network_delegate, | 35 network_delegate, |
| 33 ftp_transaction_factory_, | 36 ftp_transaction_factory_, |
| 34 &ftp_auth_cache_); | 37 ftp_auth_cache_); |
| 35 } | 38 } |
| 36 | 39 |
| 37 } // namespace net | 40 } // namespace net |
| OLD | NEW |