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