OLD | NEW |
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.h" | 5 #include "net/http/http_auth_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 HttpAuthHandler::HttpAuthHandler() | 12 HttpAuthHandler::HttpAuthHandler() |
13 : auth_scheme_(AUTH_SCHEME_MAX), | 13 : auth_scheme_(HttpAuth::AUTH_SCHEME_MAX), |
14 score_(-1), | 14 score_(-1), |
15 target_(HttpAuth::AUTH_NONE), | 15 target_(HttpAuth::AUTH_NONE), |
16 properties_(-1), | 16 properties_(-1), |
17 original_callback_(NULL), | 17 original_callback_(NULL), |
18 ALLOW_THIS_IN_INITIALIZER_LIST( | 18 ALLOW_THIS_IN_INITIALIZER_LIST( |
19 wrapper_callback_( | 19 wrapper_callback_( |
20 this, &HttpAuthHandler::OnGenerateAuthTokenComplete)) { | 20 this, &HttpAuthHandler::OnGenerateAuthTokenComplete)) { |
21 } | 21 } |
22 | 22 |
23 HttpAuthHandler::~HttpAuthHandler() { | 23 HttpAuthHandler::~HttpAuthHandler() { |
24 } | 24 } |
25 | 25 |
26 bool HttpAuthHandler::InitFromChallenge( | 26 bool HttpAuthHandler::InitFromChallenge( |
27 HttpAuth::ChallengeTokenizer* challenge, | 27 HttpAuth::ChallengeTokenizer* challenge, |
28 HttpAuth::Target target, | 28 HttpAuth::Target target, |
29 const GURL& origin, | 29 const GURL& origin, |
30 const BoundNetLog& net_log) { | 30 const BoundNetLog& net_log) { |
31 origin_ = origin; | 31 origin_ = origin; |
32 target_ = target; | 32 target_ = target; |
33 score_ = -1; | 33 score_ = -1; |
34 properties_ = -1; | 34 properties_ = -1; |
35 net_log_ = net_log; | 35 net_log_ = net_log; |
36 | 36 |
37 auth_challenge_ = challenge->challenge_text(); | 37 auth_challenge_ = challenge->challenge_text(); |
38 bool ok = Init(challenge); | 38 bool ok = Init(challenge); |
39 | 39 |
40 // Init() is expected to set the scheme, realm, score, and properties. The | 40 // Init() is expected to set the scheme, realm, score, and properties. The |
41 // realm may be empty. | 41 // realm may be empty. |
42 DCHECK(!ok || !scheme().empty()); | |
43 DCHECK(!ok || score_ != -1); | 42 DCHECK(!ok || score_ != -1); |
44 DCHECK(!ok || properties_ != -1); | 43 DCHECK(!ok || properties_ != -1); |
45 DCHECK(!ok || auth_scheme_ != AUTH_SCHEME_MAX); | 44 DCHECK(!ok || auth_scheme_ != HttpAuth::AUTH_SCHEME_MAX); |
46 | 45 |
47 return ok; | 46 return ok; |
48 } | 47 } |
49 | 48 |
50 namespace { | 49 namespace { |
51 | 50 |
52 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { | 51 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { |
53 switch (target) { | 52 switch (target) { |
54 case HttpAuth::AUTH_PROXY: | 53 case HttpAuth::AUTH_PROXY: |
55 return NetLog::TYPE_AUTH_PROXY; | 54 return NetLog::TYPE_AUTH_PROXY; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 callback->Run(rv); | 97 callback->Run(rv); |
99 } | 98 } |
100 | 99 |
101 void HttpAuthHandler::FinishGenerateAuthToken() { | 100 void HttpAuthHandler::FinishGenerateAuthToken() { |
102 // TOOD(cbentzel): Should this be done in OK case only? | 101 // TOOD(cbentzel): Should this be done in OK case only? |
103 net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL); | 102 net_log_.EndEvent(EventTypeFromAuthTarget(target_), NULL); |
104 original_callback_ = NULL; | 103 original_callback_ = NULL; |
105 } | 104 } |
106 | 105 |
107 } // namespace net | 106 } // namespace net |
OLD | NEW |