| 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/port_util.h" | 9 #include "net/base/port_util.h" |
| 10 #include "net/ftp/ftp_auth_cache.h" | 10 #include "net/ftp/ftp_auth_cache.h" |
| 11 #include "net/http/transport_security_state.h" |
| 11 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 13 #include "net/url_request/url_request_context.h" |
| 12 #include "net/url_request/url_request_error_job.h" | 14 #include "net/url_request/url_request_error_job.h" |
| 13 #include "net/url_request/url_request_ftp_job.h" | 15 #include "net/url_request/url_request_ftp_job.h" |
| 14 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 15 | 17 |
| 16 namespace net { | 18 namespace net { |
| 17 | 19 |
| 18 FtpProtocolHandler::FtpProtocolHandler( | 20 FtpProtocolHandler::FtpProtocolHandler( |
| 19 FtpTransactionFactory* ftp_transaction_factory) | 21 FtpTransactionFactory* ftp_transaction_factory) |
| 20 : ftp_transaction_factory_(ftp_transaction_factory), | 22 : ftp_transaction_factory_(ftp_transaction_factory), |
| 21 ftp_auth_cache_(new FtpAuthCache) { | 23 ftp_auth_cache_(new FtpAuthCache) { |
| 22 DCHECK(ftp_transaction_factory_); | 24 DCHECK(ftp_transaction_factory_); |
| 23 } | 25 } |
| 24 | 26 |
| 25 FtpProtocolHandler::~FtpProtocolHandler() { | 27 FtpProtocolHandler::~FtpProtocolHandler() { |
| 26 } | 28 } |
| 27 | 29 |
| 28 URLRequestJob* FtpProtocolHandler::MaybeCreateJob( | 30 URLRequestJob* FtpProtocolHandler::MaybeCreateJob( |
| 29 URLRequest* request, NetworkDelegate* network_delegate) const { | 31 URLRequest* request, NetworkDelegate* network_delegate) const { |
| 30 DCHECK_EQ("ftp", request->url().scheme()); | 32 DCHECK_EQ("ftp", request->url().scheme()); |
| 31 | 33 |
| 32 if (!IsPortAllowedForScheme(request->url().EffectiveIntPort(), | 34 if (!IsPortAllowedForScheme(request->url().EffectiveIntPort(), |
| 33 request->url().scheme())) { | 35 request->url().scheme())) { |
| 34 return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT); | 36 return new URLRequestErrorJob(request, network_delegate, ERR_UNSAFE_PORT); |
| 35 } | 37 } |
| 36 | 38 |
| 39 TransportSecurityState* state = |
| 40 request->context()->transport_security_state(); |
| 41 if (state && state->ShouldUpgradeToSSL(request->url().host())) { |
| 42 return new URLRequestErrorJob(request, network_delegate, |
| 43 ERR_DISALLOWED_URL_SCHEME); |
| 44 } |
| 45 |
| 37 return new URLRequestFtpJob(request, | 46 return new URLRequestFtpJob(request, |
| 38 network_delegate, | 47 network_delegate, |
| 39 ftp_transaction_factory_, | 48 ftp_transaction_factory_, |
| 40 ftp_auth_cache_.get()); | 49 ftp_auth_cache_.get()); |
| 41 } | 50 } |
| 42 | 51 |
| 43 } // namespace net | 52 } // namespace net |
| OLD | NEW |