| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
| 15 #include "chrome/browser/prerender/prerender_manager.h" |
| 16 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 17 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/tab_contents/tab_util.h" | 18 #include "chrome/browser/tab_contents/tab_util.h" |
| 16 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
| 20 #include "content/public/browser/resource_dispatcher_host.h" | 23 #include "content/public/browser/resource_dispatcher_host.h" |
| 21 #include "content/public/browser/resource_request_info.h" | 24 #include "content/public/browser/resource_request_info.h" |
| 22 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 23 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 24 #include "net/base/auth.h" | 27 #include "net/base/auth.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 LoginHandler* handler) { | 423 LoginHandler* handler) { |
| 421 WebContents* parent_contents = handler->GetWebContentsForLogin(); | 424 WebContents* parent_contents = handler->GetWebContentsForLogin(); |
| 422 if (!parent_contents || handler->WasAuthHandled()) { | 425 if (!parent_contents || handler->WasAuthHandled()) { |
| 423 // The request may have been cancelled, or it may be for a renderer | 426 // The request may have been cancelled, or it may be for a renderer |
| 424 // not hosted by a tab (e.g. an extension). Cancel just in case | 427 // not hosted by a tab (e.g. an extension). Cancel just in case |
| 425 // (cancelling twice is a no-op). | 428 // (cancelling twice is a no-op). |
| 426 handler->CancelAuth(); | 429 handler->CancelAuth(); |
| 427 return; | 430 return; |
| 428 } | 431 } |
| 429 | 432 |
| 433 prerender::PrerenderManager* prerender_manager = |
| 434 prerender::PrerenderManagerFactory::GetForProfile( |
| 435 Profile::FromBrowserContext(parent_contents->GetBrowserContext())); |
| 436 if (prerender_manager) { |
| 437 prerender::PrerenderContents* prerender_contents = |
| 438 prerender_manager->GetPrerenderContents(parent_contents); |
| 439 if (prerender_contents) { |
| 440 prerender_contents->Destroy( |
| 441 prerender::FINAL_STATUS_AUTH_NEEDED); |
| 442 return; |
| 443 } |
| 444 } |
| 445 |
| 430 PasswordManager* password_manager = | 446 PasswordManager* password_manager = |
| 431 PasswordManager::FromWebContents(parent_contents); | 447 PasswordManager::FromWebContents(parent_contents); |
| 432 if (!password_manager) { | 448 if (!password_manager) { |
| 433 // Same logic as above. | 449 // Same logic as above. |
| 434 handler->CancelAuth(); | 450 handler->CancelAuth(); |
| 435 return; | 451 return; |
| 436 } | 452 } |
| 437 | 453 |
| 438 // Tell the password manager to look for saved passwords. | 454 // Tell the password manager to look for saved passwords. |
| 439 std::vector<PasswordForm> v; | 455 std::vector<PasswordForm> v; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 462 | 478 |
| 463 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 479 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 464 net::URLRequest* request) { | 480 net::URLRequest* request) { |
| 465 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 481 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 466 BrowserThread::PostTask( | 482 BrowserThread::PostTask( |
| 467 BrowserThread::UI, FROM_HERE, | 483 BrowserThread::UI, FROM_HERE, |
| 468 base::Bind(&LoginDialogCallback, request->url(), | 484 base::Bind(&LoginDialogCallback, request->url(), |
| 469 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 485 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
| 470 return handler; | 486 return handler; |
| 471 } | 487 } |
| OLD | NEW |