| 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(const std::string& scheme) | 16 HttpAuthHandler::HttpAuthHandler(const std::string& scheme) |
| 17 : auth_scheme_(scheme), target_(HttpAuth::AUTH_NONE) {} | 17 : auth_scheme_(scheme), target_(HttpAuth::AUTH_NONE) {} |
| 18 | 18 |
| 19 HttpAuthHandler::~HttpAuthHandler() { | 19 HttpAuthHandler::~HttpAuthHandler() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 int HttpAuthHandler::HandleInitialChallenge( | 22 int HttpAuthHandler::HandleInitialChallenge( |
| 23 const HttpAuthChallengeTokenizer& challenge, | 23 const HttpAuthChallengeTokenizer& challenge, |
| 24 const HttpResponseInfo& response_info, |
| 24 HttpAuth::Target target, | 25 HttpAuth::Target target, |
| 25 const GURL& origin, | 26 const GURL& origin, |
| 26 const BoundNetLog& net_log) { | 27 const BoundNetLog& net_log, |
| 28 const CompletionCallback& callback) { |
| 27 origin_ = origin; | 29 origin_ = origin; |
| 28 target_ = target; | 30 target_ = target; |
| 29 net_log_ = net_log; | 31 net_log_ = net_log; |
| 30 | 32 |
| 31 auth_challenge_ = challenge.challenge_text(); | 33 auth_challenge_ = challenge.challenge_text(); |
| 32 return Init(challenge); | 34 return InitializeFromChallengeInternal(challenge, response_info, callback); |
| 35 } |
| 36 |
| 37 int HttpAuthHandler::InitializeFromCacheEntry(HttpAuthCache::Entry* cache_entry, |
| 38 HttpAuth::Target target, |
| 39 const BoundNetLog& net_log) { |
| 40 origin_ = cache_entry->origin(); |
| 41 target_ = target; |
| 42 net_log_ = net_log; |
| 43 |
| 44 auth_challenge_ = cache_entry->auth_challenge(); |
| 45 return InitializeFromCacheEntryInternal(cache_entry); |
| 33 } | 46 } |
| 34 | 47 |
| 35 namespace { | 48 namespace { |
| 36 | 49 |
| 37 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { | 50 NetLog::EventType EventTypeFromAuthTarget(HttpAuth::Target target) { |
| 38 switch (target) { | 51 switch (target) { |
| 39 case HttpAuth::AUTH_PROXY: | 52 case HttpAuth::AUTH_PROXY: |
| 40 return NetLog::TYPE_AUTH_PROXY; | 53 return NetLog::TYPE_AUTH_PROXY; |
| 41 case HttpAuth::AUTH_SERVER: | 54 case HttpAuth::AUTH_SERVER: |
| 42 return NetLog::TYPE_AUTH_SERVER; | 55 return NetLog::TYPE_AUTH_SERVER; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 callback.Run(rv); | 100 callback.Run(rv); |
| 88 } | 101 } |
| 89 | 102 |
| 90 void HttpAuthHandler::FinishGenerateAuthToken() { | 103 void HttpAuthHandler::FinishGenerateAuthToken() { |
| 91 // TOOD(cbentzel): Should this be done in OK case only? | 104 // TOOD(cbentzel): Should this be done in OK case only? |
| 92 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); | 105 net_log_.EndEvent(EventTypeFromAuthTarget(target_)); |
| 93 callback_.Reset(); | 106 callback_.Reset(); |
| 94 } | 107 } |
| 95 | 108 |
| 96 } // namespace net | 109 } // namespace net |
| OLD | NEW |