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

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

Issue 3040016: Net: Convert username and password to string16. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: address comments Created 10 years, 4 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
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <unicode/regex.h> 9 #include <unicode/regex.h>
10 #include <unicode/ucnv.h> 10 #include <unicode/ucnv.h>
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 char buffer[256]; 1331 char buffer[256];
1332 int result = gethostname(buffer, sizeof(buffer)); 1332 int result = gethostname(buffer, sizeof(buffer));
1333 if (result != 0) { 1333 if (result != 0) {
1334 DLOG(INFO) << "gethostname() failed with " << result; 1334 DLOG(INFO) << "gethostname() failed with " << result;
1335 buffer[0] = '\0'; 1335 buffer[0] = '\0';
1336 } 1336 }
1337 return std::string(buffer); 1337 return std::string(buffer);
1338 } 1338 }
1339 1339
1340 void GetIdentityFromURL(const GURL& url, 1340 void GetIdentityFromURL(const GURL& url,
1341 std::wstring* username, 1341 string16* username,
1342 std::wstring* password) { 1342 string16* password) {
1343 UnescapeRule::Type flags = 1343 UnescapeRule::Type flags =
1344 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS; 1344 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS;
1345 *username = UTF16ToWideHack(UnescapeAndDecodeUTF8URLComponent(url.username(), 1345 *username = UnescapeAndDecodeUTF8URLComponent(url.username(), flags, NULL);
1346 flags, NULL)); 1346 *password = UnescapeAndDecodeUTF8URLComponent(url.password(), flags, NULL);
1347 *password = UTF16ToWideHack(UnescapeAndDecodeUTF8URLComponent(url.password(),
1348 flags, NULL));
1349 } 1347 }
1350 1348
1351 std::string GetHostOrSpecFromURL(const GURL& url) { 1349 std::string GetHostOrSpecFromURL(const GURL& url) {
1352 return url.has_host() ? net::TrimEndingDot(url.host()) : url.spec(); 1350 return url.has_host() ? net::TrimEndingDot(url.host()) : url.spec();
1353 } 1351 }
1354 1352
1355 void AppendFormattedHost(const GURL& url, 1353 void AppendFormattedHost(const GURL& url,
1356 const std::wstring& languages, 1354 const std::wstring& languages,
1357 std::wstring* output, 1355 std::wstring* output,
1358 url_parse::Parsed* new_parsed, 1356 url_parse::Parsed* new_parsed,
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 } 1962 }
1965 1963
1966 int GetPortFromAddrinfo(const struct addrinfo* info) { 1964 int GetPortFromAddrinfo(const struct addrinfo* info) {
1967 uint16* port_field = GetPortFieldFromAddrinfo(info); 1965 uint16* port_field = GetPortFieldFromAddrinfo(info);
1968 if (!port_field) 1966 if (!port_field)
1969 return -1; 1967 return -1;
1970 return ntohs(*port_field); 1968 return ntohs(*port_field);
1971 } 1969 }
1972 1970
1973 } // namespace net 1971 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.h ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698