OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/ftp_directory_listing_response_delegate.h" | 5 #include "content/child/ftp_directory_listing_response_delegate.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/i18n/icu_encoding_detection.h" | 9 #include "base/i18n/icu_encoding_detection.h" |
10 #include "base/i18n/icu_string_conversions.h" | 10 #include "base/i18n/icu_string_conversions.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 loader_ = NULL; | 75 loader_ = NULL; |
76 } | 76 } |
77 | 77 |
78 void FtpDirectoryListingResponseDelegate::OnReceivedData(const char* data, | 78 void FtpDirectoryListingResponseDelegate::OnReceivedData(const char* data, |
79 int data_len) { | 79 int data_len) { |
80 buffer_.append(data, data_len); | 80 buffer_.append(data, data_len); |
81 } | 81 } |
82 | 82 |
83 void FtpDirectoryListingResponseDelegate::OnCompletedRequest() { | 83 void FtpDirectoryListingResponseDelegate::OnCompletedRequest() { |
84 std::vector<FtpDirectoryListingEntry> entries; | 84 std::vector<FtpDirectoryListingEntry> entries; |
85 int rv = net::ParseFtpDirectoryListing(buffer_, base::Time::Now(), &entries); | 85 int rv = -1; |
| 86 #if !defined(DISABLE_FTP_SUPPORT) |
| 87 rv = net::ParseFtpDirectoryListing(buffer_, base::Time::Now(), &entries); |
| 88 #endif |
86 if (rv != net::OK) { | 89 if (rv != net::OK) { |
87 SendDataToClient("<script>onListingParsingError();</script>\n"); | 90 SendDataToClient("<script>onListingParsingError();</script>\n"); |
88 return; | 91 return; |
89 } | 92 } |
90 for (size_t i = 0; i < entries.size(); i++) { | 93 for (size_t i = 0; i < entries.size(); i++) { |
91 const FtpDirectoryListingEntry& entry = entries[i]; | 94 const FtpDirectoryListingEntry& entry = entries[i]; |
92 | 95 |
93 // Skip the current and parent directory entries in the listing. Our header | 96 // Skip the current and parent directory entries in the listing. Our header |
94 // always includes them. | 97 // always includes them. |
95 if (EqualsASCII(entry.name, ".") || EqualsASCII(entry.name, "..")) | 98 if (EqualsASCII(entry.name, ".") || EqualsASCII(entry.name, "..")) |
(...skipping 24 matching lines...) Expand all Loading... |
120 } | 123 } |
121 } | 124 } |
122 | 125 |
123 void FtpDirectoryListingResponseDelegate::SendDataToClient( | 126 void FtpDirectoryListingResponseDelegate::SendDataToClient( |
124 const std::string& data) { | 127 const std::string& data) { |
125 if (client_) | 128 if (client_) |
126 client_->didReceiveData(loader_, data.data(), data.length(), -1); | 129 client_->didReceiveData(loader_, data.data(), data.length(), -1); |
127 } | 130 } |
128 | 131 |
129 } // namespace content | 132 } // namespace content |
OLD | NEW |