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" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 bool is_directory = (entry.type == FtpDirectoryListingEntry::DIRECTORY); | 86 bool is_directory = (entry.type == FtpDirectoryListingEntry::DIRECTORY); |
87 int64 size = entry.size; | 87 int64 size = entry.size; |
88 if (entry.type != FtpDirectoryListingEntry::FILE) | 88 if (entry.type != FtpDirectoryListingEntry::FILE) |
89 size = 0; | 89 size = 0; |
90 SendDataToClient(net::GetDirectoryListingEntry( | 90 SendDataToClient(net::GetDirectoryListingEntry( |
91 entry.name, entry.raw_name, is_directory, size, entry.last_modified)); | 91 entry.name, entry.raw_name, is_directory, size, entry.last_modified)); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { | 95 void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) { |
96 UnescapeRule::Type unescape_rules = UnescapeRule::SPACES | | 96 net::UnescapeRule::Type unescape_rules = net::UnescapeRule::SPACES | |
97 UnescapeRule::URL_SPECIAL_CHARS; | 97 net::UnescapeRule::URL_SPECIAL_CHARS; |
98 std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), | 98 std::string unescaped_path = net::UnescapeURLComponent(response_url.path(), |
99 unescape_rules); | 99 unescape_rules); |
100 SendDataToClient(net::GetDirectoryListingHeader( | 100 SendDataToClient(net::GetDirectoryListingHeader( |
101 ConvertPathToUTF16(unescaped_path))); | 101 ConvertPathToUTF16(unescaped_path))); |
102 | 102 |
103 // If this isn't top level directory (i.e. the path isn't "/",) | 103 // If this isn't top level directory (i.e. the path isn't "/",) |
104 // add a link to the parent directory. | 104 // add a link to the parent directory. |
105 if (response_url.path().length() > 1) { | 105 if (response_url.path().length() > 1) { |
106 SendDataToClient(net::GetDirectoryListingEntry( | 106 SendDataToClient(net::GetDirectoryListingEntry( |
107 ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); | 107 ASCIIToUTF16(".."), std::string(), false, 0, base::Time())); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 void FtpDirectoryListingResponseDelegate::SendDataToClient( | 111 void FtpDirectoryListingResponseDelegate::SendDataToClient( |
112 const std::string& data) { | 112 const std::string& data) { |
113 client_->didReceiveData(loader_, data.data(), data.length(), -1); | 113 client_->didReceiveData(loader_, data.data(), data.length(), -1); |
114 } | 114 } |
115 | 115 |
116 } // namespace webkit_glue | 116 } // namespace webkit_glue |
OLD | NEW |