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..a4bf95a3ed08e5470074d3f8cb3db1618e233095 |
| --- /dev/null |
| +++ b/chrome/browser/password_manager/account_chooser_infobar_delegate_android.cc |
| @@ -0,0 +1,50 @@ |
| +// 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 "chrome/browser/infobars/infobar_service.h" |
| +#include "chrome/browser/ui/android/infobars/account_chooser_infobar.h" |
| +#include "components/autofill/core/common/password_form.h" |
| +#include "components/password_manager/content/common/credential_manager_types.h" |
| + |
| +// static |
| +void AccountChooserInfoBarDelegateAndroid::Create( |
| + InfoBarService* infobar_service, |
| + ManagePasswordsUIController* ui_controller) { |
| + infobar_service->AddInfoBar( |
| + make_scoped_ptr(new AccountChooserInfoBar(make_scoped_ptr( |
| + new AccountChooserInfoBarDelegateAndroid(ui_controller))))); |
| +} |
| + |
| +AccountChooserInfoBarDelegateAndroid::AccountChooserInfoBarDelegateAndroid( |
| + ManagePasswordsUIController* ui_controller) |
| + : ui_controller_(ui_controller) { |
| +} |
| + |
| +void AccountChooserInfoBarDelegateAndroid::ChooseCredential( |
| + size_t credential_index, |
| + password_manager::CredentialType credential_type) { |
| + using namespace password_manager; |
| + DCHECK(credential_type == CredentialType::CREDENTIAL_TYPE_EMPTY || |
| + credential_type == CredentialType::CREDENTIAL_TYPE_LOCAL || |
| + credential_type == CredentialType::CREDENTIAL_TYPE_FEDERATED); |
|
Peter Kasting
2015/02/18 21:44:17
How about:
if (credential_type == CredentialTyp
melandory
2015/02/19 13:38:01
Done.
|
| + if (credential_type == CredentialType::CREDENTIAL_TYPE_EMPTY) { |
| + ui_controller_->ChooseCredential(autofill::PasswordForm(), credential_type); |
| + } else { |
| + auto& credentials_forms = |
| + (credential_type == CredentialType::CREDENTIAL_TYPE_LOCAL) |
| + ? ui_controller_->local_credentials_forms() |
| + : ui_controller_->federated_credentials_forms(); |
| + if (credential_index < credentials_forms.size()) { |
| + ui_controller_->ChooseCredential(*credentials_forms[credential_index], |
| + credential_type); |
| + } |
| + } |
| +} |
| + |
| +infobars::InfoBarDelegate::Type |
| +AccountChooserInfoBarDelegateAndroid::GetInfoBarType() const { |
| + return PAGE_ACTION_TYPE; |
| +} |