| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "webkit/glue/ftp_directory_listing_response_delegate.h" | 5 #include "webkit/glue/ftp_directory_listing_response_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/i18n/icu_string_conversions.h" | 9 #include "base/i18n/icu_string_conversions.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // can be other use cases. | 31 // can be other use cases. |
| 32 std::string DetectEncoding(const std::string& text) { | 32 std::string DetectEncoding(const std::string& text) { |
| 33 if (IsStringASCII(text)) | 33 if (IsStringASCII(text)) |
| 34 return std::string(); | 34 return std::string(); |
| 35 UErrorCode status = U_ZERO_ERROR; | 35 UErrorCode status = U_ZERO_ERROR; |
| 36 UCharsetDetector* detector = ucsdet_open(&status); | 36 UCharsetDetector* detector = ucsdet_open(&status); |
| 37 ucsdet_setText(detector, text.data(), static_cast<int32_t>(text.length()), | 37 ucsdet_setText(detector, text.data(), static_cast<int32_t>(text.length()), |
| 38 &status); | 38 &status); |
| 39 const UCharsetMatch* match = ucsdet_detect(detector, &status); | 39 const UCharsetMatch* match = ucsdet_detect(detector, &status); |
| 40 const char* encoding = ucsdet_getName(match, &status); | 40 const char* encoding = ucsdet_getName(match, &status); |
| 41 ucsdet_close(detector); |
| 41 // Should we check the quality of the match? A rather arbitrary number is | 42 // Should we check the quality of the match? A rather arbitrary number is |
| 42 // assigned by ICU and it's hard to come up with a lower limit. | 43 // assigned by ICU and it's hard to come up with a lower limit. |
| 43 if (U_FAILURE(status)) | 44 if (U_FAILURE(status)) |
| 44 return std::string(); | 45 return std::string(); |
| 45 return encoding; | 46 return encoding; |
| 46 } | 47 } |
| 47 | 48 |
| 48 string16 RawByteSequenceToFilename(const char* raw_filename, | 49 string16 RawByteSequenceToFilename(const char* raw_filename, |
| 49 const std::string& encoding) { | 50 const std::string& encoding) { |
| 50 if (encoding.empty()) | 51 if (encoding.empty()) |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 250 |
| 250 void FtpDirectoryListingResponseDelegate::SendResponseBufferToClient() { | 251 void FtpDirectoryListingResponseDelegate::SendResponseBufferToClient() { |
| 251 if (!response_buffer_.empty()) { | 252 if (!response_buffer_.empty()) { |
| 252 client_->didReceiveData(loader_, response_buffer_.data(), | 253 client_->didReceiveData(loader_, response_buffer_.data(), |
| 253 response_buffer_.length()); | 254 response_buffer_.length()); |
| 254 response_buffer_.clear(); | 255 response_buffer_.clear(); |
| 255 } | 256 } |
| 256 } | 257 } |
| 257 | 258 |
| 258 } // namespace webkit_glue | 259 } // namespace webkit_glue |
| OLD | NEW |