Commit 93876a37 authored by siyua's avatar siyua Committed by Commit Bot

[AF][Upstream UI] Add No thanks button to save card offer bubbles on Chrome OS.

Use the same flag which controls android UI.

Bug: 980716
Change-Id: Ief150b48c3894682bbb64cbf50b0689c83a02179
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1709165Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Siyu An <siyua@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680619}
parent 3d17b017
...@@ -4150,7 +4150,8 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -4150,7 +4150,8 @@ const FeatureEntry kFeatureEntries[] = {
{"enable-autofill-save-card-show-no-thanks", {"enable-autofill-save-card-show-no-thanks",
flag_descriptions::kEnableAutofillSaveCardShowNoThanksName, flag_descriptions::kEnableAutofillSaveCardShowNoThanksName,
flag_descriptions::kEnableAutofillSaveCardShowNoThanksDescription, kOsAll, flag_descriptions::kEnableAutofillSaveCardShowNoThanksDescription,
kOsCrOS | kOsAndroid,
FEATURE_VALUE_TYPE(autofill::features::kAutofillSaveCardShowNoThanks)}, FEATURE_VALUE_TYPE(autofill::features::kAutofillSaveCardShowNoThanks)},
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
......
...@@ -1162,12 +1162,27 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1162,12 +1162,27 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// [No thanks] button (it has an [X] Close button instead.) // [No thanks] button (it has an [X] Close button instead.)
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Local_ShouldNotHaveNoThanksButton) { Local_ShouldNotHaveNoThanksButton) {
scoped_feature_list_.InitAndDisableFeature(
features::kAutofillSaveCardShowNoThanks);
FillForm(); FillForm();
SubmitFormAndWaitForCardLocalSaveBubble(); SubmitFormAndWaitForCardLocalSaveBubble();
// Assert that the cancel button cannot be found. // Assert that the cancel button cannot be found.
EXPECT_FALSE(FindViewInBubbleById(DialogViewId::CANCEL_BUTTON)); EXPECT_FALSE(FindViewInBubbleById(DialogViewId::CANCEL_BUTTON));
} }
// Tests the local save bubble. Ensures that the bubble has a
// [No thanks] button if |kAutofillSaveCardShowNoThanks| experiment is enabled.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Local_ShouldHaveNoThanksButtonIfExperimentEnabled) {
scoped_feature_list_.InitAndEnableFeature(
features::kAutofillSaveCardShowNoThanks);
FillForm();
SubmitFormAndWaitForCardLocalSaveBubble();
// Assert that the cancel button can be found.
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CANCEL_BUTTON));
}
#endif #endif
// Tests the local save bubble. Ensures that the bubble behaves correctly if // Tests the local save bubble. Ensures that the bubble behaves correctly if
...@@ -1387,7 +1402,11 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1387,7 +1402,11 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// [No thanks] button (it has an [X] Close button instead.) // [No thanks] button (it has an [X] Close button instead.)
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Upload_ShouldNotHaveNoThanksButton) { Upload_ShouldNotHaveNoThanksButton) {
scoped_feature_list_.InitAndEnableFeature(features::kAutofillUpstream); scoped_feature_list_.InitWithFeatures(
// Enabled
{features::kAutofillUpstream},
// Disabled
{features::kAutofillSaveCardShowNoThanks});
// Start sync. // Start sync.
harness_->SetupSync(); harness_->SetupSync();
...@@ -1398,6 +1417,26 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest, ...@@ -1398,6 +1417,26 @@ IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
// Assert that the cancel button cannot be found. // Assert that the cancel button cannot be found.
EXPECT_FALSE(FindViewInBubbleById(DialogViewId::CANCEL_BUTTON)); EXPECT_FALSE(FindViewInBubbleById(DialogViewId::CANCEL_BUTTON));
} }
// Tests the upload save bubble. Ensures that the bubble has a
// [No thanks] button if |kAutofillSaveCardShowNoThanks| experiment is enabled.
IN_PROC_BROWSER_TEST_F(SaveCardBubbleViewsFullFormBrowserTest,
Upload_ShouldHaveNoThanksButtonIfExperimentEnabled) {
scoped_feature_list_.InitWithFeatures(
// Enabled
{features::kAutofillSaveCardShowNoThanks, features::kAutofillUpstream},
// Disabled
{});
// Start sync.
harness_->SetupSync();
FillForm();
SubmitFormAndWaitForCardUploadSaveBubble();
// Assert that the cancel button can be found.
EXPECT_TRUE(FindViewInBubbleById(DialogViewId::CANCEL_BUTTON));
}
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
// Tests the upload save bubble. Ensures that clicking the top-right [X] close // Tests the upload save bubble. Ensures that clicking the top-right [X] close
......
...@@ -111,9 +111,10 @@ bool SaveCardOfferBubbleViews::Accept() { ...@@ -111,9 +111,10 @@ bool SaveCardOfferBubbleViews::Accept() {
} }
int SaveCardOfferBubbleViews::GetDialogButtons() const { int SaveCardOfferBubbleViews::GetDialogButtons() const {
if (features::ShouldShowImprovedUserConsentForCreditCardSave()) if (features::ShouldShowImprovedUserConsentForCreditCardSave() ||
base::FeatureList::IsEnabled(features::kAutofillSaveCardShowNoThanks)) {
return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
}
return ui::DIALOG_BUTTON_OK; return ui::DIALOG_BUTTON_OK;
} }
......
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