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 201 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::SetCredentials(const std::wstring& username, |
223 const std::wstring& password) { | 223 const std::wstring& 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 | 234 |
| 235 void HttpAuthController::PrepareForAuthRestart() { |
234 DCHECK(identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP); | 236 DCHECK(identity_.source != HttpAuth::IDENT_SRC_PATH_LOOKUP); |
235 | 237 |
236 // Add the auth entry to the cache before restarting. We don't know whether | 238 // Add the auth entry to the cache before restarting. We don't know whether |
237 // the identity is valid yet, but if it is valid we want other transactions | 239 // the identity is valid yet, but if it is valid we want other transactions |
238 // to know about it. If an entry for (origin, handler->realm()) already | 240 // to know about it. If an entry for (origin, handler->realm()) already |
239 // exists, we update it. | 241 // exists, we update it. |
240 // | 242 // |
241 // If identity_.source is HttpAuth::IDENT_SRC_NONE or | 243 // If identity_.source is HttpAuth::IDENT_SRC_NONE or |
242 // HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS, identity_ contains no | 244 // HttpAuth::IDENT_SRC_DEFAULT_CREDENTIALS, identity_ contains no |
243 // identity because identity is not required yet or we're using default | 245 // identity because identity is not required yet or we're using default |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 356 |
355 bool HttpAuthController::IsAuthSchemeDisabled(const std::string& scheme) const { | 357 bool HttpAuthController::IsAuthSchemeDisabled(const std::string& scheme) const { |
356 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); | 358 return disabled_schemes_.find(scheme) != disabled_schemes_.end(); |
357 } | 359 } |
358 | 360 |
359 void HttpAuthController::DisableAuthScheme(const std::string& scheme) { | 361 void HttpAuthController::DisableAuthScheme(const std::string& scheme) { |
360 disabled_schemes_.insert(scheme); | 362 disabled_schemes_.insert(scheme); |
361 } | 363 } |
362 | 364 |
363 } // namespace net | 365 } // namespace net |
OLD | NEW |