| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro
id.h" |
| 6 |
| 7 #include <cstddef> |
| 8 |
| 9 #include "components/autofill/core/common/password_form.h" |
| 10 #include "components/password_manager/content/common/credential_manager_types.h" |
| 11 |
| 12 AccountChooserInfoBarDelegateAndroid::AccountChooserInfoBarDelegateAndroid( |
| 13 ManagePasswordsUIController* ui_controller) |
| 14 : ui_controller_(ui_controller) { |
| 15 } |
| 16 |
| 17 void AccountChooserInfoBarDelegateAndroid::choose_credential( |
| 18 unsigned int credential_index, |
| 19 password_manager::CredentialType credential_type) { |
| 20 using namespace password_manager; |
| 21 const size_t federated_credentials_size = |
| 22 ui_controller_->federated_credentials_forms().size(); |
| 23 const size_t local_credentials_size = |
| 24 ui_controller_->local_credentials_forms().size(); |
| 25 autofill::PasswordForm* password_form = nullptr; |
| 26 if (credential_type == CredentialType::CREDENTIAL_TYPE_LOCAL && |
| 27 credential_index < local_credentials_size) { |
| 28 password_form = ui_controller_->local_credentials_forms()[credential_index]; |
| 29 } else if (credential_type == CredentialType::CREDENTIAL_TYPE_FEDERATED && |
| 30 credential_index < federated_credentials_size) { |
| 31 password_form = |
| 32 ui_controller_->federated_credentials_forms()[credential_index]; |
| 33 } |
| 34 if (password_form) |
| 35 ui_controller_->ChooseCredential(*password_form, credential_type); |
| 36 } |
| 37 |
| 38 AccountChooserInfoBarDelegateAndroid* |
| 39 AccountChooserInfoBarDelegateAndroid::AsAccountChooserInfoBarDelegateAndroid() { |
| 40 return this; |
| 41 } |
| 42 |
| 43 infobars::InfoBarDelegate::Type |
| 44 AccountChooserInfoBarDelegateAndroid::GetInfoBarType() const { |
| 45 return PAGE_ACTION_TYPE; |
| 46 } |
| OLD | NEW |