summaryrefslogtreecommitdiff
path: root/chromium/components/autofill/core/browser/form_data_importer.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/autofill/core/browser/form_data_importer.h')
-rw-r--r--chromium/components/autofill/core/browser/form_data_importer.h60
1 files changed, 55 insertions, 5 deletions
diff --git a/chromium/components/autofill/core/browser/form_data_importer.h b/chromium/components/autofill/core/browser/form_data_importer.h
index f60dc1b6794..596fd065c8d 100644
--- a/chromium/components/autofill/core/browser/form_data_importer.h
+++ b/chromium/components/autofill/core/browser/form_data_importer.h
@@ -15,6 +15,7 @@
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/credit_card_save_manager.h"
#include "components/autofill/core/browser/form_structure.h"
+#include "components/autofill/core/browser/local_card_migration_manager.h"
#include "components/autofill/core/browser/payments/payments_client.h"
#include "components/autofill/core/browser/personal_data_manager.h"
@@ -25,6 +26,18 @@ namespace autofill {
// Owned by AutofillManager.
class FormDataImporter {
public:
+ // Record type of the credit card imported from the form, if one exists.
+ enum ImportedCreditCardRecordType {
+ // No card was successfully imported from the form.
+ NO_CARD,
+ // The imported card is already stored locally on the device.
+ LOCAL_CARD,
+ // The imported card is already known to be a server card (either masked or
+ // unmasked).
+ SERVER_CARD,
+ // The imported card is not currently stored with the browser.
+ NEW_CARD,
+ };
// The parameters should outlive the FormDataImporter.
FormDataImporter(AutofillClient* client,
payments::PaymentsClient* payments_client,
@@ -37,6 +50,7 @@ class FormDataImporter {
// |credit_card_autofill_enabled| is set to |true|, also begins the process to
// offer local or upload credit card save.
void ImportFormData(const FormStructure& submitted_form,
+ bool profile_autofill_enabled,
bool credit_card_autofill_enabled);
// Extract credit card from the form structure. This function allows for
@@ -54,6 +68,12 @@ class FormDataImporter {
credit_card_save_manager_ = std::move(credit_card_save_manager);
}
+ // Exposed for testing.
+ void set_local_card_migration_manager(
+ std::unique_ptr<LocalCardMigrationManager> local_card_migration_manager) {
+ local_card_migration_manager_ = std::move(local_card_migration_manager);
+ }
+
private:
// Scans the given |form| for importable Autofill data. If the form includes
// sufficient address data for a new profile, it is immediately imported. If
@@ -66,6 +86,7 @@ class FormDataImporter {
// to upload it. Returns |true| if sufficient address or credit card data
// was found. Exposed for testing.
bool ImportFormData(const FormStructure& form,
+ bool profile_autofill_enabled,
bool credit_card_autofill_enabled,
bool should_return_local_card,
std::unique_ptr<CreditCard>* imported_credit_card);
@@ -95,18 +116,25 @@ class FormDataImporter {
CreditCard ExtractCreditCardFromForm(const FormStructure& form,
bool* hasDuplicateFieldType);
+ // The associated autofill client. Weak reference.
+ AutofillClient* client_;
+
// Responsible for managing credit card save flows (local or upload).
std::unique_ptr<CreditCardSaveManager> credit_card_save_manager_;
+ // Responsible for migrating locally saved credit cards to Google Pay.
+ std::unique_ptr<LocalCardMigrationManager> local_card_migration_manager_;
+
// The personal data manager, used to save and load personal data to/from the
// web database. This is overridden by the AutofillManagerTest.
// Weak reference.
// May be NULL. NULL indicates OTR.
PersonalDataManager* personal_data_manager_;
- // For metrics, to be passed to |credit_card_save_manager_|. Notes if the
- // credit card being offered for upload is already a locally-saved card.
- bool offering_upload_of_local_credit_card_ = false;
+ // Represents the type of the imported credit card from the submitted form.
+ // It will be used to determine whether to offer Upstream or card migration.
+ // Will be passed to |credit_card_save_manager_| for metrics.
+ ImportedCreditCardRecordType imported_credit_card_record_type_;
std::string app_locale_;
@@ -119,14 +147,36 @@ class FormDataImporter {
AllowDuplicateMaskedServerCardIfFlagEnabled);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest, DontDuplicateFullServerCard);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest, DontDuplicateMaskedServerCard);
+ FRIEND_TEST_ALL_PREFIXES(
+ FormDataImporterTest,
+ ImportFormData_ImportCreditCardRecordType_FullServerCard);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
- ImportCreditCard_TrackOfferingUploadOfLocalCard);
+ ImportFormData_ImportCreditCardRecordType_LocalCard);
+ FRIEND_TEST_ALL_PREFIXES(
+ FormDataImporterTest,
+ ImportFormData_ImportCreditCardRecordType_MaskedServerCard);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
- ImportCreditCard_TrackOfferingUploadOfNewCard);
+ ImportFormData_ImportCreditCardRecordType_NewCard);
+ FRIEND_TEST_ALL_PREFIXES(
+ FormDataImporterTest,
+ ImportFormData_ImportCreditCardRecordType_NoCard_ExpiredCard);
+ FRIEND_TEST_ALL_PREFIXES(
+ FormDataImporterTest,
+ ImportFormData_ImportCreditCardRecordType_NoCard_InvalidCardNumber);
+ FRIEND_TEST_ALL_PREFIXES(
+ FormDataImporterTest,
+ ImportFormData_ImportCreditCardRecordType_NoCard_NoCardOnForm);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
ImportFormData_OneAddressCreditCardDisabled);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
ImportFormData_OneAddressOneCreditCard);
+ FRIEND_TEST_ALL_PREFIXES(
+ FormDataImporterTest,
+ ImportFormData_SecondImportResetsCreditCardRecordType);
+ FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
+ ImportFormData_AddressesDisabledOneCreditCard);
+ FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
+ ImportFormData_AddressCreditCardDisabled);
FRIEND_TEST_ALL_PREFIXES(FormDataImporterTest,
ImportFormData_TwoAddressesOneCreditCard);
FRIEND_TEST_ALL_PREFIXES(