1 // Copyright 2019 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/common/autofill_payments_features.h"
6 
7 #include "base/command_line.h"
8 #include "base/feature_list.h"
9 #include "base/metrics/field_trial_params.h"
10 #include "base/strings/string16.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h"
15 #include "components/autofill/core/common/autofill_prefs.h"
16 #include "components/autofill/core/common/autofill_switches.h"
17 #include "components/prefs/pref_service.h"
18 #include "ui/base/l10n/l10n_util.h"
19 
20 namespace autofill {
21 namespace features {
22 
23 // Features
24 
25 // Controls whether or not Autofill client will populate form with CPAN and
26 // dCVV, rather than FPAN.
27 const base::Feature kAutofillAlwaysReturnCloudTokenizedCard{
28     "AutofillAlwaysReturnCloudTokenizedCard",
29     base::FEATURE_DISABLED_BY_DEFAULT};
30 
31 // If enabled, when a server card is unmasked, its info will be cached until
32 // page navigation to simplify consecutive fills on the same page.
33 const base::Feature kAutofillCacheServerCardInfo{
34     "AutofillCacheServerCardInfo", base::FEATURE_ENABLED_BY_DEFAULT};
35 
36 const base::Feature kAutofillCreditCardAblationExperiment{
37     "AutofillCreditCardAblationExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
38 
39 // Enables the use of platform authenticators through WebAuthn to retrieve
40 // credit cards from Google payments.
41 const base::Feature kAutofillCreditCardAuthentication{
42   "AutofillCreditCardAuthentication",
43 #if defined(OS_WIN) || defined(OS_MAC)
44       // Better Auth project is fully launched on Win/Mac.
45       base::FEATURE_ENABLED_BY_DEFAULT
46 #else
47       base::FEATURE_DISABLED_BY_DEFAULT
48 #endif
49 };
50 
51 // When enabled, if credit card upload succeeded, the avatar icon will show a
52 // highlight otherwise, the credit card icon image will be updated and if user
53 // clicks on the icon, a save card failure bubble will pop up.
54 const base::Feature kAutofillCreditCardUploadFeedback{
55     "AutofillCreditCardUploadFeedback", base::FEATURE_DISABLED_BY_DEFAULT};
56 
57 // When enabled, the credit card nicknames will be manageable. They can be
58 // modified locally.
59 const base::Feature kAutofillEnableCardNicknameManagement{
60     "AutofillEnableCardNicknameManagement", base::FEATURE_DISABLED_BY_DEFAULT};
61 
62 // When enabled, shows the Google Pay logo on CVC prompt on Android.
63 const base::Feature kAutofillDownstreamCvcPromptUseGooglePayLogo{
64     "AutofillDownstreamCvcPromptUseGooglePayLogo",
65     base::FEATURE_DISABLED_BY_DEFAULT};
66 
67 // When enabled, the credit card nicknames will be manageable. They can be
68 // uploaded to Payments.
69 const base::Feature kAutofillEnableCardNicknameUpstream{
70     "AutofillEnableCardNicknameUpstream", base::FEATURE_DISABLED_BY_DEFAULT};
71 
72 // When enabled, autofill payments bubbles' result will be recorded as either
73 // 'accepted', 'cancelled', 'closed', 'not interacted' or 'lost focus'.
74 const base::Feature kAutofillEnableFixedPaymentsBubbleLogging{
75     "AutofillEnableFixedPaymentsBubbleLogging",
76     base::FEATURE_DISABLED_BY_DEFAULT};
77 
78 // Controls whether we show a Google-issued card in the suggestions list.
79 const base::Feature kAutofillEnableGoogleIssuedCard{
80     "AutofillEnableGoogleIssuedCard", base::FEATURE_DISABLED_BY_DEFAULT};
81 
82 // When enabled, offer data will be retrieved during downstream and shown in
83 // the dropdown list.
84 const base::Feature kAutofillEnableOffersInDownstream{
85     "kAutofillEnableOffersInDownstream", base::FEATURE_DISABLED_BY_DEFAULT};
86 
87 // When enabled and user is signed in, a footer indicating user's e-mail address
88 // and profile picture will appear at the bottom of SaveCardInfoBar.
89 const base::Feature kAutofillEnableSaveCardInfoBarAccountIndicationFooter{
90     "AutofillEnableSaveCardInfoBarAccountIndicationFooter",
91     base::FEATURE_DISABLED_BY_DEFAULT};
92 
93 // When enabled, all payments related bubbles will not be dismissed upon page
94 // navigation.
95 const base::Feature kAutofillEnableStickyPaymentsBubble{
96     "AutofillEnableStickyPaymentsBubble", base::FEATURE_DISABLED_BY_DEFAULT};
97 
98 // When enabled, Autofill data related icons will be shown in the status
99 // chip in toolbar along with the avatar toolbar button.
100 const base::Feature kAutofillEnableToolbarStatusChip{
101     "AutofillEnableToolbarStatusChip", base::FEATURE_DISABLED_BY_DEFAULT};
102 
103 // When enabled, the option of using cloud token virtual card will be offered
104 // when all requirements are met.
105 const base::Feature kAutofillEnableVirtualCard{
106     "AutofillEnableVirtualCard", base::FEATURE_DISABLED_BY_DEFAULT};
107 
108 // When enabled, the Save Card infobar will be dismissed by a user initiated
109 // navigation other than one caused by submitted form.
110 const base::Feature kAutofillSaveCardDismissOnNavigation{
111     "AutofillSaveCardDismissOnNavigation", base::FEATURE_ENABLED_BY_DEFAULT};
112 
113 // When enabled, the Save Card infobar supports editing before submitting.
114 const base::Feature kAutofillSaveCardInfobarEditSupport{
115     "AutofillSaveCardInfobarEditSupport", base::FEATURE_ENABLED_BY_DEFAULT};
116 
117 // Controls offering credit card upload to Google Payments. Cannot ever be
118 // ENABLED_BY_DEFAULT because the feature state depends on the user's country.
119 // There are countries we simply can't turn this on for, and they change over
120 // time, so it's important that we can flip a switch and be done instead of
121 // having old versions of Chrome forever do the wrong thing. Enabling it by
122 // default would mean that any first-run client without a Finch config won't get
123 // the overriding command to NOT turn it on, which becomes an issue.
124 const base::Feature kAutofillUpstream{"AutofillUpstream",
125                                       base::FEATURE_DISABLED_BY_DEFAULT};
126 
127 const base::Feature kAutofillUpstreamAllowAllEmailDomains{
128     "AutofillUpstreamAllowAllEmailDomains", base::FEATURE_DISABLED_BY_DEFAULT};
129 
ShouldShowImprovedUserConsentForCreditCardSave()130 bool ShouldShowImprovedUserConsentForCreditCardSave() {
131 #if defined(OS_WIN) || defined(OS_APPLE) || \
132     (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD)
133   // The new user consent UI is fully launched on MacOS, Windows and Linux.
134   return true;
135 #else
136   // Chrome OS does not have the new UI.
137   return false;
138 #endif
139 }
140 
141 }  // namespace features
142 }  // namespace autofill
143