| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/ui/login/login_prompt.h" | 5 #include "chrome/browser/ui/login/login_prompt.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 handled_auth_ = true; | 343 handled_auth_ = true; |
| 344 return was_handled; | 344 return was_handled; |
| 345 } | 345 } |
| 346 | 346 |
| 347 // Calls SetAuth from the IO loop. | 347 // Calls SetAuth from the IO loop. |
| 348 void LoginHandler::SetAuthDeferred(const std::wstring& username, | 348 void LoginHandler::SetAuthDeferred(const std::wstring& username, |
| 349 const std::wstring& password) { | 349 const std::wstring& password) { |
| 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 351 | 351 |
| 352 if (request_) { | 352 if (request_) { |
| 353 request_->SetAuth(WideToUTF16Hack(username), WideToUTF16Hack(password)); | 353 if (auth_info_->scheme == ASCIIToWide("TLS-SRP")) { |
| 354 // TODO(sqs): ensure that this only happens if we are indeed using TLS-SRP |
| 355 // and that an HTTP scheme called "TLS-SRP" can't trigger this |
| 356 request_->SetTLSLogin(WideToUTF16Hack(username), |
| 357 WideToUTF16Hack(password)); |
| 358 request_->ContinueWithTLSLogin(); |
| 359 } else { |
| 360 request_->SetAuth(WideToUTF16Hack(username), WideToUTF16Hack(password)); |
| 361 } |
| 354 ResetLoginHandlerForRequest(request_); | 362 ResetLoginHandlerForRequest(request_); |
| 355 } | 363 } |
| 356 } | 364 } |
| 357 | 365 |
| 358 // Calls CancelAuth from the IO loop. | 366 // Calls CancelAuth from the IO loop. |
| 359 void LoginHandler::CancelAuthDeferred() { | 367 void LoginHandler::CancelAuthDeferred() { |
| 360 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 368 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 361 | 369 |
| 362 if (request_) { | 370 if (request_) { |
| 363 request_->CancelAuth(); | 371 if (auth_info_->scheme == ASCIIToWide("TLS-SRP")) { |
| 364 // Verify that CancelAuth doesn't destroy the request via our delegate. | 372 request_->CancelTLSLogin(); |
| 373 } else { |
| 374 request_->CancelAuth(); |
| 375 } |
| 376 // Verify that CancelAuth/CancelTLSLogin doesn't destroy the request via |
| 377 // our delegate. |
| 365 DCHECK(request_ != NULL); | 378 DCHECK(request_ != NULL); |
| 366 ResetLoginHandlerForRequest(request_); | 379 ResetLoginHandlerForRequest(request_); |
| 367 } | 380 } |
| 368 } | 381 } |
| 369 | 382 |
| 370 // Closes the view_contents from the UI loop. | 383 // Closes the view_contents from the UI loop. |
| 371 void LoginHandler::CloseContentsDeferred() { | 384 void LoginHandler::CloseContentsDeferred() { |
| 372 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 373 | 386 |
| 374 // The hosting ConstrainedWindow may have been freed. | 387 // The hosting ConstrainedWindow may have been freed. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 private: | 441 private: |
| 429 // Helper to create a PasswordForm and stuff it into a vector as input | 442 // Helper to create a PasswordForm and stuff it into a vector as input |
| 430 // for PasswordManager::PasswordFormsFound, the hook into PasswordManager. | 443 // for PasswordManager::PasswordFormsFound, the hook into PasswordManager. |
| 431 void MakeInputForPasswordManager( | 444 void MakeInputForPasswordManager( |
| 432 std::vector<PasswordForm>* password_manager_input) { | 445 std::vector<PasswordForm>* password_manager_input) { |
| 433 PasswordForm dialog_form; | 446 PasswordForm dialog_form; |
| 434 if (LowerCaseEqualsASCII(auth_info_->scheme, "basic")) { | 447 if (LowerCaseEqualsASCII(auth_info_->scheme, "basic")) { |
| 435 dialog_form.scheme = PasswordForm::SCHEME_BASIC; | 448 dialog_form.scheme = PasswordForm::SCHEME_BASIC; |
| 436 } else if (LowerCaseEqualsASCII(auth_info_->scheme, "digest")) { | 449 } else if (LowerCaseEqualsASCII(auth_info_->scheme, "digest")) { |
| 437 dialog_form.scheme = PasswordForm::SCHEME_DIGEST; | 450 dialog_form.scheme = PasswordForm::SCHEME_DIGEST; |
| 451 } else if (LowerCaseEqualsASCII(auth_info_->scheme, "tls-srp")) { |
| 452 dialog_form.scheme = PasswordForm::SCHEME_TLS_SRP; |
| 438 } else { | 453 } else { |
| 439 dialog_form.scheme = PasswordForm::SCHEME_OTHER; | 454 dialog_form.scheme = PasswordForm::SCHEME_OTHER; |
| 440 } | 455 } |
| 441 std::string host_and_port(WideToASCII(auth_info_->host_and_port)); | 456 std::string host_and_port(WideToASCII(auth_info_->host_and_port)); |
| 442 if (auth_info_->is_proxy) { | 457 if (auth_info_->is_proxy) { |
| 443 std::string origin = host_and_port; | 458 std::string origin = host_and_port; |
| 444 // We don't expect this to already start with http:// or https://. | 459 // We don't expect this to already start with http:// or https://. |
| 445 DCHECK(origin.find("http://") != 0 && origin.find("https://") != 0); | 460 DCHECK(origin.find("http://") != 0 && origin.find("https://") != 0 && |
| 461 origin.find("httpsv://") != 0); |
| 446 origin = std::string("http://") + origin; | 462 origin = std::string("http://") + origin; |
| 447 dialog_form.origin = GURL(origin); | 463 dialog_form.origin = GURL(origin); |
| 448 } else if (net::GetHostAndPort(request_url_) != host_and_port) { | 464 } else if (net::GetHostAndPort(request_url_) != host_and_port) { |
| 465 LOG(INFO) << net::GetHostAndPort(request_url_) << " vs " << host_and_port; |
| 449 dialog_form.origin = GURL(); | 466 dialog_form.origin = GURL(); |
| 450 NOTREACHED(); // crbug.com/32718 | 467 NOTREACHED(); // crbug.com/32718 |
| 451 } else { | 468 } else { |
| 452 dialog_form.origin = GURL(request_url_.scheme() + "://" + host_and_port); | 469 dialog_form.origin = GURL(request_url_.scheme() + "://" + host_and_port); |
| 453 } | 470 } |
| 454 dialog_form.signon_realm = GetSignonRealm(dialog_form.origin, *auth_info_); | 471 dialog_form.signon_realm = GetSignonRealm(dialog_form.origin, *auth_info_); |
| 455 password_manager_input->push_back(dialog_form); | 472 password_manager_input->push_back(dialog_form); |
| 456 // Set the password form for the handler (by copy). | 473 // Set the password form for the handler (by copy). |
| 457 handler_->SetPasswordForm(dialog_form); | 474 handler_->SetPasswordForm(dialog_form); |
| 458 } | 475 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 474 // Public API | 491 // Public API |
| 475 | 492 |
| 476 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 493 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 477 net::URLRequest* request) { | 494 net::URLRequest* request) { |
| 478 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 495 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 479 BrowserThread::PostTask( | 496 BrowserThread::PostTask( |
| 480 BrowserThread::UI, FROM_HERE, new LoginDialogTask( | 497 BrowserThread::UI, FROM_HERE, new LoginDialogTask( |
| 481 request->url(), auth_info, handler)); | 498 request->url(), auth_info, handler)); |
| 482 return handler; | 499 return handler; |
| 483 } | 500 } |
| OLD | NEW |