Chromium Code Reviews| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 bool is_directory = (entry.type == FtpDirectoryListingEntry::DIRECTORY); | 104 bool is_directory = (entry.type == FtpDirectoryListingEntry::DIRECTORY); |
| 105 int64_t size = entry.size; | 105 int64_t size = entry.size; |
| 106 if (entry.type != FtpDirectoryListingEntry::FILE) | 106 if (entry.type != FtpDirectoryListingEntry::FILE) |
| 107 size = 0; | 107 size = 0; |
| 108 SendDataToClient(net::GetDirectoryListingEntry( | 108 SendDataToClient(net::GetDirectoryListingEntry( |
| 109 entry.name, entry.raw_name, is_directory, size, entry.last_modified)); | 109 entry.name, entry.raw_name, is_directory, size, entry.last_modified)); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { | 113 void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { |
| 114 net::UnescapeRule::Type unescape_rules = net::UnescapeRule::SPACES | | 114 net::UnescapeRule::Type unescape_rules = |
| 115 net::UnescapeRule::URL_SPECIAL_CHARS; | 115 net::UnescapeRule::SPACES | |
| 116 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS; | |
|
mmenke
2016/03/23 16:49:00
Note that this only affects display of the "Index
| |
| 116 std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), | 117 std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), |
| 117 unescape_rules); | 118 unescape_rules); |
| 118 SendDataToClient(net::GetDirectoryListingHeader( | 119 SendDataToClient(net::GetDirectoryListingHeader( |
| 119 ConvertPathToUTF16(unescaped_path))); | 120 ConvertPathToUTF16(unescaped_path))); |
| 120 | 121 |
| 121 // If this isn't top level directory (i.e. the path isn't "/",) | 122 // If this isn't top level directory (i.e. the path isn't "/",) |
| 122 // add a link to the parent directory. | 123 // add a link to the parent directory. |
| 123 if (response_url.path().length() > 1) { | 124 if (response_url.path().length() > 1) { |
| 124 SendDataToClient(net::GetDirectoryListingEntry( | 125 SendDataToClient(net::GetDirectoryListingEntry( |
| 125 base::ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); | 126 base::ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 void FtpDirectoryListingResponseDelegate::SendDataToClient( | 130 void FtpDirectoryListingResponseDelegate::SendDataToClient( |
| 130 const std::string& data) { | 131 const std::string& data) { |
| 131 if (client_) | 132 if (client_) |
| 132 client_->didReceiveData(loader_, data.data(), data.length(), -1); | 133 client_->didReceiveData(loader_, data.data(), data.length(), -1); |
| 133 } | 134 } |
| 134 | 135 |
| 135 } // namespace content | 136 } // namespace content |
| OLD | NEW |