Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: net/base/net_util.h

Issue 6898026: Eliminate wstring from base/utf_offset_string_conversions.h, net/base/escape.h, and net/base/net_... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void GetIdentityFromURL(const GURL& url, 128 void GetIdentityFromURL(const GURL& url,
129 string16* username, 129 string16* username,
130 string16* password); 130 string16* password);
131 131
132 // Returns either the host from |url|, or, if the host is empty, the full spec. 132 // Returns either the host from |url|, or, if the host is empty, the full spec.
133 std::string GetHostOrSpecFromURL(const GURL& url); 133 std::string GetHostOrSpecFromURL(const GURL& url);
134 134
135 // Return the value of the HTTP response header with name 'name'. 'headers' 135 // Return the value of the HTTP response header with name 'name'. 'headers'
136 // should be in the format that URLRequest::GetResponseHeaders() returns. 136 // should be in the format that URLRequest::GetResponseHeaders() returns.
137 // Returns the empty string if the header is not found. 137 // Returns the empty string if the header is not found.
138 std::wstring GetSpecificHeader(const std::wstring& headers,
139 const std::wstring& name);
140 std::string GetSpecificHeader(const std::string& headers, 138 std::string GetSpecificHeader(const std::string& headers,
141 const std::string& name); 139 const std::string& name);
142 140
143 // Return the value of the HTTP response header field's parameter named 141 // Return the value of the HTTP response header field's parameter named
144 // 'param_name'. Returns the empty string if the parameter is not found or is 142 // 'param_name'. Returns the empty string if the parameter is not found or is
145 // improperly formatted. 143 // improperly formatted.
146 std::wstring GetHeaderParamValue(const std::wstring& field, 144 std::string GetHeaderParamValue(const std::string& header,
147 const std::wstring& param_name,
148 QuoteRule::Type quote_rule);
149 std::string GetHeaderParamValue(const std::string& field,
150 const std::string& param_name, 145 const std::string& param_name,
151 QuoteRule::Type quote_rule); 146 QuoteRule::Type quote_rule);
152 147
153 // Return the filename extracted from Content-Disposition header. The following 148 // Return the filename extracted from Content-Disposition header. The following
154 // formats are tried in order listed below: 149 // formats are tried in order listed below:
155 // 150 //
156 // 1. RFC 5987 151 // 1. RFC 5987
157 // 2. RFC 2047 152 // 2. RFC 2047
158 // 3. Raw-8bit-characters : 153 // 3. Raw-8bit-characters :
159 // a. UTF-8, b. referrer_charset, c. default os codepage. 154 // a. UTF-8, b. referrer_charset, c. default os codepage.
(...skipping 30 matching lines...) Expand all
190 // designed to work on the substring of the host out of a URL spec). 185 // designed to work on the substring of the host out of a URL spec).
191 // 186 //
192 // |languages| is a comma separated list of ISO 639 language codes. It 187 // |languages| is a comma separated list of ISO 639 language codes. It
193 // is used to determine whether a hostname is 'comprehensible' to a user 188 // is used to determine whether a hostname is 'comprehensible' to a user
194 // who understands languages listed. |host| will be converted to a 189 // who understands languages listed. |host| will be converted to a
195 // human-readable form (Unicode) ONLY when each component of |host| is 190 // human-readable form (Unicode) ONLY when each component of |host| is
196 // regarded as 'comprehensible'. Scipt-mixing is not allowed except that 191 // regarded as 'comprehensible'. Scipt-mixing is not allowed except that
197 // Latin letters in the ASCII range can be mixed with a limited set of 192 // Latin letters in the ASCII range can be mixed with a limited set of
198 // script-language pairs (currently Han, Kana and Hangul for zh,ja and ko). 193 // script-language pairs (currently Han, Kana and Hangul for zh,ja and ko).
199 // When |languages| is empty, even that mixing is not allowed. 194 // When |languages| is empty, even that mixing is not allowed.
200 // 195 string16 IDNToUnicode(const char* host,
201 // (|offset[s]_for_adjustment|) specifies one or more offsets into the original 196 size_t host_len,
202 // |url|'s spec(); each offset will be adjusted to point at the same logical 197 const std::string& languages);
203 // place in the result strings during decoding. If this isn't possible because
204 // an offset points past the end of |host| or into the middle of a punycode
205 // sequence, the offending offset will be set to std::wstring::npos.
206 // |offset[s]_for_adjustment| may be NULL.
207 std::wstring IDNToUnicode(const char* host,
208 size_t host_len,
209 const std::wstring& languages,
210 size_t* offset_for_adjustment);
211 std::wstring IDNToUnicodeWithOffsets(
212 const char* host,
213 size_t host_len,
214 const std::wstring& languages,
215 std::vector<size_t>* offsets_for_adjustment);
216 198
217 // Canonicalizes |host| and returns it. Also fills |host_info| with 199 // Canonicalizes |host| and returns it. Also fills |host_info| with
218 // IP address information. |host_info| must not be NULL. 200 // IP address information. |host_info| must not be NULL.
219 std::string CanonicalizeHost(const std::string& host, 201 std::string CanonicalizeHost(const std::string& host,
220 url_canon::CanonHostInfo* host_info); 202 url_canon::CanonHostInfo* host_info);
221 std::string CanonicalizeHost(const std::wstring& host,
222 url_canon::CanonHostInfo* host_info);
223 203
224 // Returns true if |host| is not an IP address and is compliant with a set of 204 // Returns true if |host| is not an IP address and is compliant with a set of
225 // rules based on RFC 1738 and tweaked to be compatible with the real world. 205 // rules based on RFC 1738 and tweaked to be compatible with the real world.
226 // The rules are: 206 // The rules are:
227 // * One or more components separated by '.' 207 // * One or more components separated by '.'
228 // * Each component begins and ends with an alphanumeric character 208 // * Each component begins and ends with an alphanumeric character
229 // * Each component contains only alphanumeric characters and '-' or '_' 209 // * Each component contains only alphanumeric characters and '-' or '_'
230 // * The last component does not begin with a digit 210 // * The last component does not begin with a digit
231 // * Optional trailing dot after last component (means "treat as FQDN") 211 // * Optional trailing dot after last component (means "treat as FQDN")
232 // If |desired_tld| is non-NULL, the host will only be considered invalid if 212 // If |desired_tld| is non-NULL, the host will only be considered invalid if
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 // Appends the given part of the original URL to the output string formatted for 277 // Appends the given part of the original URL to the output string formatted for
298 // the user. The given parsed structure will be updated. The host name formatter 278 // the user. The given parsed structure will be updated. The host name formatter
299 // also takes the same accept languages component as ElideURL. |new_parsed| may 279 // also takes the same accept languages component as ElideURL. |new_parsed| may
300 // be null. 280 // be null.
301 // 281 //
302 // (|offset[s]_for_adjustment|) specifies one or more offsets into the original 282 // (|offset[s]_for_adjustment|) specifies one or more offsets into the original
303 // |url|'s spec(); each offset will be adjusted to point at the same logical 283 // |url|'s spec(); each offset will be adjusted to point at the same logical
304 // place in the result strings after reformatting of the host. If this isn't 284 // place in the result strings after reformatting of the host. If this isn't
305 // possible because an offset points past the end of the host or into the middle 285 // possible because an offset points past the end of the host or into the middle
306 // of a multi-character sequence, the offending offset will be set to 286 // of a multi-character sequence, the offending offset will be set to
307 // std::wstring::npos. |offset[s]_for_adjustment| may be NULL. 287 // string16::npos. |offset[s]_for_adjustment| may be NULL.
308 void AppendFormattedHost(const GURL& url, 288 void AppendFormattedHost(const GURL& url,
309 const std::wstring& languages, 289 const std::string& languages,
310 std::wstring* output, 290 string16* output,
311 url_parse::Parsed* new_parsed, 291 url_parse::Parsed* new_parsed,
312 size_t* offset_for_adjustment); 292 size_t* offset_for_adjustment);
313 void AppendFormattedHostWithOffsets( 293 void AppendFormattedHostWithOffsets(
314 const GURL& url, 294 const GURL& url,
315 const std::wstring& languages, 295 const std::string& languages,
316 std::wstring* output, 296 string16* output,
317 url_parse::Parsed* new_parsed, 297 url_parse::Parsed* new_parsed,
318 std::vector<size_t>* offsets_for_adjustment); 298 std::vector<size_t>* offsets_for_adjustment);
319 299
320 // Creates a string representation of |url|. The IDN host name may be in Unicode 300 // Creates a string representation of |url|. The IDN host name may be in Unicode
321 // if |languages| accepts the Unicode representation. |format_type| is a bitmask 301 // if |languages| accepts the Unicode representation. |format_type| is a bitmask
322 // of FormatUrlTypes, see it for details. |unescape_rules| defines how to clean 302 // of FormatUrlTypes, see it for details. |unescape_rules| defines how to clean
323 // the URL for human readability. You will generally want |UnescapeRule::SPACES| 303 // the URL for human readability. You will generally want |UnescapeRule::SPACES|
324 // for display to the user if you can handle spaces, or |UnescapeRule::NORMAL| 304 // for display to the user if you can handle spaces, or |UnescapeRule::NORMAL|
325 // if not. If the path part and the query part seem to be encoded in %-encoded 305 // if not. If the path part and the query part seem to be encoded in %-encoded
326 // UTF-8, decodes %-encoding and UTF-8. 306 // UTF-8, decodes %-encoding and UTF-8.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 struct ClampComponentOffset { 467 struct ClampComponentOffset {
488 explicit ClampComponentOffset(size_t component_start); 468 explicit ClampComponentOffset(size_t component_start);
489 size_t operator()(size_t offset); 469 size_t operator()(size_t offset);
490 470
491 const size_t component_start; 471 const size_t component_start;
492 }; 472 };
493 473
494 } // namespace net 474 } // namespace net
495 475
496 #endif // NET_BASE_NET_UTIL_H_ 476 #endif // NET_BASE_NET_UTIL_H_
OLDNEW
« no previous file with comments | « net/base/escape_unittest.cc ('k') | net/base/net_util.cc » ('j') | net/base/net_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698