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" |
27 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
28 #include "net/http/http_transaction_factory.h" | 29 #include "net/http/http_transaction_factory.h" |
29 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
30 #include "net/url_request/url_request_context.h" | 31 #include "net/url_request/url_request_context.h" |
31 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
32 #include "ui/gfx/text_elider.h" | 33 #include "ui/gfx/text_elider.h" |
33 | 34 |
34 using autofill::PasswordForm; | 35 using autofill::PasswordForm; |
36 using autofill::SavePasswordProgressLogger; | |
35 using content::BrowserThread; | 37 using content::BrowserThread; |
36 using content::NavigationController; | 38 using content::NavigationController; |
37 using content::RenderViewHost; | 39 using content::RenderViewHost; |
38 using content::RenderViewHostDelegate; | 40 using content::RenderViewHostDelegate; |
39 using content::ResourceDispatcherHost; | 41 using content::ResourceDispatcherHost; |
40 using content::ResourceRequestInfo; | 42 using content::ResourceRequestInfo; |
41 using content::WebContents; | 43 using content::WebContents; |
42 | 44 |
43 class LoginHandlerImpl; | 45 class LoginHandlerImpl; |
44 | 46 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 130 |
129 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( | 131 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( |
130 render_process_host_id_, render_frame_id_); | 132 render_process_host_id_, render_frame_id_); |
131 return WebContents::FromRenderFrameHost(rfh); | 133 return WebContents::FromRenderFrameHost(rfh); |
132 } | 134 } |
133 | 135 |
134 void LoginHandler::SetAuth(const base::string16& username, | 136 void LoginHandler::SetAuth(const base::string16& username, |
135 const base::string16& password) { | 137 const base::string16& password) { |
136 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 138 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
137 | 139 |
138 if (TestAndSetAuthHandled()) | 140 bool already_handled = TestAndSetAuthHandled(); |
141 scoped_ptr<password_manager::BrowserSavePasswordProgressLogger> logger; | |
142 if (password_manager_ && password_manager_->client()->IsLoggingActive()) { | |
143 logger.reset(new password_manager::BrowserSavePasswordProgressLogger( | |
144 password_manager_->client())); | |
145 logger->LogMessage(SavePasswordProgressLogger::STRING_SET_AUTH_METHOD); | |
Ilya Sherman
2014/04/23 05:19:56
nit: Please move the construction of the logger, a
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
146 logger->LogBoolean( | |
147 SavePasswordProgressLogger::STRING_AUTHENTICATION_HANDLED, | |
148 already_handled); | |
149 } | |
150 if (already_handled ) | |
Ilya Sherman
2014/04/23 05:19:56
nit: Spurious space.
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
139 return; | 151 return; |
140 | 152 |
141 // Tell the password manager the credentials were submitted / accepted. | 153 // Tell the password manager the credentials were submitted / accepted. |
142 if (password_manager_) { | 154 if (password_manager_) { |
143 password_form_.username_value = username; | 155 password_form_.username_value = username; |
144 password_form_.password_value = password; | 156 password_form_.password_value = password; |
145 password_manager_->ProvisionallySavePassword(password_form_); | 157 password_manager_->ProvisionallySavePassword(password_form_); |
158 if (logger) | |
Ilya Sherman
2014/04/23 05:19:56
nit: Needs curly braces.
vabr (Chromium)
2014/04/23 18:15:35
Done.
| |
159 logger->LogPasswordForm( | |
160 SavePasswordProgressLogger::STRING_LOGINHANDLER_FORM, password_form_); | |
146 } | 161 } |
147 | 162 |
148 // Calling NotifyAuthSupplied() directly instead of posting a task | 163 // Calling NotifyAuthSupplied() directly instead of posting a task |
149 // allows other LoginHandler instances to queue their | 164 // allows other LoginHandler instances to queue their |
150 // CloseContentsDeferred() before ours. Closing dialogs in the | 165 // CloseContentsDeferred() before ours. Closing dialogs in the |
151 // opposite order as they were created avoids races where remaining | 166 // opposite order as they were created avoids races where remaining |
152 // dialogs in the same tab may be briefly displayed to the user | 167 // dialogs in the same tab may be briefly displayed to the user |
153 // before they are removed. | 168 // before they are removed. |
154 NotifyAuthSupplied(username, password); | 169 NotifyAuthSupplied(username, password); |
155 | 170 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 | 485 |
471 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 486 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
472 net::URLRequest* request) { | 487 net::URLRequest* request) { |
473 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 488 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
474 BrowserThread::PostTask( | 489 BrowserThread::PostTask( |
475 BrowserThread::UI, FROM_HERE, | 490 BrowserThread::UI, FROM_HERE, |
476 base::Bind(&LoginDialogCallback, request->url(), | 491 base::Bind(&LoginDialogCallback, request->url(), |
477 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 492 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
478 return handler; | 493 return handler; |
479 } | 494 } |
OLD | NEW |