Commit 0b6f6e57 authored by Sujie Zhu's avatar Sujie Zhu Committed by Commit Bot

[Autofill] Fix local save metric for dynamic and accordion form

Set the |from_dynamic_change_form| and |has_non_focusable_field| in SaveCreditCardOptions when Chrome shows local save prompt to user from a dynamic/accordion form so that sub-histogram can be logged correctly.

We add tests to ensure these two fields are correctly populated in SaveCreditCardOptions when a user was prompted local-save/upload from a dynamic/accordion form. The tests for the local save sub-histogram were already introduced in save_card_bubble_controller_impl_unittest.cc

Bug: 989771
Change-Id: I286416e2d8a4f90f2e5740658cf414531ba0a574
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730853
Commit-Queue: Sujie Zhu <sujiezhu@google.com>
Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#684363}
parent 678cdaba
......@@ -475,6 +475,8 @@ CreditCard FormDataImporter::ExtractCreditCardFromForm(
const FormStructure& form,
bool* has_duplicate_field_type) {
*has_duplicate_field_type = false;
has_non_focusable_field_ = false;
from_dynamic_change_form_ = false;
CreditCard candidate_credit_card;
......
......@@ -421,8 +421,10 @@ void CreditCardSaveManager::OfferCardLocalSave() {
observer_for_testing_->OnOfferLocalSave();
client_->ConfirmSaveCreditCardLocally(
local_card_save_candidate_,
AutofillClient::SaveCreditCardOptions().with_show_prompt(
show_save_prompt_.value_or(true)),
AutofillClient::SaveCreditCardOptions()
.with_show_prompt(show_save_prompt_.value_or(true))
.with_from_dynamic_change_form(from_dynamic_change_form_)
.with_has_non_focusable_field(has_non_focusable_field_),
base::BindOnce(&CreditCardSaveManager::OnUserDidDecideOnLocalSave,
weak_ptr_factory_.GetWeakPtr()));
......
......@@ -121,6 +121,7 @@ void TestAutofillClient::ConfirmSaveCreditCardLocally(
LocalSaveCardPromptCallback callback) {
confirm_save_credit_card_locally_called_ = true;
offer_to_save_credit_card_bubble_was_shown_ = options.show_prompt;
save_credit_card_options_ = options;
std::move(callback).Run(AutofillClient::ACCEPTED);
}
......@@ -148,6 +149,7 @@ void TestAutofillClient::ConfirmSaveCreditCardToCloud(
SaveCreditCardOptions options,
UploadSaveCardPromptCallback callback) {
offer_to_save_credit_card_bubble_was_shown_ = options.show_prompt;
save_credit_card_options_ = options;
std::move(callback).Run(AutofillClient::ACCEPTED, {});
}
......
......@@ -159,6 +159,10 @@ class TestAutofillClient : public AutofillClient {
return offer_to_save_credit_card_bubble_was_shown_.value();
}
SaveCreditCardOptions get_save_credit_card_options() {
return save_credit_card_options_.value();
}
MockAutocompleteHistoryManager* GetMockAutocompleteHistoryManager() {
return &mock_autocomplete_history_manager_;
}
......@@ -200,6 +204,9 @@ class TestAutofillClient : public AutofillClient {
// otherwise.
base::Optional<bool> credit_card_name_fix_flow_bubble_was_shown_;
// Populated if local save or upload was offered.
base::Optional<SaveCreditCardOptions> save_credit_card_options_;
std::vector<std::string> migration_card_selection_;
DISALLOW_COPY_AND_ASSIGN(TestAutofillClient);
......
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