| 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_controller.h" | 5 #include "net/http/http_auth_controller.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/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 HttpAuthController::~HttpAuthController() { | 204 HttpAuthController::~HttpAuthController() { |
| 205 DCHECK(CalledOnValidThread()); | 205 DCHECK(CalledOnValidThread()); |
| 206 } | 206 } |
| 207 | 207 |
| 208 int HttpAuthController::MaybeGenerateAuthToken( | 208 int HttpAuthController::MaybeGenerateAuthToken( |
| 209 const HttpRequestInfo* request, const CompletionCallback& callback, | 209 const HttpRequestInfo* request, const CompletionCallback& callback, |
| 210 const BoundNetLog& net_log) { | 210 const BoundNetLog& net_log) { |
| 211 DCHECK(CalledOnValidThread()); | 211 DCHECK(CalledOnValidThread()); |
| 212 DCHECK(request); |
| 212 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); | 213 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); |
| 213 if (!needs_auth) | 214 if (!needs_auth) |
| 214 return OK; | 215 return OK; |
| 215 const AuthCredentials* credentials = NULL; | 216 const AuthCredentials* credentials = NULL; |
| 216 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) | 217 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) |
| 217 credentials = &identity_.credentials; | 218 credentials = &identity_.credentials; |
| 218 DCHECK(auth_token_.empty()); | 219 DCHECK(auth_token_.empty()); |
| 219 DCHECK(callback_.is_null()); | 220 DCHECK(callback_.is_null()); |
| 220 int rv = handler_->GenerateAuthToken( | 221 int rv = handler_->GenerateAuthToken( |
| 221 credentials, request, | 222 credentials, *request, |
| 222 base::Bind(&HttpAuthController::OnIOComplete, base::Unretained(this)), | 223 base::Bind(&HttpAuthController::OnIOComplete, base::Unretained(this)), |
| 223 &auth_token_); | 224 &auth_token_); |
| 224 if (DisableOnAuthHandlerResult(rv)) | 225 if (DisableOnAuthHandlerResult(rv)) |
| 225 rv = OK; | 226 rv = OK; |
| 226 if (rv == ERR_IO_PENDING) | 227 if (rv == ERR_IO_PENDING) |
| 227 callback_ = callback; | 228 callback_ = callback; |
| 228 else | 229 else |
| 229 OnIOComplete(rv); | 230 OnIOComplete(rv); |
| 230 return rv; | 231 return rv; |
| 231 } | 232 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 DCHECK(CalledOnValidThread()); | 605 DCHECK(CalledOnValidThread()); |
| 605 disabled_schemes_.Add(scheme); | 606 disabled_schemes_.Add(scheme); |
| 606 } | 607 } |
| 607 | 608 |
| 608 void HttpAuthController::DisableEmbeddedIdentity() { | 609 void HttpAuthController::DisableEmbeddedIdentity() { |
| 609 DCHECK(CalledOnValidThread()); | 610 DCHECK(CalledOnValidThread()); |
| 610 embedded_identity_used_ = true; | 611 embedded_identity_used_ = true; |
| 611 } | 612 } |
| 612 | 613 |
| 613 } // namespace net | 614 } // namespace net |
| OLD | NEW |