Commit f0ba93e4 authored by Sujie Zhu's avatar Sujie Zhu Committed by Commit Bot

[Autofill local card migration settings page] Add migration experimental flag...

[Autofill local card migration settings page] Add migration experimental flag api for settings page(#1).

This is the start CL of triggering migration from settings page.

We modify the original Boolean experimental flag to multi-state experimental flag in order to use one flag to control the normal submit form and settings page separately.

The following CLs will be:
1. We will use loadTimeData to get the experimental flag in the JS code. We will use this flag to protect and isolate the new changes.

2. Add new attribute of CreditCardEntry to check the migration requirements.

3. Display the migration button to the user when requirements meet.

4. Trigger migration when user click on the button with new API call.

Please refer to the design doc for more details: https://docs.google.com/document/d/1J7YyBeKZZaBhjAHnMEezvuBa5x1pk_XCh_yZvV_HMmc/edit#heading=h.1wm3blr98d8i

Bug: 852904
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I5fbf0acc32853b5d2d86cfcd24f109f04341dddd
Reviewed-on: https://chromium-review.googlesource.com/1163067Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Sujie Zhu <sujiezhu@google.com>
Cr-Commit-Position: refs/heads/master@{#582183}
parent 55fdb8e0
...@@ -1215,6 +1215,19 @@ const FeatureEntry::FeatureVariation kExploreSitesVariations[] = { ...@@ -1215,6 +1215,19 @@ const FeatureEntry::FeatureVariation kExploreSitesVariations[] = {
{"Experimental", &kExploreSitesExperimental, 1, nullptr}}; {"Experimental", &kExploreSitesExperimental, 1, nullptr}};
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
const FeatureEntry::FeatureParam
kAutofillCreditCardLocalCardMigrationWithoutSettingsPage[] = {
{autofill::kAutofillCreditCardLocalCardMigrationParameterName,
autofill::
kAutofillCreditCardLocalCardMigrationParameterWithoutSettingsPage}};
const FeatureEntry::FeatureVariation
kAutofillCreditCardLocalCardMigrationVariations[] = {
{"(without settings page)",
kAutofillCreditCardLocalCardMigrationWithoutSettingsPage,
base::size(kAutofillCreditCardLocalCardMigrationWithoutSettingsPage),
nullptr}};
// RECORDING USER METRICS FOR FLAGS: // RECORDING USER METRICS FOR FLAGS:
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// The first line of the entry is the internal name. // The first line of the entry is the internal name.
...@@ -2981,7 +2994,10 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -2981,7 +2994,10 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kEnableAutofillCreditCardLocalCardMigrationName, flag_descriptions::kEnableAutofillCreditCardLocalCardMigrationName,
flag_descriptions::kEnableAutofillCreditCardLocalCardMigrationDescription, flag_descriptions::kEnableAutofillCreditCardLocalCardMigrationDescription,
kOsDesktop, kOsDesktop,
FEATURE_VALUE_TYPE(autofill::kAutofillCreditCardLocalCardMigration)}, FEATURE_WITH_PARAMS_VALUE_TYPE(
autofill::kAutofillCreditCardLocalCardMigration,
kAutofillCreditCardLocalCardMigrationVariations,
"AutofillLocalCardMigration")},
{"enable-autofill-credit-card-upload-editable-cardholder-name", {"enable-autofill-credit-card-upload-editable-cardholder-name",
flag_descriptions:: flag_descriptions::
kEnableAutofillCreditCardUploadEditableCardholderNameName, kEnableAutofillCreditCardUploadEditableCardholderNameName,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
...@@ -38,6 +39,9 @@ const base::Feature kAutofillCreditCardAblationExperiment{ ...@@ -38,6 +39,9 @@ const base::Feature kAutofillCreditCardAblationExperiment{
"AutofillCreditCardAblationExperiment", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillCreditCardAblationExperiment", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAutofillCreditCardLocalCardMigration{ const base::Feature kAutofillCreditCardLocalCardMigration{
"AutofillCreditCardLocalCardMigration", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillCreditCardLocalCardMigration", base::FEATURE_DISABLED_BY_DEFAULT};
const char kAutofillCreditCardLocalCardMigrationParameterName[] = "variant";
const char kAutofillCreditCardLocalCardMigrationParameterWithoutSettingsPage[] =
"without-settings-page";
const base::Feature kAutofillDeleteDisusedAddresses{ const base::Feature kAutofillDeleteDisusedAddresses{
"AutofillDeleteDisusedAddresses", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillDeleteDisusedAddresses", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kAutofillDeleteDisusedCreditCards{ const base::Feature kAutofillDeleteDisusedCreditCards{
...@@ -100,8 +104,19 @@ bool IsAutofillCreditCardAssistEnabled() { ...@@ -100,8 +104,19 @@ bool IsAutofillCreditCardAssistEnabled() {
#endif #endif
} }
bool IsAutofillCreditCardLocalCardMigrationExperimentEnabled() { LocalCardMigrationExperimentalFlag GetLocalCardMigrationExperimentalFlag() {
return base::FeatureList::IsEnabled(kAutofillCreditCardLocalCardMigration); if (!base::FeatureList::IsEnabled(kAutofillCreditCardLocalCardMigration))
return LocalCardMigrationExperimentalFlag::kMigrationDisabled;
std::string param = base::GetFieldTrialParamValueByFeature(
kAutofillCreditCardLocalCardMigration,
kAutofillCreditCardLocalCardMigrationParameterName);
if (param ==
kAutofillCreditCardLocalCardMigrationParameterWithoutSettingsPage) {
return LocalCardMigrationExperimentalFlag::kMigrationWithoutSettingsPage;
}
return LocalCardMigrationExperimentalFlag::kMigrationIncludeSettingsPage;
} }
bool OfferStoreUnmaskedCards() { bool OfferStoreUnmaskedCards() {
......
...@@ -48,6 +48,10 @@ extern const base::Feature kAutofillVoteUsingInvalidProfileData; ...@@ -48,6 +48,10 @@ extern const base::Feature kAutofillVoteUsingInvalidProfileData;
extern const char kCreditCardSigninPromoImpressionLimitParamKey[]; extern const char kCreditCardSigninPromoImpressionLimitParamKey[];
extern const char kAutofillCreditCardLastUsedDateShowExpirationDateKey[]; extern const char kAutofillCreditCardLastUsedDateShowExpirationDateKey[];
extern const char kAutofillUpstreamMaxMinutesSinceAutofillProfileUseKey[]; extern const char kAutofillUpstreamMaxMinutesSinceAutofillProfileUseKey[];
extern const base::Feature kAutofillCreditCardLocalCardMigration;
extern const char kAutofillCreditCardLocalCardMigrationParameterName[];
extern const char
kAutofillCreditCardLocalCardMigrationParameterWithoutSettingsPage[];
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
extern const base::Feature kMacViewsAutofillPopup; extern const base::Feature kMacViewsAutofillPopup;
...@@ -74,9 +78,22 @@ bool IsCreditCardUploadEnabled(const PrefService* pref_service, ...@@ -74,9 +78,22 @@ bool IsCreditCardUploadEnabled(const PrefService* pref_service,
const syncer::SyncService* sync_service, const syncer::SyncService* sync_service,
const std::string& user_email); const std::string& user_email);
// Returns whether Autofill credit card local card migration experiment is // Enum for local card migration experimental flag states.
// enabled. enum class LocalCardMigrationExperimentalFlag {
bool IsAutofillCreditCardLocalCardMigrationExperimentEnabled(); // Local card migration disabled.
kMigrationDisabled,
// Only migrate local cards when user submits form.
kMigrationWithoutSettingsPage,
// Migrate both on submitted form and from settings page.
kMigrationIncludeSettingsPage,
};
// Returns kMigrationDisabled if no experimental behavior is enabled for
// kAutofillCreditCardLocalCardMigration; Return kMigrationIncludeSettingsPage
// if user enables the local card migration and does not exclude the settings
// page. Return kMigrationWithoutSettingsPage if user chooses to exclude the
// settings page migration.
LocalCardMigrationExperimentalFlag GetLocalCardMigrationExperimentalFlag();
// For testing purposes; not to be launched. When enabled, Chrome Upstream // For testing purposes; not to be launched. When enabled, Chrome Upstream
// always requests that the user enters/confirms cardholder name in the // always requests that the user enters/confirms cardholder name in the
......
...@@ -116,7 +116,8 @@ bool LocalCardMigrationManager::IsCreditCardMigrationEnabled() { ...@@ -116,7 +116,8 @@ bool LocalCardMigrationManager::IsCreditCardMigrationEnabled() {
// Confirm that the user is signed in, syncing, and the proper experiment // Confirm that the user is signed in, syncing, and the proper experiment
// flags are enabled. // flags are enabled.
bool migration_experiment_enabled = bool migration_experiment_enabled =
IsAutofillCreditCardLocalCardMigrationExperimentEnabled(); GetLocalCardMigrationExperimentalFlag() !=
LocalCardMigrationExperimentalFlag::kMigrationDisabled;
bool credit_card_upload_enabled = ::autofill::IsCreditCardUploadEnabled( bool credit_card_upload_enabled = ::autofill::IsCreditCardUploadEnabled(
client_->GetPrefs(), client_->GetSyncService(), client_->GetPrefs(), client_->GetSyncService(),
client_->GetIdentityManager()->GetPrimaryAccountInfo().email); client_->GetIdentityManager()->GetPrimaryAccountInfo().email);
......
...@@ -26,7 +26,8 @@ TestLocalCardMigrationManager::~TestLocalCardMigrationManager() {} ...@@ -26,7 +26,8 @@ TestLocalCardMigrationManager::~TestLocalCardMigrationManager() {}
bool TestLocalCardMigrationManager::IsCreditCardMigrationEnabled() { bool TestLocalCardMigrationManager::IsCreditCardMigrationEnabled() {
bool migration_experiment_enabled = bool migration_experiment_enabled =
IsAutofillCreditCardLocalCardMigrationExperimentEnabled(); GetLocalCardMigrationExperimentalFlag() !=
LocalCardMigrationExperimentalFlag::kMigrationDisabled;
bool has_google_payments_account = bool has_google_payments_account =
(static_cast<int64_t>(payments_client_->GetPrefService()->GetDouble( (static_cast<int64_t>(payments_client_->GetPrefService()->GetDouble(
prefs::kAutofillBillingCustomerNumber)) != 0); prefs::kAutofillBillingCustomerNumber)) != 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment