Chromium Code Reviews| Index: chrome/browser/password_manager/account_chooser_infobar_delegate_android.cc |
| diff --git a/chrome/browser/password_manager/account_chooser_infobar_delegate_android.cc b/chrome/browser/password_manager/account_chooser_infobar_delegate_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b5fd0cb4e87c088499f106927842deb5f8cdcc1a |
| --- /dev/null |
| +++ b/chrome/browser/password_manager/account_chooser_infobar_delegate_android.cc |
| @@ -0,0 +1,46 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/password_manager/account_chooser_infobar_delegate_android.h" |
| + |
| +#include <cstddef> |
|
Peter Kasting
2015/02/16 20:37:07
You don't need this.
melandory
2015/02/17 16:16:57
Done.
|
| + |
| +#include "components/autofill/core/common/password_form.h" |
| +#include "components/password_manager/content/common/credential_manager_types.h" |
| + |
| +AccountChooserInfoBarDelegateAndroid::AccountChooserInfoBarDelegateAndroid( |
| + ManagePasswordsUIController* ui_controller) |
| + : ui_controller_(ui_controller) { |
| +} |
| + |
| +void AccountChooserInfoBarDelegateAndroid::choose_credential( |
| + unsigned int credential_index, |
| + password_manager::CredentialType credential_type) { |
| + using namespace password_manager; |
| + const size_t federated_credentials_size = |
| + ui_controller_->federated_credentials_forms().size(); |
| + const size_t local_credentials_size = |
| + ui_controller_->local_credentials_forms().size(); |
| + autofill::PasswordForm* password_form = nullptr; |
| + if (credential_type == CredentialType::CREDENTIAL_TYPE_LOCAL && |
| + credential_index < local_credentials_size) { |
| + password_form = ui_controller_->local_credentials_forms()[credential_index]; |
| + } else if (credential_type == CredentialType::CREDENTIAL_TYPE_FEDERATED && |
| + credential_index < federated_credentials_size) { |
| + password_form = |
| + ui_controller_->federated_credentials_forms()[credential_index]; |
| + } |
| + if (password_form) |
| + ui_controller_->ChooseCredential(*password_form, credential_type); |
|
Peter Kasting
2015/02/16 20:37:07
Nit: Simpler:
if ((credential_type != Credentia
melandory
2015/02/17 16:16:57
Great! I didn't like my code, but nothing more ele
|
| +} |
| + |
| +AccountChooserInfoBarDelegateAndroid* |
| +AccountChooserInfoBarDelegateAndroid::AsAccountChooserInfoBarDelegateAndroid() { |
| + return this; |
| +} |
| + |
| +infobars::InfoBarDelegate::Type |
| +AccountChooserInfoBarDelegateAndroid::GetInfoBarType() const { |
| + return PAGE_ACTION_TYPE; |
| +} |