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..9caeb408c877360bb144e4e547df020b0cf231d0 |
| --- /dev/null |
| +++ b/chrome/browser/password_manager/account_chooser_infobar_delegate_android.cc |
| @@ -0,0 +1,52 @@ |
| +// 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) { |
| +} |
| + |
| +AccountChooserInfoBarDelegateAndroid::~AccountChooserInfoBarDelegateAndroid() { |
| +} |
| + |
| +void AccountChooserInfoBarDelegateAndroid::ChooseCredential( |
| + size_t credential_index, |
| + password_manager::CredentialType credential_type) { |
| + using namespace password_manager; |
|
Mike West
2015/02/19 10:06:17
Nit: I don't think we generally do this sort of sc
Mike West
2015/02/19 10:06:17
Nit: I don't think we generally do this sort of sc
Peter Kasting
2015/02/19 10:24:24
I'm OK with it if it makes the code below noticeab
|
| + if (credential_type == CredentialType::CREDENTIAL_TYPE_EMPTY) { |
| + ui_controller_->ChooseCredential(autofill::PasswordForm(), credential_type); |
| + return; |
| + } |
| + DCHECK(credential_type == CredentialType::CREDENTIAL_TYPE_LOCAL || |
| + credential_type == CredentialType::CREDENTIAL_TYPE_FEDERATED); |
| + auto& credentials_forms = |
| + (credential_type == CredentialType::CREDENTIAL_TYPE_LOCAL) |
|
Mike West
2015/02/19 10:06:17
Nit: You don't need the () here.
Peter Kasting
2015/02/19 10:24:24
No, but I think it makes things a little more read
|
| + ? 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; |
| +} |