Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: components/autofill/core/browser/autofill_credit_card_filling_infobar_delegate_mobile.cc

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleaning Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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 "components/autofill/core/browser/autofill_credit_card_filling_infobar_ delegate_mobile.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "components/autofill/core/browser/credit_card.h"
9 #include "components/autofill/core/common/autofill_constants.h"
10 #include "components/infobars/core/infobar_delegate.h"
11 #include "grit/components_scaled_resources.h"
12 #include "grit/components_strings.h"
13 #include "ui/base/l10n/l10n_util.h"
14
15 namespace autofill {
16
17 AutofillCreditCardFillingInfoBarDelegateMobile::
18 AutofillCreditCardFillingInfoBarDelegateMobile(
19 const CreditCard& card,
20 const base::Closure& card_filling_callback)
21 : ConfirmInfoBarDelegate(),
22 card_filling_callback_(card_filling_callback),
23 had_user_interaction_(false),
24 was_shown_(false),
25 issuer_icon_id_(CreditCard::IconResourceId(card.type())),
26 card_label_(base::string16(kMidlineEllipsis) + card.LastFourDigits()),
27 card_sub_label_(card.AbbreviatedExpirationDateForDisplay()) {}
28
29 AutofillCreditCardFillingInfoBarDelegateMobile::
30 ~AutofillCreditCardFillingInfoBarDelegateMobile() {
31 if (was_shown_) {
32 AutofillMetrics::LogCreditCardFillingInfoBarMetric(
33 AutofillMetrics::INFOBAR_SHOWN);
34 if (!had_user_interaction_)
35 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
36 }
37 }
38
39 int AutofillCreditCardFillingInfoBarDelegateMobile::GetIconId() const {
40 return IDR_INFOBAR_AUTOFILL_CC;
41 }
42
43 base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetMessageText()
44 const {
45 return l10n_util::GetStringUTF16(
46 IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_TITLE);
47 }
48
49 void AutofillCreditCardFillingInfoBarDelegateMobile::InfoBarDismissed() {
50 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
51 }
52
53 bool AutofillCreditCardFillingInfoBarDelegateMobile::Accept() {
54 card_filling_callback_.Run();
55 LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
56 return true;
57 }
58
59 bool AutofillCreditCardFillingInfoBarDelegateMobile::Cancel() {
60 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
61 return true;
62 }
63
64 infobars::InfoBarDelegate::Type
65 AutofillCreditCardFillingInfoBarDelegateMobile::GetInfoBarType() const {
66 return PAGE_ACTION_TYPE;
67 }
68
69 infobars::InfoBarDelegate::InfoBarIdentifier
70 AutofillCreditCardFillingInfoBarDelegateMobile::GetIdentifier() const {
71 return AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_DELEGATE_ANDROID;
72 }
73
74 base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetButtonLabel(
75 InfoBarButton button) const {
76 return l10n_util::GetStringUTF16(
77 button == BUTTON_OK ? IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_ACCEPT
78 : IDS_NO_THANKS);
79 }
80
81 void AutofillCreditCardFillingInfoBarDelegateMobile::LogUserAction(
82 AutofillMetrics::InfoBarMetric user_action) {
83 DCHECK(!had_user_interaction_);
84
85 AutofillMetrics::LogCreditCardFillingInfoBarMetric(user_action);
86 had_user_interaction_ = true;
87 }
88
89 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698