OLD | NEW |
---|---|
(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_assist_infobar_delegate_mobi le.h" | |
6 | |
7 #include "base/strings/utf_string_conversions.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.h" | |
11 #include "components/infobars/core/infobar_manager.h" | |
12 #include "grit/components_scaled_resources.h" | |
13 #include "grit/components_strings.h" | |
14 #include "ui/base/l10n/l10n_util.h" | |
15 #include "ui/base/window_open_disposition.h" | |
Peter Kasting
2016/07/29 21:26:34
You don't use this #include. Check to see if ther
Mathieu
2016/08/01 22:16:57
Done. Refined the includes, thanks.
| |
16 | |
17 namespace autofill { | |
18 | |
19 AutofillAssistInfoBarDelegateMobile::AutofillAssistInfoBarDelegateMobile( | |
20 const CreditCard& card, | |
21 const base::Closure& assist_callback) | |
22 : ConfirmInfoBarDelegate(), | |
23 assist_callback_(assist_callback), | |
24 issuer_icon_id_(CreditCard::IconResourceId(card.type())), | |
25 card_label_(base::string16(kMidlineEllipsis) + card.LastFourDigits()), | |
26 card_sub_label_(card.AbbreviatedExpirationDateForDisplay()) { | |
27 AutofillMetrics::LogCreditCardAssistInfoBarMetric( | |
28 AutofillMetrics::INFOBAR_SHOWN); | |
Peter Kasting
2016/07/29 21:26:34
This is a call that should probably be in the Crea
Mathieu
2016/08/01 22:16:57
Good catch! Now using a boolean to track whether t
| |
29 } | |
30 | |
31 AutofillAssistInfoBarDelegateMobile::~AutofillAssistInfoBarDelegateMobile() { | |
32 if (!had_user_interaction_) | |
33 LogUserAction(AutofillMetrics::INFOBAR_IGNORED); | |
34 } | |
35 | |
36 int AutofillAssistInfoBarDelegateMobile::GetIconId() const { | |
37 return IDR_INFOBAR_AUTOFILL_CC; | |
38 } | |
39 | |
40 base::string16 AutofillAssistInfoBarDelegateMobile::GetMessageText() const { | |
41 return l10n_util::GetStringUTF16( | |
42 IDS_AUTOFILL_CREDIT_CARD_ASSIST_INFOBAR_TITLE); | |
43 } | |
44 | |
45 infobars::InfoBarDelegate::Type | |
46 AutofillAssistInfoBarDelegateMobile::GetInfoBarType() const { | |
47 return PAGE_ACTION_TYPE; | |
48 } | |
49 | |
50 infobars::InfoBarDelegate::InfoBarIdentifier | |
51 AutofillAssistInfoBarDelegateMobile::GetIdentifier() const { | |
52 return AUTOFILL_CC_ASSIST_INFOBAR_DELEGATE; | |
53 } | |
54 | |
55 bool AutofillAssistInfoBarDelegateMobile::ShouldExpire( | |
56 const NavigationDetails& details) const { | |
57 // InfoBar should disappear when the page is navigated. | |
58 return true; | |
Peter Kasting
2016/07/29 21:26:34
It's very unlikely that you want to override the b
Mathieu
2016/08/01 22:16:57
Base class implementation SGTM, thanks.
| |
59 } | |
60 | |
61 void AutofillAssistInfoBarDelegateMobile::InfoBarDismissed() { | |
62 LogUserAction(AutofillMetrics::INFOBAR_DENIED); | |
63 } | |
64 | |
65 base::string16 AutofillAssistInfoBarDelegateMobile::GetButtonLabel( | |
66 InfoBarButton button) const { | |
67 return l10n_util::GetStringUTF16( | |
68 button == BUTTON_OK ? IDS_AUTOFILL_CREDIT_CARD_ASSIST_INFOBAR_ACCEPT | |
69 : IDS_AUTOFILL_CREDIT_CARD_ASSIST_INFOBAR_DENY); | |
70 } | |
71 | |
72 bool AutofillAssistInfoBarDelegateMobile::Accept() { | |
73 assist_callback_.Run(); | |
74 assist_callback_.Reset(); | |
Peter Kasting
2016/07/29 21:26:34
Why is this call needed?
Mathieu
2016/08/01 22:16:57
Removed.
| |
75 LogUserAction(AutofillMetrics::INFOBAR_ACCEPTED); | |
76 return true; | |
77 } | |
78 | |
79 bool AutofillAssistInfoBarDelegateMobile::Cancel() { | |
80 LogUserAction(AutofillMetrics::INFOBAR_DENIED); | |
81 return true; | |
82 } | |
83 | |
84 void AutofillAssistInfoBarDelegateMobile::LogUserAction( | |
85 AutofillMetrics::InfoBarMetric user_action) { | |
86 DCHECK(!had_user_interaction_); | |
87 | |
88 AutofillMetrics::LogCreditCardAssistInfoBarMetric(user_action); | |
89 had_user_interaction_ = true; | |
90 } | |
91 | |
92 } // namespace autofill | |
OLD | NEW |