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 #include "net/http/http_auth_handler.h" | 5 #include "net/http/http_auth_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/http/http_auth_challenge_tokenizer.h" | 12 #include "net/http/http_auth_challenge_tokenizer.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 HttpAuthHandler::HttpAuthHandler() : target_(HttpAuth::AUTH_NONE) {} | 16 HttpAuthHandler::HttpAuthHandler(const std::string& scheme) |
| 17 : auth_scheme_(scheme), target_(HttpAuth::AUTH_NONE) {} |
17 | 18 |
18 HttpAuthHandler::~HttpAuthHandler() { | 19 HttpAuthHandler::~HttpAuthHandler() { |
19 } | 20 } |
20 | 21 |
21 int HttpAuthHandler::HandleInitialChallenge( | 22 int HttpAuthHandler::HandleInitialChallenge( |
22 const HttpAuthChallengeTokenizer& challenge, | 23 const HttpAuthChallengeTokenizer& challenge, |
23 HttpAuth::Target target, | 24 HttpAuth::Target target, |
24 const GURL& origin, | 25 const GURL& origin, |
25 const BoundNetLog& net_log) { | 26 const BoundNetLog& net_log) { |
26 origin_ = origin; | 27 origin_ = origin; |
27 target_ = target; | 28 target_ = target; |
28 net_log_ = net_log; | 29 net_log_ = net_log; |
29 | 30 |
30 auth_challenge_ = challenge.challenge_text(); | 31 auth_challenge_ = challenge.challenge_text(); |
31 int result = Init(challenge); | 32 return Init(challenge); |
32 | |
33 // Init() is expected to set the scheme, realm, score, and properties. The | |
34 // realm may be empty. | |
35 DCHECK_IMPLIES(result == OK, HttpAuth::IsValidNormalizedScheme(auth_scheme_)); | |
36 | |
37 return result; | |
38 } | 33 } |
39 | 34 |
40 namespace { | 35 namespace { |
41 | 36 |
42 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { | 37 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { |
43 switch (target) { | 38 switch (target) { |
44 case HttpAuth::AUTH_PROXY: | 39 case HttpAuth::AUTH_PROXY: |
45 return NetLog::TYPE_AUTH_PROXY; | 40 return NetLog::TYPE_AUTH_PROXY; |
46 case HttpAuth::AUTH_SERVER: | 41 case HttpAuth::AUTH_SERVER: |
47 return NetLog::TYPE_AUTH_SERVER; | 42 return NetLog::TYPE_AUTH_SERVER; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 callback.Run(rv); | 87 callback.Run(rv); |
93 } | 88 } |
94 | 89 |
95 void HttpAuthHandler::FinishGenerateAuthToken() { | 90 void HttpAuthHandler::FinishGenerateAuthToken() { |
96 // TOOD(cbentzel): Should this be done in OK case only? | 91 // TOOD(cbentzel): Should this be done in OK case only? |
97 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); | 92 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); |
98 callback_.Reset(); | 93 callback_.Reset(); |
99 } | 94 } |
100 | 95 |
101 } // namespace net | 96 } // namespace net |
OLD | NEW |