| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( | 247 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( |
| 248 ScopedVector<autofill::PasswordForm> local_forms, | 248 ScopedVector<autofill::PasswordForm> local_forms, |
| 249 ScopedVector<autofill::PasswordForm> federated_forms, | 249 ScopedVector<autofill::PasswordForm> federated_forms, |
| 250 const GURL& origin, | 250 const GURL& origin, |
| 251 const CredentialsCallback& callback) { | 251 const CredentialsCallback& callback) { |
| 252 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one | 252 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one |
| 253 // form provided). | 253 // form provided). |
| 254 CredentialsCallback intercept = | 254 CredentialsCallback intercept = |
| 255 base::Bind(&ChromePasswordManagerClient::OnCredentialsChosen, | 255 base::Bind(&ChromePasswordManagerClient::OnCredentialsChosen, |
| 256 base::Unretained(this), callback, local_forms.size() == 1); | 256 base::Unretained(this), callback, local_forms.size() == 1); |
| 257 std::vector<std::unique_ptr<autofill::PasswordForm>> locals = |
| 258 password_manager_util::ConvertScopedVector(std::move(local_forms)); |
| 259 std::vector<std::unique_ptr<autofill::PasswordForm>> federations = |
| 260 password_manager_util::ConvertScopedVector(std::move(federated_forms)); |
| 257 #if defined(OS_ANDROID) | 261 #if defined(OS_ANDROID) |
| 258 // Deletes itself on the event from Java counterpart, when user interacts with | 262 // Deletes itself on the event from Java counterpart, when user interacts with |
| 259 // dialog. | 263 // dialog. |
| 260 AccountChooserDialogAndroid* acccount_chooser_dialog = | 264 AccountChooserDialogAndroid* acccount_chooser_dialog = |
| 261 new AccountChooserDialogAndroid(web_contents(), std::move(local_forms), | 265 new AccountChooserDialogAndroid(web_contents(), std::move(locals), |
| 262 std::move(federated_forms), origin, | 266 std::move(federations), origin, |
| 263 intercept); | 267 intercept); |
| 264 acccount_chooser_dialog->ShowDialog(); | 268 acccount_chooser_dialog->ShowDialog(); |
| 265 return true; | 269 return true; |
| 266 #else | 270 #else |
| 267 return PasswordsClientUIDelegateFromWebContents(web_contents()) | 271 return PasswordsClientUIDelegateFromWebContents(web_contents()) |
| 268 ->OnChooseCredentials(std::move(local_forms), std::move(federated_forms), | 272 ->OnChooseCredentials(std::move(locals), std::move(federations), origin, |
| 269 origin, intercept); | 273 intercept); |
| 270 #endif | 274 #endif |
| 271 } | 275 } |
| 272 | 276 |
| 273 void ChromePasswordManagerClient::OnCredentialsChosen( | 277 void ChromePasswordManagerClient::OnCredentialsChosen( |
| 274 const CredentialsCallback& callback, | 278 const CredentialsCallback& callback, |
| 275 bool one_local_credential, | 279 bool one_local_credential, |
| 276 const autofill::PasswordForm* form) { | 280 const autofill::PasswordForm* form) { |
| 277 callback.Run(form); | 281 callback.Run(form); |
| 278 // If a site gets back a credential some navigations are likely to occur. They | 282 // If a site gets back a credential some navigations are likely to occur. They |
| 279 // shouldn't trigger the autofill password manager. | 283 // shouldn't trigger the autofill password manager. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 295 driver->GeneratePassword(); | 299 driver->GeneratePassword(); |
| 296 } | 300 } |
| 297 | 301 |
| 298 void ChromePasswordManagerClient::NotifyUserAutoSignin( | 302 void ChromePasswordManagerClient::NotifyUserAutoSignin( |
| 299 ScopedVector<autofill::PasswordForm> local_forms, | 303 ScopedVector<autofill::PasswordForm> local_forms, |
| 300 const GURL& origin) { | 304 const GURL& origin) { |
| 301 DCHECK(!local_forms.empty()); | 305 DCHECK(!local_forms.empty()); |
| 302 // If a site gets back a credential some navigations are likely to occur. They | 306 // If a site gets back a credential some navigations are likely to occur. They |
| 303 // shouldn't trigger the autofill password manager. | 307 // shouldn't trigger the autofill password manager. |
| 304 password_manager_.DropFormManagers(); | 308 password_manager_.DropFormManagers(); |
| 309 std::vector<std::unique_ptr<autofill::PasswordForm>> forms = |
| 310 password_manager_util::ConvertScopedVector(std::move(local_forms)); |
| 305 #if BUILDFLAG(ANDROID_JAVA_UI) | 311 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 306 ShowAutoSigninPrompt(web_contents(), local_forms[0]->username_value); | 312 ShowAutoSigninPrompt(web_contents(), forms[0]->username_value); |
| 307 #else | 313 #else |
| 308 PasswordsClientUIDelegateFromWebContents(web_contents()) | 314 PasswordsClientUIDelegateFromWebContents(web_contents()) |
| 309 ->OnAutoSignin(std::move(local_forms), origin); | 315 ->OnAutoSignin(std::move(forms), origin); |
| 310 #endif | 316 #endif |
| 311 } | 317 } |
| 312 | 318 |
| 313 void ChromePasswordManagerClient::NotifyUserCouldBeAutoSignedIn( | 319 void ChromePasswordManagerClient::NotifyUserCouldBeAutoSignedIn( |
| 314 std::unique_ptr<autofill::PasswordForm> form) { | 320 std::unique_ptr<autofill::PasswordForm> form) { |
| 315 possible_auto_sign_in_ = std::move(form); | 321 possible_auto_sign_in_ = std::move(form); |
| 316 } | 322 } |
| 317 | 323 |
| 318 void ChromePasswordManagerClient::NotifySuccessfulLoginWithExistingPassword( | 324 void ChromePasswordManagerClient::NotifySuccessfulLoginWithExistingPassword( |
| 319 const autofill::PasswordForm& form) { | 325 const autofill::PasswordForm& form) { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 password_manager::mojom::CredentialManagerRequest request) { | 594 password_manager::mojom::CredentialManagerRequest request) { |
| 589 content::WebContents* web_contents = | 595 content::WebContents* web_contents = |
| 590 content::WebContents::FromRenderFrameHost(render_frame_host); | 596 content::WebContents::FromRenderFrameHost(render_frame_host); |
| 591 DCHECK(web_contents); | 597 DCHECK(web_contents); |
| 592 | 598 |
| 593 ChromePasswordManagerClient* instance = | 599 ChromePasswordManagerClient* instance = |
| 594 ChromePasswordManagerClient::FromWebContents(web_contents); | 600 ChromePasswordManagerClient::FromWebContents(web_contents); |
| 595 DCHECK(instance); | 601 DCHECK(instance); |
| 596 instance->credential_manager_impl_.BindRequest(std::move(request)); | 602 instance->credential_manager_impl_.BindRequest(std::move(request)); |
| 597 } | 603 } |
| OLD | NEW |