| 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_controller.h" | 5 #include "net/http/http_auth_controller.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "net/base/host_resolver.h" | 8 #include "net/base/host_resolver.h" |
| 9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
| 10 #include "net/http/http_auth_handler_factory.h" | 10 #include "net/http/http_auth_handler_factory.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 DCHECK(auth_token_.empty()); | 82 DCHECK(auth_token_.empty()); |
| 83 DCHECK(NULL == user_callback_); | 83 DCHECK(NULL == user_callback_); |
| 84 int rv = handler_->GenerateAuthToken(username, | 84 int rv = handler_->GenerateAuthToken(username, |
| 85 password, | 85 password, |
| 86 request, | 86 request, |
| 87 &io_callback_, | 87 &io_callback_, |
| 88 &auth_token_); | 88 &auth_token_); |
| 89 if (rv == ERR_IO_PENDING) | 89 if (rv == ERR_IO_PENDING) |
| 90 user_callback_ = callback; | 90 user_callback_ = callback; |
| 91 if (rv != ERR_IO_PENDING) | 91 else |
| 92 OnIOComplete(rv); | 92 OnIOComplete(rv); |
| 93 // This error occurs with GSSAPI, if the user has not already logged in. | 93 // This error occurs with GSSAPI, if the user has not already logged in. |
| 94 if (rv == ERR_MISSING_AUTH_CREDENTIALS) | 94 if (rv == ERR_MISSING_AUTH_CREDENTIALS) |
| 95 rv = OK; | 95 rv = OK; |
| 96 return rv; | 96 return rv; |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool HttpAuthController::SelectPreemptiveAuth(const BoundNetLog& net_log) { | 99 bool HttpAuthController::SelectPreemptiveAuth(const BoundNetLog& net_log) { |
| 100 DCHECK(!HaveAuth()); | 100 DCHECK(!HaveAuth()); |
| 101 DCHECK(identity_.invalid); | 101 DCHECK(identity_.invalid); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 auth_info_->scheme = ASCIIToWide(handler_->scheme()); | 335 auth_info_->scheme = ASCIIToWide(handler_->scheme()); |
| 336 // TODO(eroman): decode realm according to RFC 2047. | 336 // TODO(eroman): decode realm according to RFC 2047. |
| 337 auth_info_->realm = ASCIIToWide(handler_->realm()); | 337 auth_info_->realm = ASCIIToWide(handler_->realm()); |
| 338 } | 338 } |
| 339 | 339 |
| 340 void HttpAuthController::OnIOComplete(int result) { | 340 void HttpAuthController::OnIOComplete(int result) { |
| 341 // This error occurs with GSSAPI, if the user has not already logged in. | 341 // This error occurs with GSSAPI, if the user has not already logged in. |
| 342 // In that case, disable the current scheme as it cannot succeed. | 342 // In that case, disable the current scheme as it cannot succeed. |
| 343 if (result == ERR_MISSING_AUTH_CREDENTIALS) { | 343 if (result == ERR_MISSING_AUTH_CREDENTIALS) { |
| 344 DisableAuthScheme(handler_->scheme()); | 344 DisableAuthScheme(handler_->scheme()); |
| 345 auth_token_.erase(); | 345 auth_token_.clear(); |
| 346 result = OK; | 346 result = OK; |
| 347 } | 347 } |
| 348 if (user_callback_) { | 348 if (user_callback_) { |
| 349 CompletionCallback* c = user_callback_; | 349 CompletionCallback* c = user_callback_; |
| 350 user_callback_ = NULL; | 350 user_callback_ = NULL; |
| 351 c->Run(result); | 351 c->Run(result); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 bool HttpAuthController::IsAuthSchemeDisabled(const std::string& scheme) const { | 355 bool HttpAuthController::IsAuthSchemeDisabled(const std::string& scheme) const { |
| 356 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); | 356 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void HttpAuthController::DisableAuthScheme(const std::string& scheme) { | 359 void HttpAuthController::DisableAuthScheme(const std::string& scheme) { |
| 360 disabled_schemes_.insert(scheme); | 360 disabled_schemes_.insert(scheme); |
| 361 } | 361 } |
| 362 | 362 |
| 363 } // namespace net | 363 } // namespace net |
| OLD | NEW |