Skip to content

Commit

Permalink
Code cleanup for the Save Card UI experiment.
Browse files Browse the repository at this point in the history
The experiment was completed successfully and
now is being cleaned up. We will be implementing
the next steps based on
go/save-card-ui-exp-results

Bug: 1322299
Change-Id: I216ebe51976b45e0a39d6f410360749b92e97a39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4229592
Reviewed-by: Siyu An <siyua@chromium.org>
Reviewed-by: Evan Stade <estade@chromium.org>
Commit-Queue: Vipul Koul <koulvipul@google.com>
Cr-Commit-Position: refs/heads/main@{#1103000}
  • Loading branch information
Vipul Vinod Koul authored and Chromium LUCI CQ committed Feb 8, 2023
1 parent 9deb9cc commit a20fe63
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 339 deletions.
38 changes: 0 additions & 38 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -642,36 +642,6 @@ const FeatureEntry::FeatureVariation

#endif // BUILDFLAG(IS_ANDROID)

const FeatureEntry::FeatureParam
kAutofillSaveCardUiExperimentEnableCurrentWithUserAvatarAndEmail[] = {
{"autofill_save_card_ui_experiment_selector_in_number", "3"},
};

const FeatureEntry::FeatureParam
kAutofillSaveCardUiExperimentEnableEncryptedAndSecure[] = {
{"autofill_save_card_ui_experiment_selector_in_number", "2"},
};

const FeatureEntry::FeatureParam
kAutofillSaveCardUiExperimentEnableFasterAndProtected[] = {
{"autofill_save_card_ui_experiment_selector_in_number", "1"},
};

const FeatureEntry::FeatureVariation kAutofillSaveCardUiExperimentOptions[] = {
{flag_descriptions::kAutofillSaveCardUiExperimentFasterAndProtected,
kAutofillSaveCardUiExperimentEnableFasterAndProtected,
std::size(kAutofillSaveCardUiExperimentEnableFasterAndProtected), nullptr},
{flag_descriptions::kAutofillSaveCardUiExperimentEncryptedAndSecure,
kAutofillSaveCardUiExperimentEnableEncryptedAndSecure,
std::size(kAutofillSaveCardUiExperimentEnableEncryptedAndSecure), nullptr},
{flag_descriptions::
kAutofillSaveCardUiExperimentCurrentWithUserAvatarAndEmail,
kAutofillSaveCardUiExperimentEnableCurrentWithUserAvatarAndEmail,
std::size(
kAutofillSaveCardUiExperimentEnableCurrentWithUserAvatarAndEmail),
nullptr},
};

#if !BUILDFLAG(IS_CHROMEOS_ASH)
const FeatureEntry::FeatureParam kForceDark_SimpleHsl[] = {
{"inversion_method", "hsl_based"},
Expand Down Expand Up @@ -8747,14 +8717,6 @@ const FeatureEntry kFeatureEntries[] = {
permissions::features::kRecordPermissionExpirationTimestamps)},
#endif // !BUILDFLAG(IS_ANDROID)

{"autofill-enable-upstream-save-card-offer-ui-experiment",
flag_descriptions::kAutofillSaveCardUiExperimentName,
flag_descriptions::kAutofillSaveCardUiExperimentDescription, kOsDesktop,
FEATURE_WITH_PARAMS_VALUE_TYPE(
autofill::features::kAutofillSaveCardUiExperiment,
kAutofillSaveCardUiExperimentOptions,
"AutofillSaveCardUiExperiment")},

#if BUILDFLAG(IS_ANDROID)
{"network-service-in-process",
flag_descriptions::kNetworkServiceInProcessName,
Expand Down
12 changes: 0 additions & 12 deletions chrome/browser/flag_descriptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,6 @@ const char kAutofillSaveAndFillVPADescription[] =
"it will offer to save it. If saved, it will be offered for filling in "
"fields which expect a VPA.";

const char kAutofillSaveCardUiExperimentName[] =
"Enable different UI variants for the upload credit card save bubble";
const char kAutofillSaveCardUiExperimentDescription[] =
"When enabled, it will trigger slightly different UI variants along with "
"notification texts, when the upload credit card save bubble is shown.";
const char kAutofillSaveCardUiExperimentCurrentWithUserAvatarAndEmail[] =
"Current with Avatar and Email";
const char kAutofillSaveCardUiExperimentEncryptedAndSecure[] =
"Encrypted and Secure";
const char kAutofillSaveCardUiExperimentFasterAndProtected[] =
"Faster and Protected";

const char kAutofillShowManualFallbackInContextMenuName[] =
"Show Autofill options in Context Menu";
const char kAutofillShowManualFallbackInContextMenuDescription[] =
Expand Down
6 changes: 0 additions & 6 deletions chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,6 @@ extern const char kAutofillRemoveCardExpirationAndTypeTitlesDescription[];
extern const char kAutofillSaveAndFillVPAName[];
extern const char kAutofillSaveAndFillVPADescription[];

extern const char kAutofillSaveCardUiExperimentName[];
extern const char kAutofillSaveCardUiExperimentDescription[];
extern const char kAutofillSaveCardUiExperimentCurrentWithUserAvatarAndEmail[];
extern const char kAutofillSaveCardUiExperimentEncryptedAndSecure[];
extern const char kAutofillSaveCardUiExperimentFasterAndProtected[];

extern const char kAutofillShowManualFallbackInContextMenuName[];
extern const char kAutofillShowManualFallbackInContextMenuDescription[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,6 @@
#include "content/public/browser/navigation_handle.h"
#include "ui/base/l10n/l10n_util.h"

namespace {

autofill::SaveCardUiExperiment GetSaveCardUiExperimentArm() {
if (!base::FeatureList::IsEnabled(
autofill::features::kAutofillSaveCardUiExperiment)) {
return autofill::SaveCardUiExperiment::DEFAULT;
}

switch (
autofill::features::kAutofillSaveCardUiExperimentSelectorInNumber.Get()) {
case 1:
return autofill::SaveCardUiExperiment::FASTER_AND_PROTECTED;
case 2:
return autofill::SaveCardUiExperiment::ENCRYPTED_AND_SECURE;
default:
return autofill::SaveCardUiExperiment::DEFAULT;
}
}

} // namespace

namespace autofill {

SaveCardBubbleControllerImpl::SaveCardBubbleControllerImpl(
Expand Down Expand Up @@ -187,16 +166,6 @@ std::u16string SaveCardBubbleControllerImpl::GetWindowTitle() const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_LOCAL);
case BubbleType::UPLOAD_SAVE:
if (GetSaveCardUiExperimentArm() ==
SaveCardUiExperiment::FASTER_AND_PROTECTED) {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_EXPERIMENT_FASTER_AND_PROTECTED);
}
if (GetSaveCardUiExperimentArm() ==
SaveCardUiExperiment::ENCRYPTED_AND_SECURE) {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_EXPERIMENT_ENCRYPTED_AND_SECURE);
}
return features::ShouldShowImprovedUserConsentForCreditCardSave()
? l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_TO_CLOUD_V4)
Expand Down Expand Up @@ -225,17 +194,8 @@ std::u16string SaveCardBubbleControllerImpl::GetExplanatoryMessage() const {
IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_V3_WITH_NAME);
}

switch (GetSaveCardUiExperimentArm()) {
case SaveCardUiExperiment::FASTER_AND_PROTECTED:
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_EXPERIMENT_FASTER_AND_PROTECTED);
case SaveCardUiExperiment::ENCRYPTED_AND_SECURE:
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_EXPERIMENT_ENCRYPTED_AND_SECURE);
default:
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_V3);
}
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_V3);
}

std::u16string SaveCardBubbleControllerImpl::GetAcceptButtonText() const {
Expand Down
12 changes: 0 additions & 12 deletions chrome/browser/ui/autofill/payments/save_card_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@ enum class BubbleType {
INACTIVE
};

// The type of experiment running for the save card ui.
enum SaveCardUiExperiment {
// Show the text for default/current image.
DEFAULT = 0,

// Show the text for faster and protected image.
FASTER_AND_PROTECTED = 1,

// Show the text for encrypted and secure image.
ENCRYPTED_AND_SECURE = 2
};

} // namespace autofill

#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_SAVE_CARD_UI_H_
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,6 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/style/typography.h"

namespace {

ui::ImageModel GetProfileAvatar(AccountInfo account_info) {
// Get the user avatar icon.
gfx::Image account_avatar = account_info.account_image;

// Check for avatar being empty and replacing it with a
// placeholder if that is the case.
if (account_avatar.IsEmpty()) {
account_avatar = ui::ResourceBundle::GetSharedInstance().GetImageNamed(
profiles::GetPlaceholderAvatarIconResourceID());
}

int avatar_size = views::style::GetLineHeight(
views::style::CONTEXT_DIALOG_BODY_TEXT, views::style::STYLE_SECONDARY);

return ui::ImageModel::FromImage(profiles::GetSizedAvatarIcon(
account_avatar, avatar_size, avatar_size, profiles::SHAPE_CIRCLE));
}

} // namespace

namespace autofill {

SaveCardOfferBubbleViews::SaveCardOfferBubbleViews(
Expand All @@ -86,21 +64,11 @@ SaveCardOfferBubbleViews::SaveCardOfferBubbleViews(
const LegalMessageLines message_lines = controller->GetLegalMessageLines();

if (!message_lines.empty()) {
if (IsSaveCardUiExperimentEnabled()) {
std::string user_email = controller->GetAccountInfo().email;
// Display TOS with user avatar and email present in the footer.
legal_message_view_ = SetFootnoteView(std::make_unique<LegalMessageView>(
message_lines, base::UTF8ToUTF16(user_email),
GetProfileAvatar(controller->GetAccountInfo()),
base::BindRepeating(&SaveCardOfferBubbleViews::LinkClicked,
base::Unretained(this))));
} else {
legal_message_view_ = SetFootnoteView(std::make_unique<LegalMessageView>(
message_lines, /*user_email=*/absl::nullopt,
/*user_avatar=*/absl::nullopt,
base::BindRepeating(&SaveCardOfferBubbleViews::LinkClicked,
base::Unretained(this))));
}
legal_message_view_ = SetFootnoteView(std::make_unique<LegalMessageView>(
message_lines, /*user_email=*/absl::nullopt,
/*user_avatar=*/absl::nullopt,
base::BindRepeating(&SaveCardOfferBubbleViews::LinkClicked,
base::Unretained(this))));
InitFootnoteView(legal_message_view_);
}

Expand Down Expand Up @@ -180,24 +148,13 @@ void SaveCardOfferBubbleViews::AddedToWidget() {
// Set the header image.
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();

// Boolean to show the shield image for save card bubble. It is
// active/shown only when save card ui experiment is enabled and when the
// active experiment selected != 3 (existing option with user information
// view).
bool show_shield_header_image =
IsSaveCardUiExperimentEnabled() &&
features::kAutofillSaveCardUiExperimentSelectorInNumber.Get() != 3;

// Ternary operator added for the save card ui experiment where the feature
// flag and the experiment selected would determine if the experiment is
// active or not. Currently, any option != 0 and experiment flag enabled
// should trigger the experiment.
auto image_view = std::make_unique<ThemeTrackingNonAccessibleImageView>(
*bundle.GetImageSkiaNamed(
show_shield_header_image ? IDR_SAVE_CARD_SECURELY : IDR_SAVE_CARD),
*bundle.GetImageSkiaNamed(show_shield_header_image
? IDR_SAVE_CARD_SECURELY_DARK
: IDR_SAVE_CARD_DARK),
*bundle.GetImageSkiaNamed(IDR_SAVE_CARD),
*bundle.GetImageSkiaNamed(IDR_SAVE_CARD_DARK),
base::BindRepeating(&views::BubbleDialogDelegate::GetBackgroundColor,
base::Unretained(this)));
GetBubbleFrameView()->SetHeaderView(std::move(image_view));
Expand Down Expand Up @@ -384,12 +341,6 @@ SaveCardOfferBubbleViews::CreateUploadExplanationView() {
return upload_explanation_tooltip;
}

bool SaveCardOfferBubbleViews::IsSaveCardUiExperimentEnabled() {
return (
base::FeatureList::IsEnabled(features::kAutofillSaveCardUiExperiment) &&
features::kAutofillSaveCardUiExperimentSelectorInNumber.Get() != 0);
}

void SaveCardOfferBubbleViews::LinkClicked(const GURL& url) {
if (controller())
controller()->OnLegalMessageLinkClicked(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ class SaveCardOfferBubbleViews : public SaveCardBubbleViews,
std::unique_ptr<views::View> CreateRequestExpirationDateView();
std::unique_ptr<views::View> CreateUploadExplanationView();

// Method to check if the save card ui experiment is enabled where one of the
// 3 experimental save card bubble UI treatments are shown.
bool IsSaveCardUiExperimentEnabled();

void LinkClicked(const GURL& url);

raw_ptr<views::Textfield> cardholder_name_textfield_ = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,6 @@ void CreditCardSaveManager::AttemptToOfferCardUploadSave(
show_save_prompt_ = !GetCreditCardSaveStrikeDatabase()->ShouldBlockFeature(
base::UTF16ToUTF8(upload_request_.card.LastFourDigits()));

#if !BUILDFLAG(IS_IOS) && !BUILDFLAG(IS_ANDROID)

int save_card_ui_experiment_arm =
features::kAutofillSaveCardUiExperimentSelectorInNumber.Get();

// Adding the Save Card UI Experiment to the active experiments in upload
// request if the experiment is active. If 3rd save card ui experiment, aka
// Current with Avatar and Email, is selected then we would not add
// AutofillSaveCardUiExperiment to the active experiments list, as we want the
// current footer to be displayed.
if (base::FeatureList::IsEnabled(features::kAutofillSaveCardUiExperiment) &&
(save_card_ui_experiment_arm == 1 || save_card_ui_experiment_arm == 2)) {
upload_request_.active_experiments.push_back(
"AutofillSaveCardUiExperiment");
}
#endif

payments_client_->GetUploadDetails(
country_only_profiles, upload_request_.detected_values,
upload_request_.active_experiments, app_locale_,
Expand Down

0 comments on commit a20fe63

Please sign in to comment.