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

Side by Side Diff: net/http/http_auth_handler_basic.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/http/http_auth_handler_basic.h ('k') | net/http/http_auth_handler_basic_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/http/http_auth_handler_basic.h" 5 #include "net/http/http_auth_handler_basic.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 24 matching lines...) Expand all
35 // Extract the realm (may be missing). 35 // Extract the realm (may be missing).
36 while (challenge->GetNext()) { 36 while (challenge->GetNext()) {
37 if (LowerCaseEqualsASCII(challenge->name(), "realm")) 37 if (LowerCaseEqualsASCII(challenge->name(), "realm"))
38 realm_ = challenge->unquoted_value(); 38 realm_ = challenge->unquoted_value();
39 } 39 }
40 40
41 return challenge->valid(); 41 return challenge->valid();
42 } 42 }
43 43
44 int HttpAuthHandlerBasic::GenerateAuthTokenImpl( 44 int HttpAuthHandlerBasic::GenerateAuthTokenImpl(
45 const std::wstring* username, 45 const string16* username,
46 const std::wstring* password, 46 const string16* password,
47 const HttpRequestInfo*, 47 const HttpRequestInfo*,
48 CompletionCallback*, 48 CompletionCallback*,
49 std::string* auth_token) { 49 std::string* auth_token) {
50 // TODO(eroman): is this the right encoding of username/password? 50 // TODO(eroman): is this the right encoding of username/password?
51 std::string base64_username_password; 51 std::string base64_username_password;
52 if (!base::Base64Encode(WideToUTF8(*username) + ":" + WideToUTF8(*password), 52 if (!base::Base64Encode(UTF16ToUTF8(*username) + ":" + UTF16ToUTF8(*password),
53 &base64_username_password)) { 53 &base64_username_password)) {
54 LOG(ERROR) << "Unexpected problem Base64 encoding."; 54 LOG(ERROR) << "Unexpected problem Base64 encoding.";
55 return ERR_UNEXPECTED; 55 return ERR_UNEXPECTED;
56 } 56 }
57 *auth_token = "Basic " + base64_username_password; 57 *auth_token = "Basic " + base64_username_password;
58 return OK; 58 return OK;
59 } 59 }
60 60
61 HttpAuthHandlerBasic::Factory::Factory() { 61 HttpAuthHandlerBasic::Factory::Factory() {
62 } 62 }
(...skipping 12 matching lines...) Expand all
75 // TODO(cbentzel): Move towards model of parsing in the factory 75 // TODO(cbentzel): Move towards model of parsing in the factory
76 // method and only constructing when valid. 76 // method and only constructing when valid.
77 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); 77 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic());
78 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) 78 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
79 return ERR_INVALID_RESPONSE; 79 return ERR_INVALID_RESPONSE;
80 handler->swap(tmp_handler); 80 handler->swap(tmp_handler);
81 return OK; 81 return OK;
82 } 82 }
83 83
84 } // namespace net 84 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_basic.h ('k') | net/http/http_auth_handler_basic_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698