OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 // Returns either the host from |url|, or, if the host is empty, the full spec. | 147 // Returns either the host from |url|, or, if the host is empty, the full spec. |
148 NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url); | 148 NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url); |
149 | 149 |
150 // Converts the given host name to unicode characters. This can be called for | 150 // Converts the given host name to unicode characters. This can be called for |
151 // any host name, if the input is not IDN or is invalid in some way, we'll just | 151 // any host name, if the input is not IDN or is invalid in some way, we'll just |
152 // return the ASCII source so it is still usable. | 152 // return the ASCII source so it is still usable. |
153 // | 153 // |
154 // The input should be the canonicalized ASCII host name from GURL. This | 154 // The input should be the canonicalized ASCII host name from GURL. This |
155 // function does NOT accept UTF-8! | 155 // function does NOT accept UTF-8! |
156 // | 156 // |languages| is not used any more and will be removed. |
157 // |languages| is a comma separated list of ISO 639 language codes. It | |
158 // is used to determine whether a hostname is 'comprehensible' to a user | |
159 // who understands languages listed. |host| will be converted to a | |
160 // human-readable form (Unicode) ONLY when each component of |host| is | |
161 // regarded as 'comprehensible'. Scipt-mixing is not allowed except that | |
162 // Latin letters in the ASCII range can be mixed with a limited set of | |
163 // script-language pairs (currently Han, Kana and Hangul for zh,ja and ko). | |
164 // When |languages| is empty, even that mixing is not allowed. | |
165 NET_EXPORT base::string16 IDNToUnicode(const std::string& host, | 157 NET_EXPORT base::string16 IDNToUnicode(const std::string& host, |
166 const std::string& languages); | 158 const std::string& languages); |
167 | 159 |
168 // Canonicalizes |host| and returns it. Also fills |host_info| with | 160 // Canonicalizes |host| and returns it. Also fills |host_info| with |
169 // IP address information. |host_info| must not be NULL. | 161 // IP address information. |host_info| must not be NULL. |
170 NET_EXPORT std::string CanonicalizeHost(const std::string& host, | 162 NET_EXPORT std::string CanonicalizeHost(const std::string& host, |
171 url::CanonHostInfo* host_info); | 163 url::CanonHostInfo* host_info); |
172 | 164 |
173 // Returns true if |host| is not an IP address and is compliant with a set of | 165 // Returns true if |host| is not an IP address and is compliant with a set of |
174 // rules based on RFC 1738 and tweaked to be compatible with the real world. | 166 // rules based on RFC 1738 and tweaked to be compatible with the real world. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 // unmodified. | 200 // unmodified. |
209 NET_EXPORT base::string16 StripWWW(const base::string16& text); | 201 NET_EXPORT base::string16 StripWWW(const base::string16& text); |
210 | 202 |
211 // Runs |url|'s host through StripWWW(). |url| must be valid. | 203 // Runs |url|'s host through StripWWW(). |url| must be valid. |
212 NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); | 204 NET_EXPORT base::string16 StripWWWFromHost(const GURL& url); |
213 | 205 |
214 // Set socket to non-blocking mode | 206 // Set socket to non-blocking mode |
215 NET_EXPORT int SetNonBlocking(int fd); | 207 NET_EXPORT int SetNonBlocking(int fd); |
216 | 208 |
217 // Formats the host in |url| and appends it to |output|. The host formatter | 209 // Formats the host in |url| and appends it to |output|. The host formatter |
218 // takes the same accept languages component as ElideURL(). | 210 // takes the same accept languages component as ElideURL(), but it does not |
| 211 // affect the result. It'll be removed. |
219 NET_EXPORT void AppendFormattedHost(const GURL& url, | 212 NET_EXPORT void AppendFormattedHost(const GURL& url, |
220 const std::string& languages, | 213 const std::string& languages, |
221 base::string16* output); | 214 base::string16* output); |
222 | 215 |
223 // Creates a string representation of |url|. The IDN host name may be in Unicode | 216 // Creates a string representation of |url|. The IDN host name is turned to |
224 // if |languages| accepts the Unicode representation. |format_type| is a bitmask | 217 // Unicode if the Unicode representation is deemed safe. |languages| is not |
| 218 // used any more and will be removed. |format_type| is a bitmask |
225 // of FormatUrlTypes, see it for details. |unescape_rules| defines how to clean | 219 // of FormatUrlTypes, see it for details. |unescape_rules| defines how to clean |
226 // the URL for human readability. You will generally want |UnescapeRule::SPACES| | 220 // the URL for human readability. You will generally want |UnescapeRule::SPACES| |
227 // for display to the user if you can handle spaces, or |UnescapeRule::NORMAL| | 221 // for display to the user if you can handle spaces, or |UnescapeRule::NORMAL| |
228 // if not. If the path part and the query part seem to be encoded in %-encoded | 222 // if not. If the path part and the query part seem to be encoded in %-encoded |
229 // UTF-8, decodes %-encoding and UTF-8. | 223 // UTF-8, decodes %-encoding and UTF-8. |
230 // | 224 // |
231 // The last three parameters may be NULL. | 225 // The last three parameters may be NULL. |
232 // | 226 // |
233 // |new_parsed| will be set to the parsing parameters of the resultant URL. | 227 // |new_parsed| will be set to the parsing parameters of the resultant URL. |
234 // | 228 // |
(...skipping 18 matching lines...) Expand all Loading... |
253 // components are adjacent. | 247 // components are adjacent. |
254 NET_EXPORT base::string16 FormatUrl(const GURL& url, | 248 NET_EXPORT base::string16 FormatUrl(const GURL& url, |
255 const std::string& languages, | 249 const std::string& languages, |
256 FormatUrlTypes format_types, | 250 FormatUrlTypes format_types, |
257 UnescapeRule::Type unescape_rules, | 251 UnescapeRule::Type unescape_rules, |
258 url::Parsed* new_parsed, | 252 url::Parsed* new_parsed, |
259 size_t* prefix_end, | 253 size_t* prefix_end, |
260 size_t* offset_for_adjustment); | 254 size_t* offset_for_adjustment); |
261 NET_EXPORT base::string16 FormatUrlWithOffsets( | 255 NET_EXPORT base::string16 FormatUrlWithOffsets( |
262 const GURL& url, | 256 const GURL& url, |
263 const std::string& languages, | 257 const std::string& langauges, |
264 FormatUrlTypes format_types, | 258 FormatUrlTypes format_types, |
265 UnescapeRule::Type unescape_rules, | 259 UnescapeRule::Type unescape_rules, |
266 url::Parsed* new_parsed, | 260 url::Parsed* new_parsed, |
267 size_t* prefix_end, | 261 size_t* prefix_end, |
268 std::vector<size_t>* offsets_for_adjustment); | 262 std::vector<size_t>* offsets_for_adjustment); |
269 // This function is like those above except it takes |adjustments| rather | 263 // This function is like those above except it takes |adjustments| rather |
270 // than |offset[s]_for_adjustment|. |adjustments| will be set to reflect all | 264 // than |offset[s]_for_adjustment|. |adjustments| will be set to reflect all |
271 // the transformations that happened to |url| to convert it into the returned | 265 // the transformations that happened to |url| to convert it into the returned |
272 // value. | 266 // value. |
273 NET_EXPORT base::string16 FormatUrlWithAdjustments( | 267 NET_EXPORT base::string16 FormatUrlWithAdjustments( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 DSCP_CS5 = 40, // Video | 377 DSCP_CS5 = 40, // Video |
384 DSCP_EF = 46, // Voice | 378 DSCP_EF = 46, // Voice |
385 DSCP_CS6 = 48, // Voice | 379 DSCP_CS6 = 48, // Voice |
386 DSCP_CS7 = 56, // Control messages | 380 DSCP_CS7 = 56, // Control messages |
387 DSCP_LAST = DSCP_CS7 | 381 DSCP_LAST = DSCP_CS7 |
388 }; | 382 }; |
389 | 383 |
390 } // namespace net | 384 } // namespace net |
391 | 385 |
392 #endif // NET_BASE_NET_UTIL_H_ | 386 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |