| Index: components/autofill/core/browser/autofill_credit_card_filling_infobar_delegate_mobile.cc
|
| diff --git a/components/autofill/core/browser/autofill_credit_card_filling_infobar_delegate_mobile.cc b/components/autofill/core/browser/autofill_credit_card_filling_infobar_delegate_mobile.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..432bb262becf4bb2ec5a594c2d22a3a73b09b7e5
|
| --- /dev/null
|
| +++ b/components/autofill/core/browser/autofill_credit_card_filling_infobar_delegate_mobile.cc
|
| @@ -0,0 +1,89 @@
|
| +// Copyright 2016 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 "components/autofill/core/browser/autofill_credit_card_filling_infobar_delegate_mobile.h"
|
| +
|
| +#include "base/memory/ptr_util.h"
|
| +#include "components/autofill/core/browser/credit_card.h"
|
| +#include "components/autofill/core/common/autofill_constants.h"
|
| +#include "components/infobars/core/infobar_delegate.h"
|
| +#include "grit/components_scaled_resources.h"
|
| +#include "grit/components_strings.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +
|
| +namespace autofill {
|
| +
|
| +AutofillCreditCardFillingInfoBarDelegateMobile::
|
| + AutofillCreditCardFillingInfoBarDelegateMobile(
|
| + const CreditCard& card,
|
| + const base::Closure& card_filling_callback)
|
| + : ConfirmInfoBarDelegate(),
|
| + card_filling_callback_(card_filling_callback),
|
| + had_user_interaction_(false),
|
| + was_shown_(false),
|
| + issuer_icon_id_(CreditCard::IconResourceId(card.type())),
|
| + card_label_(base::string16(kMidlineEllipsis) + card.LastFourDigits()),
|
| + card_sub_label_(card.AbbreviatedExpirationDateForDisplay()) {}
|
| +
|
| +AutofillCreditCardFillingInfoBarDelegateMobile::
|
| + ~AutofillCreditCardFillingInfoBarDelegateMobile() {
|
| + if (was_shown_) {
|
| + AutofillMetrics::LogCreditCardFillingInfoBarMetric(
|
| + AutofillMetrics::INFOBAR_SHOWN);
|
| + if (!had_user_interaction_)
|
| + LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
|
| + }
|
| +}
|
| +
|
| +int AutofillCreditCardFillingInfoBarDelegateMobile::GetIconId() const {
|
| + return IDR_INFOBAR_AUTOFILL_CC;
|
| +}
|
| +
|
| +base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetMessageText()
|
| + const {
|
| + return l10n_util::GetStringUTF16(
|
| + IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_TITLE);
|
| +}
|
| +
|
| +void AutofillCreditCardFillingInfoBarDelegateMobile::InfoBarDismissed() {
|
| + LogUserAction(AutofillMetrics::INFOBAR_DENIED);
|
| +}
|
| +
|
| +bool AutofillCreditCardFillingInfoBarDelegateMobile::Accept() {
|
| + card_filling_callback_.Run();
|
| + LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
|
| + return true;
|
| +}
|
| +
|
| +bool AutofillCreditCardFillingInfoBarDelegateMobile::Cancel() {
|
| + LogUserAction(AutofillMetrics::INFOBAR_DENIED);
|
| + return true;
|
| +}
|
| +
|
| +infobars::InfoBarDelegate::Type
|
| +AutofillCreditCardFillingInfoBarDelegateMobile::GetInfoBarType() const {
|
| + return PAGE_ACTION_TYPE;
|
| +}
|
| +
|
| +infobars::InfoBarDelegate::InfoBarIdentifier
|
| +AutofillCreditCardFillingInfoBarDelegateMobile::GetIdentifier() const {
|
| + return AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_DELEGATE_ANDROID;
|
| +}
|
| +
|
| +base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetButtonLabel(
|
| + InfoBarButton button) const {
|
| + return l10n_util::GetStringUTF16(
|
| + button == BUTTON_OK ? IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_ACCEPT
|
| + : IDS_NO_THANKS);
|
| +}
|
| +
|
| +void AutofillCreditCardFillingInfoBarDelegateMobile::LogUserAction(
|
| + AutofillMetrics::InfoBarMetric user_action) {
|
| + DCHECK(!had_user_interaction_);
|
| +
|
| + AutofillMetrics::LogCreditCardFillingInfoBarMetric(user_action);
|
| + had_user_interaction_ = true;
|
| +}
|
| +
|
| +} // namespace autofill
|
|
|