Commit 4622e6e4 authored by sczs's avatar sczs Committed by Commit Bot

Dismisses SaveCard Infobar on Navigation in iOS

- Adds is_form_navigation member to the NavigationDetails struct. This
struct is sent to the InfobarDelegate after each Navigation.
- Dismisses the SaveCard Infobar unless the navigation was triggered
by a form submission or is a redirect.
- Creates kAutofillSaveCardDismissOnNavigation feature flag for the new
behaviour.

Bug: 1021412
Change-Id: I6cf5973a635586a8f21d65a50bb750a4ea0c4070
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890734
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712853}
parent 5f87dd90
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "build/branding_buildflags.h" #include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_experiments.h" #include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/common/autofill_constants.h" #include "components/autofill/core/common/autofill_constants.h"
...@@ -118,10 +119,22 @@ AutofillSaveCardInfoBarDelegateMobile::GetIdentifier() const { ...@@ -118,10 +119,22 @@ AutofillSaveCardInfoBarDelegateMobile::GetIdentifier() const {
bool AutofillSaveCardInfoBarDelegateMobile::ShouldExpire( bool AutofillSaveCardInfoBarDelegateMobile::ShouldExpire(
const NavigationDetails& details) const { const NavigationDetails& details) const {
#if defined(OS_IOS)
if (base::FeatureList::IsEnabled(
features::kAutofillSaveCardDismissOnNavigation)) {
// Expire the Infobar unless the navigation was triggered by the form that
// presented the Infobar, or the navigation is a redirect.
return !details.is_form_submission && !details.is_redirect;
} else {
// Use the default behavior used by Android.
return false;
}
#else // defined(OS_IOS)
// The user has submitted a form, causing the page to navigate elsewhere. We // The user has submitted a form, causing the page to navigate elsewhere. We
// don't want the infobar to be expired at this point, because the user won't // don't want the infobar to be expired at this point, because the user won't
// get a chance to answer the question. // get a chance to answer the question.
return false; return false;
#endif // defined(OS_IOS)
} }
void AutofillSaveCardInfoBarDelegateMobile::InfoBarDismissed() { void AutofillSaveCardInfoBarDelegateMobile::InfoBarDismissed() {
......
...@@ -67,6 +67,11 @@ const base::Feature kAutofillNoLocalSaveOnUnmaskSuccess{ ...@@ -67,6 +67,11 @@ const base::Feature kAutofillNoLocalSaveOnUnmaskSuccess{
const base::Feature kAutofillNoLocalSaveOnUploadSuccess{ const base::Feature kAutofillNoLocalSaveOnUploadSuccess{
"AutofillNoLocalSaveOnUploadSuccess", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillNoLocalSaveOnUploadSuccess", base::FEATURE_DISABLED_BY_DEFAULT};
// When enabled, the Save Card infobar will be dismissed by a user initiated
// navigation other than one caused by submitted form.
const base::Feature kAutofillSaveCardDismissOnNavigation{
"AutofillSaveCardDismissOnNavigation", base::FEATURE_ENABLED_BY_DEFAULT};
// Controls whether to show updated UI for the card unmask prompt. // Controls whether to show updated UI for the card unmask prompt.
const base::Feature kAutofillUpdatedCardUnmaskPromptUi{ const base::Feature kAutofillUpdatedCardUnmaskPromptUi{
"AutofillUpdatedCardUnmaskPromptUi", base::FEATURE_DISABLED_BY_DEFAULT}; "AutofillUpdatedCardUnmaskPromptUi", base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -28,6 +28,7 @@ extern const base::Feature kAutofillEnableLocalCardMigrationForNonSyncUser; ...@@ -28,6 +28,7 @@ extern const base::Feature kAutofillEnableLocalCardMigrationForNonSyncUser;
extern const base::Feature kAutofillEnableToolbarStatusChip; extern const base::Feature kAutofillEnableToolbarStatusChip;
extern const base::Feature kAutofillNoLocalSaveOnUnmaskSuccess; extern const base::Feature kAutofillNoLocalSaveOnUnmaskSuccess;
extern const base::Feature kAutofillNoLocalSaveOnUploadSuccess; extern const base::Feature kAutofillNoLocalSaveOnUploadSuccess;
extern const base::Feature kAutofillSaveCardDismissOnNavigation;
extern const base::Feature kAutofillUpdatedCardUnmaskPromptUi; extern const base::Feature kAutofillUpdatedCardUnmaskPromptUi;
extern const base::Feature kAutofillUpstream; extern const base::Feature kAutofillUpstream;
extern const base::Feature kAutofillUpstreamAllowAllEmailDomains; extern const base::Feature kAutofillUpstreamAllowAllEmailDomains;
......
...@@ -172,6 +172,8 @@ class InfoBarDelegate { ...@@ -172,6 +172,8 @@ class InfoBarDelegate {
bool did_replace_entry; bool did_replace_entry;
bool is_reload; bool is_reload;
bool is_redirect; bool is_redirect;
// True if the navigation was caused by a form submission.
bool is_form_submission = false;
}; };
// Value to use when the InfoBar has no icon to show. // Value to use when the InfoBar has no icon to show.
......
...@@ -556,6 +556,12 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -556,6 +556,12 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
{"use-WKWebView-loading", flag_descriptions::kUseWKWebViewLoadingName, {"use-WKWebView-loading", flag_descriptions::kUseWKWebViewLoadingName,
flag_descriptions::kUseWKWebViewLoadingDescription, flags_ui::kOsIos, flag_descriptions::kUseWKWebViewLoadingDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(web::features::kUseWKWebViewLoading)}, FEATURE_VALUE_TYPE(web::features::kUseWKWebViewLoading)},
{"autofill-save-card-dismiss-on-navigation",
flag_descriptions::kAutofillSaveCardDismissOnNavigationName,
flag_descriptions::kAutofillSaveCardDismissOnNavigationDescription,
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(
autofill::features::kAutofillSaveCardDismissOnNavigation)},
}; };
// Add all switches from experimental flags to |command_line|. // Add all switches from experimental flags to |command_line|.
......
...@@ -74,6 +74,12 @@ const char kAutofillPruneSuggestionsName[] = "Autofill Prune Suggestions"; ...@@ -74,6 +74,12 @@ const char kAutofillPruneSuggestionsName[] = "Autofill Prune Suggestions";
const char kAutofillPruneSuggestionsDescription[] = const char kAutofillPruneSuggestionsDescription[] =
"Further limits the number of suggestions in the Autofill dropdown."; "Further limits the number of suggestions in the Autofill dropdown.";
const char kAutofillSaveCardDismissOnNavigationName[] =
"Save Card Dismiss on Navigation";
const char kAutofillSaveCardDismissOnNavigationDescription[] =
"Dismisses the Save Card Infobar on a user initiated Navigation, other "
"than one caused by submitted form.";
const char kAutofillShowAllSuggestionsOnPrefilledFormsName[] = const char kAutofillShowAllSuggestionsOnPrefilledFormsName[] =
"Enable showing all suggestions when focusing prefilled field"; "Enable showing all suggestions when focusing prefilled field";
const char kAutofillShowAllSuggestionsOnPrefilledFormsDescription[] = const char kAutofillShowAllSuggestionsOnPrefilledFormsDescription[] =
......
...@@ -52,6 +52,11 @@ extern const char kAutofillNoLocalSaveOnUploadSuccessDescription[]; ...@@ -52,6 +52,11 @@ extern const char kAutofillNoLocalSaveOnUploadSuccessDescription[];
extern const char kAutofillPruneSuggestionsName[]; extern const char kAutofillPruneSuggestionsName[];
extern const char kAutofillPruneSuggestionsDescription[]; extern const char kAutofillPruneSuggestionsDescription[];
// Title and description for the flag to control dismissing the Save Card
// Infobar on Navigation.
extern const char kAutofillSaveCardDismissOnNavigationName[];
extern const char kAutofillSaveCardDismissOnNavigationDescription[];
// Title and description for the flag to control if prefilled value filter // Title and description for the flag to control if prefilled value filter
// profiles. // profiles.
extern const char kAutofillShowAllSuggestionsOnPrefilledFormsName[]; extern const char kAutofillShowAllSuggestionsOnPrefilledFormsName[];
......
...@@ -33,7 +33,8 @@ infobars::InfoBarDelegate::NavigationDetails CreateNavigationDetails( ...@@ -33,7 +33,8 @@ infobars::InfoBarDelegate::NavigationDetails CreateNavigationDetails(
navigation_details.is_reload = navigation_details.is_reload =
ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD); ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD);
navigation_details.is_redirect = ui::PageTransitionIsRedirect(transition); navigation_details.is_redirect = ui::PageTransitionIsRedirect(transition);
navigation_details.is_form_submission =
ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_FORM_SUBMIT);
return navigation_details; return navigation_details;
} }
......
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