OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef NET_BASE_NET_UTIL_H__ | 5 #ifndef NET_BASE_NET_UTIL_H__ |
6 #define NET_BASE_NET_UTIL_H__ | 6 #define NET_BASE_NET_UTIL_H__ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #ifdef OS_WIN | 12 #ifdef OS_WIN |
13 #include <windows.h> | 13 #include <windows.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "googleurl/src/url_canon.h" | 17 #include "googleurl/src/url_canon.h" |
18 #include "googleurl/src/url_parse.h" | 18 #include "googleurl/src/url_parse.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
| 22 namespace base { |
| 23 class Time; |
| 24 } |
| 25 |
22 namespace net { | 26 namespace net { |
23 | 27 |
24 // Given the full path to a file name, creates a file: URL. The returned URL | 28 // Given the full path to a file name, creates a file: URL. The returned URL |
25 // may not be valid if the input is malformed. | 29 // may not be valid if the input is malformed. |
26 GURL FilePathToFileURL(const std::wstring& file_path); | 30 GURL FilePathToFileURL(const std::wstring& file_path); |
27 | 31 |
28 // Converts a file: URL back to a filename that can be passed to the OS. The | 32 // Converts a file: URL back to a filename that can be passed to the OS. The |
29 // file URL must be well-formed (GURL::is_valid() must return true); we don't | 33 // file URL must be well-formed (GURL::is_valid() must return true); we don't |
30 // handle degenerate cases here. Returns true on success, false if it isn't a | 34 // handle degenerate cases here. Returns true on success, false if it isn't a |
31 // valid file URL. On failure, *file_path will be empty. | 35 // valid file URL. On failure, *file_path will be empty. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void IDNToUnicode(const char* host, | 92 void IDNToUnicode(const char* host, |
89 int host_len, | 93 int host_len, |
90 const std::wstring& languages, | 94 const std::wstring& languages, |
91 std::wstring* out); | 95 std::wstring* out); |
92 | 96 |
93 // Canonicalizes |host| and returns it. If |is_ip_address| is non-NULL, sets it | 97 // Canonicalizes |host| and returns it. If |is_ip_address| is non-NULL, sets it |
94 // to true if |host| is an IP address. | 98 // to true if |host| is an IP address. |
95 std::string CanonicalizeHost(const std::string& host, bool* is_ip_address); | 99 std::string CanonicalizeHost(const std::string& host, bool* is_ip_address); |
96 std::string CanonicalizeHost(const std::wstring& host, bool* is_ip_address); | 100 std::string CanonicalizeHost(const std::wstring& host, bool* is_ip_address); |
97 | 101 |
98 #ifdef OS_WIN | |
99 // TODO: Port GetDirectoryListingEntry for OSX and linux. | |
100 // Call these functions to get the html for a directory listing. | 102 // Call these functions to get the html for a directory listing. |
101 // They will pass non-7bit-ascii characters unescaped, allowing | 103 // They will pass non-7bit-ascii characters unescaped, allowing |
102 // the browser to interpret the encoding (utf8, etc). | 104 // the browser to interpret the encoding (utf8, etc). |
103 std::string GetDirectoryListingHeader(const std::string& title); | 105 std::string GetDirectoryListingHeader(const std::string& title); |
104 std::string GetDirectoryListingEntry(const std::string& name, DWORD attrib, | 106 std::string GetDirectoryListingEntry(const std::string& name, bool is_dir, |
105 int64 size, const FILETIME* modified); | 107 int64 size, const base::Time& modified); |
106 #endif | |
107 | 108 |
108 // If text starts with "www." it is removed, otherwise text is returned | 109 // If text starts with "www." it is removed, otherwise text is returned |
109 // unmodified. | 110 // unmodified. |
110 std::wstring StripWWW(const std::wstring& text); | 111 std::wstring StripWWW(const std::wstring& text); |
111 | 112 |
112 // Gets the filename from the raw Content-Disposition header (as read from the | 113 // Gets the filename from the raw Content-Disposition header (as read from the |
113 // network). Otherwise uses the last path component name or hostname from | 114 // network). Otherwise uses the last path component name or hostname from |
114 // |url|. Note: it's possible for the suggested filename to be empty (e.g., | 115 // |url|. Note: it's possible for the suggested filename to be empty (e.g., |
115 // file:/// or view-cache:). | 116 // file:/// or view-cache:). |
116 std::wstring GetSuggestedFilename(const GURL& url, | 117 std::wstring GetSuggestedFilename(const GURL& url, |
(...skipping 14 matching lines...) Expand all Loading... |
131 // restricted. | 132 // restricted. |
132 bool IsPortAllowedByFtp(int port); | 133 bool IsPortAllowedByFtp(int port); |
133 | 134 |
134 // Set socket to non-blocking mode | 135 // Set socket to non-blocking mode |
135 int SetNonBlocking(int fd); | 136 int SetNonBlocking(int fd); |
136 | 137 |
137 } // namespace net | 138 } // namespace net |
138 | 139 |
139 #endif // NET_BASE_NET_UTIL_H__ | 140 #endif // NET_BASE_NET_UTIL_H__ |
140 | 141 |
OLD | NEW |