| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 size = 0; | 108 size = 0; |
| 109 SendDataToClient(net::GetDirectoryListingEntry( | 109 SendDataToClient(net::GetDirectoryListingEntry( |
| 110 entry.name, entry.raw_name, is_directory, size, entry.last_modified)); | 110 entry.name, entry.raw_name, is_directory, size, entry.last_modified)); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { | 114 void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { |
| 115 net::UnescapeRule::Type unescape_rules = | 115 net::UnescapeRule::Type unescape_rules = |
| 116 net::UnescapeRule::SPACES | | 116 net::UnescapeRule::SPACES | |
| 117 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS; | 117 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS; |
| 118 std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), | 118 std::string unescaped_path = net::UnescapeURLComponent( |
| 119 unescape_rules); | 119 response_url.path().as_string(), unescape_rules); |
| 120 SendDataToClient(net::GetDirectoryListingHeader( | 120 SendDataToClient(net::GetDirectoryListingHeader( |
| 121 ConvertPathToUTF16(unescaped_path))); | 121 ConvertPathToUTF16(unescaped_path))); |
| 122 | 122 |
| 123 // If this isn't top level directory (i.e. the path isn't "/",) | 123 // If this isn't top level directory (i.e. the path isn't "/",) |
| 124 // add a link to the parent directory. | 124 // add a link to the parent directory. |
| 125 if (response_url.path().length() > 1) { | 125 if (response_url.path().length() > 1) { |
| 126 SendDataToClient(net::GetDirectoryListingEntry( | 126 SendDataToClient(net::GetDirectoryListingEntry( |
| 127 base::ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); | 127 base::ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 void FtpDirectoryListingResponseDelegate::SendDataToClient( | 131 void FtpDirectoryListingResponseDelegate::SendDataToClient( |
| 132 const std::string& data) { | 132 const std::string& data) { |
| 133 if (client_) { | 133 if (client_) { |
| 134 client_->didReceiveData(loader_, data.data(), data.length(), -1, | 134 client_->didReceiveData(loader_, data.data(), data.length(), -1, |
| 135 data.length()); | 135 data.length()); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 } // namespace content | 139 } // namespace content |
| OLD | NEW |