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

Side by Side Diff: net/http/http_auth_handler_basic.cc

Issue 252733002: Consolidate most of net/'s icu_string_conversions.h dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to comments (x2) Created 6 years, 7 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 #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/i18n/icu_string_conversions.h"
11 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
13 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/base/net_string_util.h"
14 #include "net/http/http_auth.h" 14 #include "net/http/http_auth.h"
15 #include "net/http/http_auth_challenge_tokenizer.h" 15 #include "net/http/http_auth_challenge_tokenizer.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 namespace { 19 namespace {
20 20
21 // Parses a realm from an auth challenge, and converts to UTF8-encoding. 21 // Parses a realm from an auth challenge, and converts to UTF8-encoding.
22 // Returns whether the realm is invalid or the parameters are invalid. 22 // Returns whether the realm is invalid or the parameters are invalid.
23 // 23 //
(...skipping 12 matching lines...) Expand all
36 // well, see http://crbug.com/25790. 36 // well, see http://crbug.com/25790.
37 bool ParseRealm(const HttpAuthChallengeTokenizer& tokenizer, 37 bool ParseRealm(const HttpAuthChallengeTokenizer& tokenizer,
38 std::string* realm) { 38 std::string* realm) {
39 CHECK(realm); 39 CHECK(realm);
40 realm->clear(); 40 realm->clear();
41 HttpUtil::NameValuePairsIterator parameters = tokenizer.param_pairs(); 41 HttpUtil::NameValuePairsIterator parameters = tokenizer.param_pairs();
42 while (parameters.GetNext()) { 42 while (parameters.GetNext()) {
43 if (!LowerCaseEqualsASCII(parameters.name(), "realm")) 43 if (!LowerCaseEqualsASCII(parameters.name(), "realm"))
44 continue; 44 continue;
45 45
46 if (!base::ConvertToUtf8AndNormalize( 46 if (!net::ConvertLatin1ToUtf8AndNormalize(parameters.value(), realm))
47 parameters.value(), base::kCodepageLatin1, realm))
48 return false; 47 return false;
49 } 48 }
50 return parameters.valid(); 49 return parameters.valid();
51 } 50 }
52 51
53 } // namespace 52 } // namespace
54 53
55 bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) { 54 bool HttpAuthHandlerBasic::Init(HttpAuthChallengeTokenizer* challenge) {
56 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC; 55 auth_scheme_ = HttpAuth::AUTH_SCHEME_BASIC;
57 score_ = 1; 56 score_ = 1;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // TODO(cbentzel): Move towards model of parsing in the factory 115 // TODO(cbentzel): Move towards model of parsing in the factory
117 // method and only constructing when valid. 116 // method and only constructing when valid.
118 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic()); 117 scoped_ptr<HttpAuthHandler> tmp_handler(new HttpAuthHandlerBasic());
119 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) 118 if (!tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
120 return ERR_INVALID_RESPONSE; 119 return ERR_INVALID_RESPONSE;
121 handler->swap(tmp_handler); 120 handler->swap(tmp_handler);
122 return OK; 121 return OK;
123 } 122 }
124 123
125 } // namespace net 124 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698