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 #ifdef OS_WIN | 10 #ifdef OS_WIN |
11 #include <windows.h> | 11 #include <windows.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
17 #include "net/base/escape.h" | 17 #include "net/base/escape.h" |
18 | 18 |
19 struct addrinfo; | 19 struct addrinfo; |
20 class FilePath; | 20 class FilePath; |
21 class GURL; | 21 class GURL; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class Time; | 24 class Time; |
25 } | 25 } |
26 | 26 |
| 27 namespace url_canon { |
| 28 struct CanonHostInfo; |
| 29 } |
| 30 |
27 namespace url_parse { | 31 namespace url_parse { |
28 struct Parsed; | 32 struct Parsed; |
29 } | 33 } |
30 | 34 |
31 namespace net { | 35 namespace net { |
32 | 36 |
33 // Given the full path to a file name, creates a file: URL. The returned URL | 37 // Given the full path to a file name, creates a file: URL. The returned URL |
34 // may not be valid if the input is malformed. | 38 // may not be valid if the input is malformed. |
35 GURL FilePathToFileURL(const FilePath& path); | 39 GURL FilePathToFileURL(const FilePath& path); |
36 | 40 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // human-readable form (Unicode) ONLY when each component of |host| is | 133 // human-readable form (Unicode) ONLY when each component of |host| is |
130 // regarded as 'comprehensible'. Scipt-mixing is not allowed except that | 134 // regarded as 'comprehensible'. Scipt-mixing is not allowed except that |
131 // Latin letters in the ASCII range can be mixed with a limited set of | 135 // Latin letters in the ASCII range can be mixed with a limited set of |
132 // script-language pairs (currently Han, Kana and Hangul for zh,ja and ko). | 136 // script-language pairs (currently Han, Kana and Hangul for zh,ja and ko). |
133 // When |languages| is empty, even that mixing is not allowed. | 137 // When |languages| is empty, even that mixing is not allowed. |
134 void IDNToUnicode(const char* host, | 138 void IDNToUnicode(const char* host, |
135 int host_len, | 139 int host_len, |
136 const std::wstring& languages, | 140 const std::wstring& languages, |
137 std::wstring* out); | 141 std::wstring* out); |
138 | 142 |
139 // Canonicalizes |host| and returns it. If |is_ip_address| is non-NULL, sets it | 143 // Canonicalizes |host| and returns it. Also fills |host_info| with |
140 // to true if |host| is an IP address. | 144 // IP address information. |host_info| must not be NULL. |
141 std::string CanonicalizeHost(const std::string& host, bool* is_ip_address); | 145 std::string CanonicalizeHost(const std::string& host, |
142 std::string CanonicalizeHost(const std::wstring& host, bool* is_ip_address); | 146 url_canon::CanonHostInfo* host_info); |
| 147 std::string CanonicalizeHost(const std::wstring& host, |
| 148 url_canon::CanonHostInfo* host_info); |
143 | 149 |
144 // Call these functions to get the html for a directory listing. | 150 // Call these functions to get the html for a directory listing. |
145 // They will pass non-7bit-ascii characters unescaped, allowing | 151 // They will pass non-7bit-ascii characters unescaped, allowing |
146 // the browser to interpret the encoding (utf8, etc). | 152 // the browser to interpret the encoding (utf8, etc). |
147 std::string GetDirectoryListingHeader(const std::string& title); | 153 std::string GetDirectoryListingHeader(const std::string& title); |
148 std::string GetDirectoryListingEntry(const std::string& name, bool is_dir, | 154 std::string GetDirectoryListingEntry(const std::string& name, bool is_dir, |
149 int64 size, const base::Time& modified); | 155 int64 size, const base::Time& modified); |
150 | 156 |
151 // If text starts with "www." it is removed, otherwise text is returned | 157 // If text starts with "www." it is removed, otherwise text is returned |
152 // unmodified. | 158 // unmodified. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Creates a string representation of |url| for display to the user. | 208 // Creates a string representation of |url| for display to the user. |
203 // This is a shorthand of the above function with omit_username_password=true, | 209 // This is a shorthand of the above function with omit_username_password=true, |
204 // unescape=SPACES, new_parsed=NULL, and prefix_end=NULL. | 210 // unescape=SPACES, new_parsed=NULL, and prefix_end=NULL. |
205 inline std::wstring FormatUrl(const GURL& url, const std::wstring& languages) { | 211 inline std::wstring FormatUrl(const GURL& url, const std::wstring& languages) { |
206 return FormatUrl(url, languages, true, UnescapeRule::SPACES, NULL, NULL); | 212 return FormatUrl(url, languages, true, UnescapeRule::SPACES, NULL, NULL); |
207 } | 213 } |
208 | 214 |
209 } // namespace net | 215 } // namespace net |
210 | 216 |
211 #endif // NET_BASE_NET_UTIL_H__ | 217 #endif // NET_BASE_NET_UTIL_H__ |
OLD | NEW |