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

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: removed CreateCreditCardFillingInfoBar from interface 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 if (was_shown_) {
20 AutofillMetrics::LogCreditCardFillingInfoBarMetric(
21 AutofillMetrics::INFOBAR_SHOWN);
22 if (!had_user_interaction_)
23 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
24 }
25 }
26
27 int AutofillCreditCardFillingInfoBarDelegateMobile::GetIconId() const {
28 return IDR_INFOBAR_AUTOFILL_CC;
29 }
30
31 base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetMessageText()
32 const {
33 return l10n_util::GetStringUTF16(
34 IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_TITLE);
35 }
36
37 AutofillCreditCardFillingInfoBarDelegateMobile::
38 AutofillCreditCardFillingInfoBarDelegateMobile(
39 const CreditCard& card,
40 const base::Closure& card_filling_callback)
41 : ConfirmInfoBarDelegate(),
42 card_filling_callback_(card_filling_callback),
43 had_user_interaction_(false),
44 was_shown_(false),
45 issuer_icon_id_(CreditCard::IconResourceId(card.type())),
46 card_label_(base::string16(kMidlineEllipsis) + card.LastFourDigits()),
47 card_sub_label_(card.AbbreviatedExpirationDateForDisplay()) {}
48
49 infobars::InfoBarDelegate::Type
50 AutofillCreditCardFillingInfoBarDelegateMobile::GetInfoBarType() const {
51 return PAGE_ACTION_TYPE;
52 }
53
54 infobars::InfoBarDelegate::InfoBarIdentifier
55 AutofillCreditCardFillingInfoBarDelegateMobile::GetIdentifier() const {
56 return AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_DELEGATE_ANDROID;
57 }
58
59 void AutofillCreditCardFillingInfoBarDelegateMobile::InfoBarDismissed() {
60 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
61 }
62
63 base::string16 AutofillCreditCardFillingInfoBarDelegateMobile::GetButtonLabel(
64 InfoBarButton button) const {
65 return l10n_util::GetStringUTF16(
66 button == BUTTON_OK ? IDS_AUTOFILL_CREDIT_CARD_FILLING_INFOBAR_ACCEPT
67 : IDS_AUTOFILL_INFOBAR_PROMPT_DENY);
68 }
69
70 bool AutofillCreditCardFillingInfoBarDelegateMobile::Accept() {
71 card_filling_callback_.Run();
72 LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED);
73 return true;
74 }
75
76 bool AutofillCreditCardFillingInfoBarDelegateMobile::Cancel() {
77 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
78 return true;
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