| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_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" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/sys_string_conversions.h" | 13 #include "base/sys_string_conversions.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "net/base/escape.h" | 16 #include "net/base/escape.h" |
| 17 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
| 18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 19 #include "net/ftp/ftp_directory_listing_parser.h" | 19 #include "net/ftp/ftp_directory_listing_parser.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" |
| 22 #include "webkit/glue/weburlresponse_extradata_impl.h" |
| 22 | 23 |
| 23 using net::FtpDirectoryListingEntry; | 24 using net::FtpDirectoryListingEntry; |
| 24 | 25 |
| 25 using WebKit::WebURLLoader; | 26 using WebKit::WebURLLoader; |
| 26 using WebKit::WebURLLoaderClient; | 27 using WebKit::WebURLLoaderClient; |
| 27 using WebKit::WebURLResponse; | 28 using WebKit::WebURLResponse; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 string16 ConvertPathToUTF16(const std::string& path) { | 32 string16 ConvertPathToUTF16(const std::string& path) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 53 } // namespace | 54 } // namespace |
| 54 | 55 |
| 55 namespace webkit_glue { | 56 namespace webkit_glue { |
| 56 | 57 |
| 57 FtpDirectoryListingResponseDelegate::FtpDirectoryListingResponseDelegate( | 58 FtpDirectoryListingResponseDelegate::FtpDirectoryListingResponseDelegate( |
| 58 WebURLLoaderClient* client, | 59 WebURLLoaderClient* client, |
| 59 WebURLLoader* loader, | 60 WebURLLoader* loader, |
| 60 const WebURLResponse& response) | 61 const WebURLResponse& response) |
| 61 : client_(client), | 62 : client_(client), |
| 62 loader_(loader) { | 63 loader_(loader) { |
| 64 if (response.extraData()) { |
| 65 // extraData can be NULL during tests. |
| 66 WebURLResponseExtraDataImpl* extra_data = |
| 67 static_cast<WebURLResponseExtraDataImpl*>(response.extraData()); |
| 68 extra_data->set_is_ftp_directory_listing(true); |
| 69 } |
| 63 Init(response.url()); | 70 Init(response.url()); |
| 64 } | 71 } |
| 65 | 72 |
| 66 void FtpDirectoryListingResponseDelegate::OnReceivedData(const char* data, | 73 void FtpDirectoryListingResponseDelegate::OnReceivedData(const char* data, |
| 67 int data_len) { | 74 int data_len) { |
| 68 buffer_.append(data, data_len); | 75 buffer_.append(data, data_len); |
| 69 } | 76 } |
| 70 | 77 |
| 71 void FtpDirectoryListingResponseDelegate::OnCompletedRequest() { | 78 void FtpDirectoryListingResponseDelegate::OnCompletedRequest() { |
| 72 std::vector<FtpDirectoryListingEntry> entries; | 79 std::vector<FtpDirectoryListingEntry> entries; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); | 114 ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); |
| 108 } | 115 } |
| 109 } | 116 } |
| 110 | 117 |
| 111 void FtpDirectoryListingResponseDelegate::SendDataToClient( | 118 void FtpDirectoryListingResponseDelegate::SendDataToClient( |
| 112 const std::string& data) { | 119 const std::string& data) { |
| 113 client_->didReceiveData(loader_, data.data(), data.length(), -1); | 120 client_->didReceiveData(loader_, data.data(), data.length(), -1); |
| 114 } | 121 } |
| 115 | 122 |
| 116 } // namespace webkit_glue | 123 } // namespace webkit_glue |
| OLD | NEW |