| 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/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 15 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 16 #include "chrome/browser/prerender/prerender_contents.h" | 16 #include "chrome/browser/prerender/prerender_contents.h" |
| 17 #include "chrome/browser/tab_contents/tab_util.h" | 17 #include "chrome/browser/tab_contents/tab_util.h" |
| 18 #include "chrome/browser/ui/login/login_interstitial_delegate.h" | 18 #include "chrome/browser/ui/login/login_interstitial_delegate.h" |
| 19 #include "chrome/grit/generated_resources.h" | 19 #include "chrome/grit/generated_resources.h" |
| 20 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
| 20 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 21 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
| 21 #include "components/password_manager/core/browser/password_manager.h" | 22 #include "components/password_manager/core/browser/password_manager.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
| 24 #include "content/public/browser/notification_service.h" | 25 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
| 26 #include "content/public/browser/resource_dispatcher_host.h" | 27 #include "content/public/browser/resource_dispatcher_host.h" |
| 27 #include "content/public/browser/resource_request_info.h" | 28 #include "content/public/browser/resource_request_info.h" |
| 28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 29 #include "net/base/auth.h" | 30 #include "net/base/auth.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 129 } |
| 129 | 130 |
| 130 WebContents* LoginHandler::GetWebContentsForLogin() const { | 131 WebContents* LoginHandler::GetWebContentsForLogin() const { |
| 131 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 132 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 132 | 133 |
| 133 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 134 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( |
| 134 render_process_host_id_, render_frame_id_); | 135 render_process_host_id_, render_frame_id_); |
| 135 return WebContents::FromRenderFrameHost(rfh); | 136 return WebContents::FromRenderFrameHost(rfh); |
| 136 } | 137 } |
| 137 | 138 |
| 139 password_manager::PasswordManager* LoginHandler::GetPasswordManagerForLogin() { |
| 140 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( |
| 141 render_process_host_id_, render_frame_id_); |
| 142 return password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( |
| 143 rfh)->GetPasswordManager(); |
| 144 } |
| 145 |
| 138 void LoginHandler::SetAuth(const base::string16& username, | 146 void LoginHandler::SetAuth(const base::string16& username, |
| 139 const base::string16& password) { | 147 const base::string16& password) { |
| 140 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 148 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 141 | 149 |
| 142 scoped_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; | 150 scoped_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; |
| 143 if (password_manager_ && password_manager_->client()->IsLoggingActive()) { | 151 if (password_manager_ && password_manager_->client()->IsLoggingActive()) { |
| 144 logger.reset(new password_manager::BrowserSavePasswordProgressLogger( | 152 logger.reset(new password_manager::BrowserSavePasswordProgressLogger( |
| 145 password_manager_->client())); | 153 password_manager_->client())); |
| 146 logger->LogMessage( | 154 logger->LogMessage( |
| 147 autofill::SavePasswordProgressLogger::STRING_SET_AUTH_METHOD); | 155 autofill::SavePasswordProgressLogger::STRING_SET_AUTH_METHOD); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 if (!parent_contents) | 462 if (!parent_contents) |
| 455 return; | 463 return; |
| 456 prerender::PrerenderContents* prerender_contents = | 464 prerender::PrerenderContents* prerender_contents = |
| 457 prerender::PrerenderContents::FromWebContents(parent_contents); | 465 prerender::PrerenderContents::FromWebContents(parent_contents); |
| 458 if (prerender_contents) { | 466 if (prerender_contents) { |
| 459 prerender_contents->Destroy(prerender::FINAL_STATUS_AUTH_NEEDED); | 467 prerender_contents->Destroy(prerender::FINAL_STATUS_AUTH_NEEDED); |
| 460 return; | 468 return; |
| 461 } | 469 } |
| 462 | 470 |
| 463 password_manager::PasswordManager* password_manager = | 471 password_manager::PasswordManager* password_manager = |
| 464 ChromePasswordManagerClient::GetManagerFromWebContents(parent_contents); | 472 handler->GetPasswordManagerForLogin(); |
| 473 |
| 465 if (!password_manager) { | 474 if (!password_manager) { |
| 466 // Same logic as above. | 475 // Same logic as above. |
| 467 handler->CancelAuth(); | 476 handler->CancelAuth(); |
| 468 return; | 477 return; |
| 469 } | 478 } |
| 470 | 479 |
| 471 // Tell the password manager to look for saved passwords. | 480 // Tell the password manager to look for saved passwords. |
| 472 std::vector<PasswordForm> v; | 481 std::vector<PasswordForm> v; |
| 473 MakeInputForPasswordManager(request_url, auth_info, handler, &v); | 482 MakeInputForPasswordManager(request_url, auth_info, handler, &v); |
| 474 password_manager->OnPasswordFormsParsed(v); | 483 password_manager->OnPasswordFormsParsed(v); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 net::URLRequest* request) { | 554 net::URLRequest* request) { |
| 546 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; | 555 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; |
| 547 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 556 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 548 BrowserThread::PostTask( | 557 BrowserThread::PostTask( |
| 549 BrowserThread::UI, FROM_HERE, | 558 BrowserThread::UI, FROM_HERE, |
| 550 base::Bind(&LoginDialogCallback, request->url(), | 559 base::Bind(&LoginDialogCallback, request->url(), |
| 551 make_scoped_refptr(auth_info), make_scoped_refptr(handler), | 560 make_scoped_refptr(auth_info), make_scoped_refptr(handler), |
| 552 is_main_frame)); | 561 is_main_frame)); |
| 553 return handler; | 562 return handler; |
| 554 } | 563 } |
| OLD | NEW |