Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 438 LoginHandler* handler) { | 438 LoginHandler* handler) { |
| 439 TabContents* parent_contents = handler->GetTabContentsForLogin(); | 439 TabContents* parent_contents = handler->GetTabContentsForLogin(); |
| 440 if (!parent_contents || handler->WasAuthHandled()) { | 440 if (!parent_contents || handler->WasAuthHandled()) { |
| 441 // The request may have been cancelled, or it may be for a renderer | 441 // The request may have been cancelled, or it may be for a renderer |
| 442 // not hosted by a tab (e.g. an extension). Cancel just in case | 442 // not hosted by a tab (e.g. an extension). Cancel just in case |
| 443 // (cancelling twice is a no-op). | 443 // (cancelling twice is a no-op). |
| 444 handler->CancelAuth(); | 444 handler->CancelAuth(); |
| 445 return; | 445 return; |
| 446 } | 446 } |
| 447 | 447 |
| 448 TabContentsWrapper* wrapper = | |
| 449 TabContentsWrapper::GetCurrentWrapperForContents(parent_contents); | |
| 450 if (!wrapper) { | |
|
asanka
2011/12/01 21:46:39
I'm curious how this happens in practice. Can you
James Hawkins
2011/12/01 21:48:22
I don't know how it happens in the wild; we've got
| |
| 451 // Same logic as above. | |
| 452 handler->CancelAuth(); | |
| 453 return; | |
| 454 } | |
| 455 | |
| 448 // Tell the password manager to look for saved passwords. | 456 // Tell the password manager to look for saved passwords. |
| 449 TabContentsWrapper* wrapper = | |
| 450 TabContentsWrapper::GetCurrentWrapperForContents(parent_contents); | |
| 451 if (!wrapper) | |
| 452 NOTREACHED() << "Login dialog created for TabContents with no wrapper"; | |
| 453 | |
| 454 PasswordManager* password_manager = wrapper->password_manager(); | 457 PasswordManager* password_manager = wrapper->password_manager(); |
| 455 std::vector<PasswordForm> v; | 458 std::vector<PasswordForm> v; |
| 456 MakeInputForPasswordManager(request_url, auth_info, handler, &v); | 459 MakeInputForPasswordManager(request_url, auth_info, handler, &v); |
| 457 password_manager->OnPasswordFormsFound(v); | 460 password_manager->OnPasswordFormsFound(v); |
| 458 handler->SetPasswordManager(password_manager); | 461 handler->SetPasswordManager(password_manager); |
| 459 | 462 |
| 460 // The realm is controlled by the remote server, so there is no reason | 463 // The realm is controlled by the remote server, so there is no reason |
| 461 // to believe it is of a reasonable length. | 464 // to believe it is of a reasonable length. |
| 462 string16 elided_realm; | 465 string16 elided_realm; |
| 463 ui::ElideString(UTF8ToUTF16(auth_info->realm), 120, &elided_realm); | 466 ui::ElideString(UTF8ToUTF16(auth_info->realm), 120, &elided_realm); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 477 | 480 |
| 478 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 481 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 479 net::URLRequest* request) { | 482 net::URLRequest* request) { |
| 480 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 483 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 481 BrowserThread::PostTask( | 484 BrowserThread::PostTask( |
| 482 BrowserThread::UI, FROM_HERE, | 485 BrowserThread::UI, FROM_HERE, |
| 483 base::Bind(&LoginDialogCallback, request->url(), | 486 base::Bind(&LoginDialogCallback, request->url(), |
| 484 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 487 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
| 485 return handler; | 488 return handler; |
| 486 } | 489 } |
| OLD | NEW |