| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 NOTREACHED() << "Aura platforms should always use the bubble"; | 252 NOTREACHED() << "Aura platforms should always use the bubble"; |
| 253 #endif | 253 #endif |
| 254 } | 254 } |
| 255 return true; | 255 return true; |
| 256 } | 256 } |
| 257 | 257 |
| 258 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( | 258 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( |
| 259 ScopedVector<autofill::PasswordForm> local_forms, | 259 ScopedVector<autofill::PasswordForm> local_forms, |
| 260 ScopedVector<autofill::PasswordForm> federated_forms, | 260 ScopedVector<autofill::PasswordForm> federated_forms, |
| 261 const GURL& origin, | 261 const GURL& origin, |
| 262 base::Callback<void(const password_manager::CredentialInfo&)> callback) { | 262 const CredentialsCallback& callback) { |
| 263 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one | 263 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one |
| 264 // form provided). | 264 // form provided). |
| 265 base::Callback<void(const password_manager::CredentialInfo&)> intercept = | 265 CredentialsCallback intercept = |
| 266 local_forms.size() == 1u | 266 local_forms.size() == 1u |
| 267 ? base::Bind(&ChromePasswordManagerClient::OnCredentialsChosen, | 267 ? base::Bind(&ChromePasswordManagerClient::OnCredentialsChosen, |
| 268 base::Unretained(this), callback) | 268 base::Unretained(this), callback) |
| 269 : callback; | 269 : callback; |
| 270 #if defined(OS_ANDROID) | 270 #if defined(OS_ANDROID) |
| 271 // Deletes itself on the event from Java counterpart, when user interacts with | 271 // Deletes itself on the event from Java counterpart, when user interacts with |
| 272 // dialog. | 272 // dialog. |
| 273 AccountChooserDialogAndroid* acccount_chooser_dialog = | 273 AccountChooserDialogAndroid* acccount_chooser_dialog = |
| 274 new AccountChooserDialogAndroid(web_contents(), std::move(local_forms), | 274 new AccountChooserDialogAndroid(web_contents(), std::move(local_forms), |
| 275 std::move(federated_forms), origin, | 275 std::move(federated_forms), origin, |
| 276 intercept); | 276 intercept); |
| 277 acccount_chooser_dialog->ShowDialog(); | 277 acccount_chooser_dialog->ShowDialog(); |
| 278 return true; | 278 return true; |
| 279 #else | 279 #else |
| 280 return PasswordsClientUIDelegateFromWebContents(web_contents()) | 280 return PasswordsClientUIDelegateFromWebContents(web_contents()) |
| 281 ->OnChooseCredentials(std::move(local_forms), std::move(federated_forms), | 281 ->OnChooseCredentials(std::move(local_forms), std::move(federated_forms), |
| 282 origin, intercept); | 282 origin, intercept); |
| 283 #endif | 283 #endif |
| 284 } | 284 } |
| 285 | 285 |
| 286 void ChromePasswordManagerClient::OnCredentialsChosen( | 286 void ChromePasswordManagerClient::OnCredentialsChosen( |
| 287 base::Callback<void(const password_manager::CredentialInfo&)> callback, | 287 const CredentialsCallback& callback, |
| 288 const password_manager::CredentialInfo& credential) { | 288 const autofill::PasswordForm* form) { |
| 289 callback.Run(credential); | 289 callback.Run(form); |
| 290 if (credential.type != | 290 if (form) |
| 291 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY) { | |
| 292 PromptUserToEnableAutosigninIfNecessary(); | 291 PromptUserToEnableAutosigninIfNecessary(); |
| 293 } | |
| 294 } | 292 } |
| 295 | 293 |
| 296 void ChromePasswordManagerClient::ForceSavePassword() { | 294 void ChromePasswordManagerClient::ForceSavePassword() { |
| 297 password_manager::ContentPasswordManagerDriver* driver = | 295 password_manager::ContentPasswordManagerDriver* driver = |
| 298 driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); | 296 driver_factory_->GetDriverForFrame(web_contents()->GetFocusedFrame()); |
| 299 driver->ForceSavePassword(); | 297 driver->ForceSavePassword(); |
| 300 } | 298 } |
| 301 | 299 |
| 302 void ChromePasswordManagerClient::GeneratePassword() { | 300 void ChromePasswordManagerClient::GeneratePassword() { |
| 303 password_manager::ContentPasswordManagerDriver* driver = | 301 password_manager::ContentPasswordManagerDriver* driver = |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 | 605 |
| 608 const password_manager::CredentialsFilter* | 606 const password_manager::CredentialsFilter* |
| 609 ChromePasswordManagerClient::GetStoreResultFilter() const { | 607 ChromePasswordManagerClient::GetStoreResultFilter() const { |
| 610 return &credentials_filter_; | 608 return &credentials_filter_; |
| 611 } | 609 } |
| 612 | 610 |
| 613 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() | 611 const password_manager::LogManager* ChromePasswordManagerClient::GetLogManager() |
| 614 const { | 612 const { |
| 615 return log_manager_.get(); | 613 return log_manager_.get(); |
| 616 } | 614 } |
| OLD | NEW |