| 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/chrome_password_manager_client.h" | 14 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 15 #include "chrome/browser/prerender/prerender_contents.h" | 15 #include "chrome/browser/prerender/prerender_contents.h" |
| 16 #include "chrome/browser/tab_contents/tab_util.h" | 16 #include "chrome/browser/tab_contents/tab_util.h" |
| 17 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
| 17 #include "components/password_manager/core/browser/password_manager.h" | 18 #include "components/password_manager/core/browser/password_manager.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/browser/resource_dispatcher_host.h" | 23 #include "content/public/browser/resource_dispatcher_host.h" |
| 23 #include "content/public/browser/resource_request_info.h" | 24 #include "content/public/browser/resource_request_info.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 26 #include "net/base/auth.h" | 27 #include "net/base/auth.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 129 |
| 129 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 130 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( |
| 130 render_process_host_id_, render_frame_id_); | 131 render_process_host_id_, render_frame_id_); |
| 131 return WebContents::FromRenderFrameHost(rfh); | 132 return WebContents::FromRenderFrameHost(rfh); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void LoginHandler::SetAuth(const base::string16& username, | 135 void LoginHandler::SetAuth(const base::string16& username, |
| 135 const base::string16& password) { | 136 const base::string16& password) { |
| 136 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 137 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 137 | 138 |
| 138 if (TestAndSetAuthHandled()) | 139 scoped_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; |
| 140 if (password_manager_ && password_manager_->client()->IsLoggingActive()) { |
| 141 logger.reset(new password_manager::BrowserSavePasswordProgressLogger( |
| 142 password_manager_->client())); |
| 143 logger->LogMessage( |
| 144 autofill::SavePasswordProgressLogger::STRING_SET_AUTH_METHOD); |
| 145 } |
| 146 |
| 147 bool already_handled = TestAndSetAuthHandled(); |
| 148 if (logger) { |
| 149 logger->LogBoolean( |
| 150 autofill::SavePasswordProgressLogger::STRING_AUTHENTICATION_HANDLED, |
| 151 already_handled); |
| 152 } |
| 153 if (already_handled) |
| 139 return; | 154 return; |
| 140 | 155 |
| 141 // Tell the password manager the credentials were submitted / accepted. | 156 // Tell the password manager the credentials were submitted / accepted. |
| 142 if (password_manager_) { | 157 if (password_manager_) { |
| 143 password_form_.username_value = username; | 158 password_form_.username_value = username; |
| 144 password_form_.password_value = password; | 159 password_form_.password_value = password; |
| 145 password_manager_->ProvisionallySavePassword(password_form_); | 160 password_manager_->ProvisionallySavePassword(password_form_); |
| 161 if (logger) { |
| 162 logger->LogPasswordForm( |
| 163 autofill::SavePasswordProgressLogger::STRING_LOGINHANDLER_FORM, |
| 164 password_form_); |
| 165 } |
| 146 } | 166 } |
| 147 | 167 |
| 148 // Calling NotifyAuthSupplied() directly instead of posting a task | 168 // Calling NotifyAuthSupplied() directly instead of posting a task |
| 149 // allows other LoginHandler instances to queue their | 169 // allows other LoginHandler instances to queue their |
| 150 // CloseContentsDeferred() before ours. Closing dialogs in the | 170 // CloseContentsDeferred() before ours. Closing dialogs in the |
| 151 // opposite order as they were created avoids races where remaining | 171 // opposite order as they were created avoids races where remaining |
| 152 // dialogs in the same tab may be briefly displayed to the user | 172 // dialogs in the same tab may be briefly displayed to the user |
| 153 // before they are removed. | 173 // before they are removed. |
| 154 NotifyAuthSupplied(username, password); | 174 NotifyAuthSupplied(username, password); |
| 155 | 175 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 490 |
| 471 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 491 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 472 net::URLRequest* request) { | 492 net::URLRequest* request) { |
| 473 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 493 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 474 BrowserThread::PostTask( | 494 BrowserThread::PostTask( |
| 475 BrowserThread::UI, FROM_HERE, | 495 BrowserThread::UI, FROM_HERE, |
| 476 base::Bind(&LoginDialogCallback, request->url(), | 496 base::Bind(&LoginDialogCallback, request->url(), |
| 477 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 497 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
| 478 return handler; | 498 return handler; |
| 479 } | 499 } |
| OLD | NEW |