| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 HttpAuthController::~HttpAuthController() { | 66 HttpAuthController::~HttpAuthController() { |
| 67 user_callback_ = NULL; | 67 user_callback_ = NULL; |
| 68 } | 68 } |
| 69 | 69 |
| 70 int HttpAuthController::MaybeGenerateAuthToken(const HttpRequestInfo* request, | 70 int HttpAuthController::MaybeGenerateAuthToken(const HttpRequestInfo* request, |
| 71 CompletionCallback* callback, | 71 CompletionCallback* callback, |
| 72 const BoundNetLog& net_log) { | 72 const BoundNetLog& net_log) { |
| 73 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); | 73 bool needs_auth = HaveAuth() || SelectPreemptiveAuth(net_log); |
| 74 if (!needs_auth) | 74 if (!needs_auth) |
| 75 return OK; | 75 return OK; |
| 76 const std::wstring* username = NULL; | 76 const string16* username = NULL; |
| 77 const std::wstring* password = NULL; | 77 const string16* password = NULL; |
| 78 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) { | 78 if (identity_.source != HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS) { |
| 79 username = &identity_.username; | 79 username = &identity_.username; |
| 80 password = &identity_.password; | 80 password = &identity_.password; |
| 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_, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // We have exhausted all identity possibilities, all we can do now is | 212 // We have exhausted all identity possibilities, all we can do now is |
| 213 // pass the challenge information back to the client. | 213 // pass the challenge information back to the client. |
| 214 PopulateAuthChallenge(); | 214 PopulateAuthChallenge(); |
| 215 } else { | 215 } else { |
| 216 auth_info_ = NULL; | 216 auth_info_ = NULL; |
| 217 } | 217 } |
| 218 | 218 |
| 219 return OK; | 219 return OK; |
| 220 } | 220 } |
| 221 | 221 |
| 222 void HttpAuthController::ResetAuth(const std::wstring& username, | 222 void HttpAuthController::ResetAuth(const string16& username, |
| 223 const std::wstring& password) { | 223 const string16& password) { |
| 224 DCHECK(identity_.invalid || (username.empty() && password.empty())); | 224 DCHECK(identity_.invalid || (username.empty() && password.empty())); |
| 225 | 225 |
| 226 if (identity_.invalid) { | 226 if (identity_.invalid) { |
| 227 // Update the username/password. | 227 // Update the username/password. |
| 228 identity_.source = HttpAuth::IDENT_SRC_EXTERNAL; | 228 identity_.source = HttpAuth::IDENT_SRC_EXTERNAL; |
| 229 identity_.invalid = false; | 229 identity_.invalid = false; |
| 230 identity_.username = username; | 230 identity_.username = username; |
| 231 identity_.password = password; | 231 identity_.password = password; |
| 232 } | 232 } |
| 233 | 233 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |